完善推荐页显示

This commit is contained in:
橙子
2022-10-16 22:51:53 +08:00
parent 6d99539730
commit 50d43a2fc5
8 changed files with 33 additions and 26 deletions

View File

@@ -50,7 +50,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers
public override Task<Result> Add(ArticleEntity entity)
{
//如果标题为空默认为内容的前20个字符
entity.Title = string.IsNullOrEmpty(entity.Title) ? entity.Content.Substring(0, 20): entity.Title;
entity.Title = string.IsNullOrEmpty(entity.Title) ?
(entity.Content.Length > 20 ? entity.Content.Substring(0, 20) : entity.Content) :
entity.Title;
entity.UserId = HttpContext.GetUserIdInfo();
return base.Add(entity);
}