feat: 操作日志
This commit is contained in:
@@ -8,12 +8,14 @@ type ApiGroup struct {
|
||||
ClientApi
|
||||
RoleApi
|
||||
MenuApi
|
||||
OperationRecordApi
|
||||
}
|
||||
|
||||
var (
|
||||
jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService
|
||||
userService = service.ServiceGroupApp.SystemServiceGroup.UserService
|
||||
clientService = service.ServiceGroupApp.SystemServiceGroup.ClientService
|
||||
roleService = service.ServiceGroupApp.SystemServiceGroup.RoleService
|
||||
menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService
|
||||
jwtService = service.ServiceGroupApp.SystemServiceGroup.JwtService
|
||||
userService = service.ServiceGroupApp.SystemServiceGroup.UserService
|
||||
clientService = service.ServiceGroupApp.SystemServiceGroup.ClientService
|
||||
roleService = service.ServiceGroupApp.SystemServiceGroup.RoleService
|
||||
menuService = service.ServiceGroupApp.SystemServiceGroup.MenuService
|
||||
operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
|
||||
)
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user