package system import ( "sundynix-go/global" "sundynix-go/model/commom/request" "sundynix-go/model/commom/response" "sundynix-go/model/system" systemReq "sundynix-go/model/system/request" "github.com/gin-gonic/gin" "go.uber.org/zap" ) type OperationRecordApi struct { } func (s *OperationRecordApi) CreateOperationRecord(c *gin.Context) { var sysOperationRecord system.SysOperationRecord err := c.ShouldBindJSON(&sysOperationRecord) if err != nil { response.FailWithMsg(err.Error(), c) return } err = operationRecordService.CreateOperationRecord(sysOperationRecord) if err != nil { global.Logger.Error("创建操作记录失败!", zap.Error(err)) response.FailWithMsg(err.Error(), c) return } response.OkWithMsg("创建操作记录成功!", c) } func (s *OperationRecordApi) GetRecordList(c *gin.Context) { var pageInfo systemReq.GetOperationRecordList err := c.ShouldBindJSON(&pageInfo) if err != nil { response.FailWithMsg(err.Error(), c) return } list, total, err := operationRecordService.GetRecordList(pageInfo) if err != nil { global.Logger.Error("获取操作记录列表失败!", zap.Error(err)) response.FailWithMsg(err.Error(), c) return } response.OkWithData(response.PageResult{ List: list, Total: total, Page: pageInfo.Current, PageSize: pageInfo.PageSize, }, c) } func (s *OperationRecordApi) GetRecordById(c *gin.Context) { id := c.Query("id") record, err := operationRecordService.GetRecordById(id) if err != nil { global.Logger.Error("获取操作记录详情失败!", zap.Error(err)) response.FailWithMsg(err.Error(), c) return } response.OkWithData(record, c) } func (s *OperationRecordApi) DeleteRecordsByIds(c *gin.Context) { var ids request.IdsReq err := c.ShouldBindJSON(&ids) if err != nil { response.FailWithMsg(err.Error(), c) return } err = operationRecordService.DeleteRecordsByIds(ids) if err != nil { global.Logger.Error("删除操作记录失败!", zap.Error(err)) response.FailWithMsg(err.Error(), c) return } response.OkWithMsg("删除操作记录成功!", c) }