package controller import ( "context" "strings" "gitee.com/red-future---jilin-g/common/log/model/dto" "gitee.com/red-future---jilin-g/common/log/service" ) type operationLog struct{} // OperationLog 操作日志控制器 var OperationLog = new(operationLog) // GetByID 根据ID获取操作日志 // @Summary 获取操作日志详情 // @Description 根据日志ID获取操作日志的详细信息 func (c *operationLog) GetByID(ctx context.Context, req *dto.GetLogReq) (res *dto.GetLogResp, err error) { logInfo, err := service.OperationLog.GetByID(ctx, req.ID) if err != nil { return } res = &dto.GetLogResp{ OperationLogInfo: *logInfo, } return } // List 查询操作日志列表(通用方法,支持根据不同条件动态查询) // @Summary 查询操作日志列表 // @Description 根据多个条件查询操作日志列表 func (c *operationLog) List(ctx context.Context, req *dto.ListLogsReq) (res *dto.ListLogsResp, err error) { // 处理排序字段 var sortFields []string if req.SortFields != "" { sortFields = strings.Split(req.SortFields, ",") } logs, total, err := service.OperationLog.List(ctx, req, sortFields...) if err != nil { return } res = &dto.ListLogsResp{ Logs: logs, Total: total, } return }