2023-07-31 18:41:23 +08:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2022-03-22 11:34:23 +08:00
|
|
|
|
using ZR.Admin.WebApi.Extensions;
|
2021-08-23 16:57:25 +08:00
|
|
|
|
using ZR.Admin.WebApi.Filters;
|
2021-09-16 19:07:49 +08:00
|
|
|
|
using ZR.Model.System.Dto;
|
2021-09-16 19:35:17 +08:00
|
|
|
|
using ZR.Service.System.IService;
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
|
|
|
|
|
namespace ZR.Admin.WebApi.Controllers.monitor
|
|
|
|
|
|
{
|
2022-05-13 22:13:44 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 操作日志记录
|
|
|
|
|
|
/// </summary>
|
2021-08-23 16:57:25 +08:00
|
|
|
|
[Verify]
|
|
|
|
|
|
[Route("/monitor/operlog")]
|
|
|
|
|
|
public class SysOperlogController : BaseController
|
|
|
|
|
|
{
|
|
|
|
|
|
private ISysOperLogService sysOperLogService;
|
2021-11-21 15:48:24 +08:00
|
|
|
|
private IWebHostEnvironment WebHostEnvironment;
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
2021-11-21 15:48:24 +08:00
|
|
|
|
public SysOperlogController(ISysOperLogService sysOperLogService, IWebHostEnvironment hostEnvironment)
|
2021-08-23 16:57:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.sysOperLogService = sysOperLogService;
|
2021-11-21 15:48:24 +08:00
|
|
|
|
WebHostEnvironment = hostEnvironment;
|
2021-08-23 16:57:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 查询操作日志
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sysOperLog"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("list")]
|
2023-05-21 11:08:55 +08:00
|
|
|
|
public IActionResult OperList([FromQuery] SysOperLogQueryDto sysOperLog)
|
2021-08-23 16:57:25 +08:00
|
|
|
|
{
|
2022-12-14 18:45:30 +08:00
|
|
|
|
sysOperLog.OperName = !HttpContextExtension.IsAdmin(HttpContext) ? HttpContextExtension.GetName(HttpContext) : sysOperLog.OperName;
|
2023-05-21 11:08:55 +08:00
|
|
|
|
var list = sysOperLogService.SelectOperLogList(sysOperLog);
|
2021-08-23 16:57:25 +08:00
|
|
|
|
|
2023-03-18 20:45:51 +08:00
|
|
|
|
return SUCCESS(list);
|
2021-08-23 16:57:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除操作日志
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="operIds"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[Log(Title = "操作日志", BusinessType = BusinessType.DELETE)]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "monitor:operlog:delete")]
|
|
|
|
|
|
[HttpDelete("{operIds}")]
|
|
|
|
|
|
public IActionResult Remove(string operIds)
|
|
|
|
|
|
{
|
2022-03-22 11:34:23 +08:00
|
|
|
|
if (!HttpContextExtension.IsAdmin(HttpContext))
|
|
|
|
|
|
{
|
|
|
|
|
|
return ToResponse(ApiResult.Error("操作失败"));
|
|
|
|
|
|
}
|
2021-08-23 16:57:25 +08:00
|
|
|
|
long[] operIdss = Tools.SpitLongArrary(operIds);
|
|
|
|
|
|
return SUCCESS(sysOperLogService.DeleteOperLogByIds(operIdss));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 清空操作日志
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[Log(Title = "清空操作日志", BusinessType = BusinessType.CLEAN)]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "monitor:operlog:delete")]
|
|
|
|
|
|
[HttpDelete("clean")]
|
2023-06-02 18:33:07 +08:00
|
|
|
|
public IActionResult ClearOperLog()
|
2021-08-23 16:57:25 +08:00
|
|
|
|
{
|
2022-03-22 11:34:23 +08:00
|
|
|
|
if (!HttpContextExtension.IsAdmin(HttpContext))
|
|
|
|
|
|
{
|
2023-06-02 18:33:07 +08:00
|
|
|
|
return ToResponse(Infrastructure.ResultCode.CUSTOM_ERROR,"操作失败");
|
2022-03-22 11:34:23 +08:00
|
|
|
|
}
|
2021-08-23 16:57:25 +08:00
|
|
|
|
sysOperLogService.CleanOperLog();
|
|
|
|
|
|
|
2023-06-02 18:33:07 +08:00
|
|
|
|
return SUCCESS(1);
|
2021-08-23 16:57:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-21 15:48:24 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导出操作日志
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[Log(Title = "操作日志", BusinessType = BusinessType.EXPORT)]
|
|
|
|
|
|
[ActionPermissionFilter(Permission = "monitor:operlog:export")]
|
|
|
|
|
|
[HttpGet("export")]
|
2023-05-21 11:08:55 +08:00
|
|
|
|
public IActionResult Export([FromQuery] SysOperLogQueryDto sysOperLog)
|
2021-11-21 15:48:24 +08:00
|
|
|
|
{
|
2023-05-21 11:08:55 +08:00
|
|
|
|
sysOperLog.PageSize = 100000;
|
|
|
|
|
|
var list = sysOperLogService.SelectOperLogList(sysOperLog);
|
2022-12-14 18:45:30 +08:00
|
|
|
|
var result = ExportExcelMini(list.Result, "操作日志", "操作日志");
|
|
|
|
|
|
return ExportExcel(result.Item2, result.Item1);
|
2021-11-21 15:48:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-23 16:57:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|