public IActionResult AddArticle(Article model) { if (model.KId <= 0) { tip.Message = "请选择一个文章栏目"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写文章标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } model.ItemImg = morIMG; model.AuthorId = Core.Admin.GetMyInfo().Id; model.Insert(); ArticleCategory.UpdateDetailCount(model.KId); SessionHelper.WriteSession("com_add_article_kid", model.KId); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public JsonResult DelArticle(int id) { Article entity = Article.Find(Article._.Id == id); if (entity == null) { tip.Message = "系统找不到本文章!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == entity.KId) == -1) { tip.Message = "者您没这个栏目的权限,无法删除该栏目文章!"; return(Json(tip)); } } if (my.Roles.OnlyEditMyselfArticle == 1 && entity.AuthorId != my.Id) { tip.Message = "系统限制,您无法删除非自己添加的文章!"; return(Json(tip)); } } int kid = entity.Id; //删除TAG //Tag.DeleteTag(RTType.RatuoModule.Article, entity.Id); Core.Admin.WriteLogActions("删除文章(id:" + entity.Id + ");"); entity.Delete(); ArticleCategory.UpdateDetailCount(kid); tip.Status = JsonTip.SUCCESS; tip.Message = "删除文章成功"; return(Json(tip)); }
public JsonResult DelArtice(int id) { Article entity = Article.Find(Article._.Id == id); if (entity == null) { tip.Message = "系统找不到本文章!"; return(Json(tip)); } int kid = entity.Id; //删除TAG //Tag.DeleteTag(RTType.RatuoModule.Article, entity.Id); Core.Admin.WriteLogActions("删除文章(id:" + entity.Id + ");"); entity.Delete(); ArticleCategory.UpdateDetailCount(kid); tip.Status = JsonTip.SUCCESS; tip.Message = "删除文章成功"; return(Json(tip)); }
public IActionResult AddArticle(Article model) { if (model.KId <= 0) { tip.Message = "请选择一个文章栏目"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写文章标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.FileName) && !Utils.ChekHTMLFileNameIsOK(model.FileName)) { tip.Message = "静态化文件名错误,请填写正确的,或者留空!"; return(Json(tip)); } Admin my = Admin.GetMyInfo(); List <int> aclist = new List <int>(); if (my.Roles.IsSuperAdmin != 1) { aclist = JsonConvert.DeserializeObject <List <int> >(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory); if (aclist == null) { aclist = new List <int>(); } if (aclist.Count > 0) { if (aclist.FindIndex(x => x == model.KId) == -1) { tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!"; return(Json(tip)); } } } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } model.ItemImg = morIMG; model.AuthorId = my.Id; model.Insert(); ArticleCategory.UpdateDetailCount(model.KId); SessionHelper.WriteSession("com_add_article_kid", model.KId); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章成功"; tip.ReturnUrl = "close"; return(Json(tip)); }