71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/rpc/factory/pb"
|
|
"lone-services/services/factory/internal/dao"
|
|
"lone-services/services/factory/internal/model"
|
|
"lone-services/services/factory/internal/svc"
|
|
"lone-services/services/factory/validator"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type LogItemsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewLogItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogItemsLogic {
|
|
return &LogItemsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *LogItemsLogic) LogItems(in *factory.LogItemsRequest) (*factory.Response, error) {
|
|
var v validator.LogItemsValidator
|
|
if fail := l.checkParams(in, &v); fail != nil {
|
|
return fail, nil
|
|
}
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
var info []dao.GroupInfo
|
|
w := modelbase.Params{
|
|
Page: int(in.Page),
|
|
Size: int(in.Size),
|
|
Order: "id desc",
|
|
}
|
|
//TODO
|
|
|
|
w.Like = make(map[string]string)
|
|
w.Other = make(map[string]string)
|
|
w.Eq = make(map[string]string)
|
|
|
|
if in.Type > utils.NumberZero {
|
|
w.Eq["type"] = string(in.Type)
|
|
}
|
|
if in.ObjType > utils.NumberZero {
|
|
w.Eq["obj_type"] = string(in.ObjType)
|
|
}
|
|
if len(in.Time) > utils.NumberZero {
|
|
w.Other["create_time > ?"] = in.Time[utils.NumberZero]
|
|
w.Other["create_time < ?"] = in.Time[utils.NumberOne]
|
|
}
|
|
|
|
items, err := model.LogModel{}.Init().Page(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
|
|
return l.ok(items)
|
|
}
|