feat: 初次启动
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package operationRecord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
)
|
||||
|
||||
type DeleteOperationRecordLogic struct {
|
||||
@@ -21,8 +19,6 @@ func NewDeleteOperationRecordLogic(ctx context.Context, svcCtx *svc.ServiceConte
|
||||
}
|
||||
|
||||
func (l *DeleteOperationRecordLogic) DeleteOperationRecord(req *types.IdsReq) error {
|
||||
if err := l.svcCtx.DB.Where("id IN ?", req.Ids).Delete(&sysModel.SundynixOperationRecord{}).Error; err != nil {
|
||||
return fmt.Errorf("删除操作日志失败")
|
||||
}
|
||||
return nil
|
||||
_, err := l.svcCtx.SystemRpc.DeleteOperationRecord(l.ctx, &system.IdsReq{Ids: req.Ids})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
// Code scaffolded by goctl. Safe to edit.
|
||||
package operationRecord
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/system/api/internal/svc"
|
||||
"sundynix-micro-go/app/system/api/internal/types"
|
||||
sysModel "sundynix-micro-go/app/system/model"
|
||||
"sundynix-micro-go/app/system/rpc/system"
|
||||
)
|
||||
|
||||
type GetOperationRecordListLogic struct {
|
||||
@@ -20,29 +18,13 @@ func NewGetOperationRecordListLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
return &GetOperationRecordListLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||||
}
|
||||
|
||||
func (l *GetOperationRecordListLogic) GetOperationRecordList(req *types.OperationRecordListReq) (resp interface{}, err error) {
|
||||
var records []sysModel.SundynixOperationRecord
|
||||
var total int64
|
||||
db := l.svcCtx.DB.Model(&sysModel.SundynixOperationRecord{})
|
||||
if req.Method != "" {
|
||||
db = db.Where("method = ?", req.Method)
|
||||
func (l *GetOperationRecordListLogic) GetOperationRecordList(req *types.OperationRecordListReq) (interface{}, error) {
|
||||
resp, err := l.svcCtx.SystemRpc.GetOperationRecordList(l.ctx, &system.OperationRecordListReq{
|
||||
Current: int32(req.Current), PageSize: int32(req.PageSize),
|
||||
Method: req.Method, Path: req.Path, Status: int32(req.Status),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if req.Path != "" {
|
||||
db = db.Where("path LIKE ?", "%"+req.Path+"%")
|
||||
}
|
||||
if req.Status > 0 {
|
||||
db = db.Where("status = ?", req.Status)
|
||||
}
|
||||
db.Count(&total)
|
||||
current, pageSize := req.Current, req.PageSize
|
||||
if current <= 0 {
|
||||
current = 1
|
||||
}
|
||||
if pageSize <= 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
if err := db.Offset((current - 1) * pageSize).Limit(pageSize).Order("created_at DESC").Find(&records).Error; err != nil {
|
||||
return nil, fmt.Errorf("查询操作日志失败")
|
||||
}
|
||||
return map[string]interface{}{"list": records, "total": total, "current": current, "size": pageSize}, nil
|
||||
return map[string]interface{}{"list": resp.List, "total": resp.Total}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user