public IActionResult PictureUpload(PictureDto body) { using EFCoreContextWrite context = new EFCore.EFCoreContextWrite(); if (!string.IsNullOrEmpty(body.PictureTitle) && !string.IsNullOrEmpty(body.PictureExplain)) { string token = _httpContext.HttpContext.Request.Headers["Authorization"]; AuthRedis.GetUserByToken(token, out UserInfo userInfo); PictureInfo PictureInfos = new PictureInfo() { Id = SequenceID.GetSequenceID(), CreateTime = DateTime.Now, Disable = false, PictureContent = body.url, UserID = userInfo.id, LastModifiedTime = DateTime.Now, PictureExplain = body.PictureExplain, PictureTitle = body.PictureTitle, RecommendIndex = body.Index, PictureType = body.PictureType, PhotoType = body.PhotoType }; context.Add(PictureInfos); context.SaveChanges(); PictureRedis.Del(); } return(Ok(new ApiResponse())); }
[AuthFilter]//身份认证,不带token或者token错误会被拦截器拦截进不来这个接口 public IActionResult WordDel(long id) { using EFCoreContextWrite context = new EFCore.EFCoreContextWrite(); var wordinfo = context.WordInfo.Single(x => x.Id == id); wordinfo.Disable = true; context.SaveChanges(); return(Ok(new ApiResponse())); }
[AuthFilter]//身份认证,不带token或者token错误会被拦截器拦截进不来这个接口 public IActionResult WordsUpLoad(WordDto body) { string token = _httpContext.HttpContext.Request.Headers["Authorization"]; AuthRedis.GetUserByToken(token, out UserInfo userInfo); using EFCoreContextWrite context = new EFCore.EFCoreContextWrite(); if (body.Eid == null) { int count = context.WordInfo.Where(x => x.PictureID == body.id).Count(); if (count > 0) { return(Ok(new ApiResponse(code: CodeAndMessage.已存在对应的资讯文档))); } WordInfo WordInfos = new WordInfo() { Id = SequenceID.GetSequenceID(), CreateTime = DateTime.Now, Disable = false, HtmlContent = body.HtmlContent, PictureID = body.id, LastModifiedTime = DateTime.Now, HtmlExplain = body.HtmlExplain, HtmlTitle = body.HtmlTitle, AttachedPath = body.AttachedPath }; context.Add(WordInfos); context.SaveChanges(); WordRedis.Del(); } else { var WordInfo = context.WordInfo.Single(x => x.Id == body.Eid); WordInfo.LastModifiedTime = DateTime.Now; WordInfo.HtmlContent = body.HtmlContent; WordInfo.HtmlExplain = body.HtmlExplain; WordInfo.HtmlTitle = body.HtmlTitle; WordInfo.AttachedPath = body.AttachedPath; context.SaveChanges(); WordRedis.Del(); } return(Ok(new ApiResponse())); }
[AuthFilter]//身份认证,不带token或者token错误会被拦截器拦截进不来这个接口 public IActionResult PictureDel(long id) { using EFCoreContextWrite context = new EFCore.EFCoreContextWrite(); var PictureInfo = context.PictureInfo.Single(x => x.Id == id); var WordInfo = context.WordInfo.Where(x => x.PictureID == id); PictureInfo.Disable = true; foreach (var item in WordInfo) { item.Disable = true; } context.SaveChanges(); WordRedis.Del(); PictureRedis.Del(); return(Ok(new ApiResponse())); }
public bool moreAdd(int i) { using EFCoreContextWrite context = new EFCore.EFCoreContextWrite(); Test test = new Test(); for (int j = 0; j <= i; j++) { test = new Test() { Id = SequenceID.GetSequenceID(), Name = "hangfire" }; context.Add(test); context.SaveChanges(); } TestRedis.Del(); return(true); }