diff --git a/Blog.Core.Common/Helper/UtilConvert.cs b/Blog.Core.Common/Helper/UtilConvert.cs
index b3feb14..0be5986 100644
--- a/Blog.Core.Common/Helper/UtilConvert.cs
+++ b/Blog.Core.Common/Helper/UtilConvert.cs
@@ -82,6 +82,15 @@ namespace Blog.Core
///
///
///
+ ///
+ public static bool IsNotEmptyOrNull(this object thisValue)
+ {
+ return ObjToString(thisValue) != "";
+ }
+ ///
+ ///
+ ///
+ ///
///
///
public static string ObjToString(this object thisValue, string errorValue)
diff --git a/Blog.Core/Controllers/BlogController.cs b/Blog.Core/Controllers/BlogController.cs
index 7c113b7..23737a6 100644
--- a/Blog.Core/Controllers/BlogController.cs
+++ b/Blog.Core/Controllers/BlogController.cs
@@ -48,20 +48,20 @@ namespace Blog.Core.Controllers
///
///
///
- ///
///
[HttpGet]
[AllowAnonymous]
//[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
//[ResponseCache(Duration = 600)]
- public async Task>> Get(int id, int page = 1, string bcategory = "技术博文", string key = "", int intPageSize = 6)
+ public async Task>> Get(int id, int page = 1, string bcategory = "技术博文", string key = "")
{
+ int intPageSize = 6;
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
{
key = "";
}
- Expression> whereExpression = a =>(a.bcategory == bcategory && a.IsDeleted == false) && ((a.btitle != null && a.btitle.Contains(key)) || (a.bcontent != null && a.bcontent.Contains(key)));
+ Expression> whereExpression = a => (a.bcategory == bcategory && a.IsDeleted == false) && ((a.btitle != null && a.btitle.Contains(key)) || (a.bcontent != null && a.bcontent.Contains(key)));
var pageModelBlog = await _blogArticleServices.QueryPage(whereExpression, page, intPageSize, " bID desc ");
@@ -133,6 +133,21 @@ namespace Blog.Core.Controllers
};
}
+ [HttpGet]
+ [Route("GoUrl")]
+ [AllowAnonymous]
+ public async Task GoUrl(int id)
+ {
+ var response = await _blogArticleServices.QueryById(id);
+ if (response != null && response.bsubmitter.IsNotEmptyOrNull())
+ {
+ response.btraffic += 1;
+ await _blogArticleServices.Update(response);
+ return Redirect(response.bsubmitter);
+ }
+
+ return null;
+ }
///
/// 获取博客测试信息 v2版本