1cbce2c1a3
CI / changes (push) Successful in 36s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 0s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 26s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 1s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 0s
CI / task (push) Successful in 1s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
67 lines
1.5 KiB
Go
67 lines
1.5 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 GroupItemsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewGroupItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupItemsLogic {
|
|
return &GroupItemsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GroupItemsLogic) GroupItems(in *factory.GroupItemsRequest) (*factory.Response, error) {
|
|
var v validator.GroupItemsValidator
|
|
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",
|
|
}
|
|
|
|
w.Like = make(map[string]string)
|
|
w.Other = make(map[string]string)
|
|
w.Eq = make(map[string]string)
|
|
|
|
if len(in.Name) > utils.NumberZero {
|
|
w.Like["name LIKE ? "] = "%%" + in.Name + "%%"
|
|
}
|
|
|
|
if in.Status > utils.NumberZero {
|
|
w.Eq["status"] = string(in.Status)
|
|
}
|
|
|
|
items, err := model.GroupModel{}.Init().Page(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
|
|
return l.ok(items)
|
|
}
|