修复后台授权问题,调整后台列表批量操作例子
This commit is contained in:
@@ -717,5 +717,51 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 批量删除文章
|
||||
[HttpPost]
|
||||
[MyAuthorize("batch", "article", "JSON")]
|
||||
public IActionResult DoBatchDelArticle(string ids)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ids))
|
||||
{
|
||||
tip.Message = "请最少选择一篇文章!";
|
||||
return Json(tip);
|
||||
}
|
||||
List<int> listIds = new List<int>();
|
||||
try
|
||||
{
|
||||
listIds = JsonConvert.DeserializeObject<List<int>>(ids);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tip.Message = "转换出错:" + ex.Message;
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (listIds == null || listIds.Count < 1)
|
||||
{
|
||||
tip.Message = "请至少选择一篇文章!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
IList<Article> list = Article.FindAll(Article._.Id.In(listIds), null, null, 0, 0);
|
||||
if (list == null || list.Count < 1)
|
||||
{
|
||||
tip.Message = "请至少选择一篇文章!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
item.IsHide = 0;
|
||||
}
|
||||
list.Delete();
|
||||
Admin.WriteLogActions($"批量删除文章:{ids};");
|
||||
tip.Message = "批量删除文章成功!";
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using COMCMS.Common;
|
||||
using COMCMS.Core;
|
||||
using XCode;
|
||||
using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using COMCMS.Web.Models;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using COMCMS.Core.Models;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.IO;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
public class AttachController : AdminBaseController
|
||||
{
|
||||
private readonly SystemSetting _attachsetting;
|
||||
private IWebHostEnvironment _env;
|
||||
private AttachConfigEntity attach;
|
||||
public AttachController(IWebHostEnvironment env, IOptions<SystemSetting> attachsetting)
|
||||
{
|
||||
attach = Config.GetSystemConfig().AttachConfigEntity;
|
||||
_env = env;
|
||||
_attachsetting = attachsetting.Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 附件管理
|
||||
[HttpGet]
|
||||
[MyAuthorize("viewlist", "attach")]
|
||||
public IActionResult AttachList()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取附件所有目录
|
||||
[HttpPost]
|
||||
[MyAuthorize("viewlist", "attach","JSON")]
|
||||
public IActionResult GetDirList(string subdir)
|
||||
{
|
||||
string attachPath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
|
||||
|
||||
|
||||
//Directory.GetDirectories()
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
return Json(errorJson);
|
||||
}
|
||||
//判断是否是图片类型
|
||||
List<string> imgtypelist = new List<string> { "image/pjpeg", "image/png", "image/x-png", "image/gif", "image/bmp", "image/jpeg" };
|
||||
List<string> imgtypelist = new List<string> { "image/jpg", "image/png", "image/x-png", "image/gif", "image/bmp", "image/jpeg" };
|
||||
if (imgtypelist.FindIndex(x => x == upload.ContentType) == -1)
|
||||
{
|
||||
errorJson.error.message = "请选择一张图片!";
|
||||
@@ -244,7 +244,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//判断是否是图片,如果是图片,后面需要生成缩略图并可能的话,就加上水印
|
||||
bool isImage = false;
|
||||
//判断是否是图片类型
|
||||
List<string> imgtypelist = new List<string> { "image/pjpeg", "image/png", "image/x-png", "image/gif", "image/bmp" };
|
||||
List<string> imgtypelist = new List<string> { "image/jpg", "image/png", "image/x-png", "image/gif", "image/bmp", "image/jpeg" };
|
||||
if (imgtypelist.FindIndex(x => x == upload.ContentType) >= 0)
|
||||
{
|
||||
isImage = true;
|
||||
@@ -556,7 +556,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
if (data != null)
|
||||
{
|
||||
//判断是否是图片类型
|
||||
List<string> imgtypelist = new List<string> { "image/pjpeg", "image/png", "image/x-png", "image/gif", "image/bmp", "image/jpeg" };
|
||||
List<string> imgtypelist = new List<string> { "image/jpg", "image/png", "image/x-png", "image/gif", "image/bmp", "image/jpeg" };
|
||||
if (imgtypelist.FindIndex(x => x == data.ContentType) == -1)
|
||||
{
|
||||
msg = "只能上传一张图片格式文件!";
|
||||
|
||||
Reference in New Issue
Block a user