first commit
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
using JSMachine.WMS.App.Dto;
|
||||
using JSMachine.WMS.Application.Dto;
|
||||
using JSMachine.WMS.Application.IService;
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Infrastructure.Helper;
|
||||
using JSMachine.WMS.RPC.ErpRPC.Dto.Out;
|
||||
using JSMachine.WMS.WebHost.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JSMachine.WMS.WebHost.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class OperationLogController : ControllerBase
|
||||
{
|
||||
private readonly IOperationLogService _operationLogService;
|
||||
|
||||
public OperationLogController(IOperationLogService operationLogService)
|
||||
{
|
||||
_operationLogService = operationLogService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有操作日志
|
||||
/// </summary>
|
||||
/// <returns>操作日志列表</returns>
|
||||
[HttpGet]
|
||||
public async Task<ApiResult<List<OperationLogDto>>> GetAll()
|
||||
{
|
||||
var logs = await _operationLogService.GetListByExpression(
|
||||
p => true,
|
||||
nameof(OperationLogDto.CreationTime),
|
||||
OrderByType.Desc);
|
||||
|
||||
return new ApiResult<List<OperationLogDto>>
|
||||
{
|
||||
ResultCode = "200",
|
||||
Data = logs
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取操作日志
|
||||
/// </summary>
|
||||
/// <param name="id">操作日志ID</param>
|
||||
/// <returns>单个操作日志</returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<OperationLogDto>> GetById(Guid id)
|
||||
{
|
||||
var log = await _operationLogService.GetSingalByExpression(p => p.Id == id);
|
||||
|
||||
return new ApiResult<OperationLogDto>
|
||||
{
|
||||
ResultCode = "200",
|
||||
Data = log
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建操作日志
|
||||
/// </summary>
|
||||
/// <param name="logDto">操作日志DTO</param>
|
||||
/// <returns>是否创建成功</returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<bool>> Create(OperationLogDto logDto)
|
||||
{
|
||||
if (logDto == null)
|
||||
return new ApiResult<bool> { ResultCode = "400", Data = false, ErrorMsg = "参数不能为空" };
|
||||
|
||||
bool success = await _operationLogService.Add(logDto);
|
||||
|
||||
return new ApiResult<bool>
|
||||
{
|
||||
ResultCode = success ? "200" : "500",
|
||||
Data = success,
|
||||
ErrorMsg = success ? "创建成功" : "创建失败"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新操作日志
|
||||
/// </summary>
|
||||
/// <param name="logDto">操作日志DTO</param>
|
||||
/// <returns>是否更新成功</returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<bool>> Update(OperationLogDto logDto)
|
||||
{
|
||||
if (logDto == null || logDto.Id == Guid.Empty)
|
||||
return new ApiResult<bool> { ResultCode = "400", Data = false, ErrorMsg = "参数无效" };
|
||||
|
||||
bool success = await _operationLogService.EditSingal(logDto);
|
||||
|
||||
return new ApiResult<bool>
|
||||
{
|
||||
ResultCode = success ? "200" : "500",
|
||||
Data = success,
|
||||
ErrorMsg = success ? "更新成功" : "更新失败"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除操作日志
|
||||
/// </summary>
|
||||
/// <param name="id">操作日志ID</param>
|
||||
/// <returns>是否删除成功</returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<bool>> Delete(Guid id)
|
||||
{
|
||||
bool success = await _operationLogService.DeleteById(id);
|
||||
|
||||
return new ApiResult<bool>
|
||||
{
|
||||
ResultCode = success ? "200" : "500",
|
||||
Data = success,
|
||||
ErrorMsg = success ? "删除成功" : "删除失败"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询操作日志
|
||||
/// </summary>
|
||||
/// <param name="pageQuery">分页查询条件</param>
|
||||
/// <returns>分页结果</returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<PagedResult<OperationLogDto>>> QueryByPage([FromBody]OperationLogQueryParam pageQuery)
|
||||
{
|
||||
var condition = pageQuery.BuildConditional();
|
||||
|
||||
var result = await _operationLogService.QueryByPage(condition);
|
||||
|
||||
return new ApiResult<PagedResult<OperationLogDto>>
|
||||
{
|
||||
ResultCode = "200",
|
||||
Data = result
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user