d597975b42
CI / changes (push) Successful in 38s
CI / ad (push) Successful in 3m1s
CI / admin (push) Successful in 34s
CI / bff (push) Successful in 29s
CI / chore (push) Successful in 34s
CI / equipment (push) Failing after 11s
CI / express (push) Successful in 27s
CI / factory (push) Successful in 32s
CI / payment (push) Successful in 29s
CI / product (push) Successful in 30s
CI / record (push) Successful in 30s
CI / sale (push) Successful in 30s
CI / task (push) Successful in 32s
CI / user (push) Successful in 31s
CI / wecom (push) Successful in 33s
89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/rpc/equipment/pb"
|
|
"lone-services/services/equipment/internal/dao"
|
|
"lone-services/services/equipment/internal/model"
|
|
"lone-services/services/equipment/internal/svc"
|
|
"strconv"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type MaskItemsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewMaskItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MaskItemsLogic {
|
|
return &MaskItemsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *MaskItemsLogic) MaskItems(in *equipment.MaskItemsRequest) (*equipment.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
var info []dao.MaskAddInfo
|
|
w := modelbase.Params{
|
|
Size: int(in.Size),
|
|
Order: "id desc",
|
|
Page: int(in.Page),
|
|
}
|
|
w.Eq = make(map[string]string)
|
|
if in.FacialMaskId != utils.StringEmpty {
|
|
w.Eq["facial_mask_id"] = in.FacialMaskId
|
|
}
|
|
if in.Batch != utils.StringEmpty {
|
|
w.Eq["batch"] = in.Batch
|
|
}
|
|
if in.Model >= utils.NumberZero {
|
|
mm := "MM"
|
|
if in.Model == utils.NumberOne {
|
|
mm = "YT"
|
|
}
|
|
w.Eq["model"] = mm
|
|
}
|
|
if in.IsStore >= utils.NumberZero {
|
|
w.Eq["is_store"] = strconv.Itoa(int(in.IsStore))
|
|
}
|
|
if in.IsOnTrial >= utils.NumberZero {
|
|
w.Eq["is_on_trial"] = strconv.Itoa(int(in.IsOnTrial))
|
|
}
|
|
if in.UseScenario >= utils.NumberZero {
|
|
w.Eq["use_scenario"] = strconv.Itoa(int(in.UseScenario))
|
|
}
|
|
if in.Effect >= utils.NumberZero {
|
|
w.Eq["effect"] = strconv.Itoa(int(in.Effect))
|
|
}
|
|
|
|
if in.IsUse >= utils.NumberZero {
|
|
w.Eq["is_use"] = strconv.Itoa(int(in.IsUse))
|
|
}
|
|
|
|
if in.WorkerGroupId >= utils.NumberZero {
|
|
w.Eq["worker_group_id"] = strconv.Itoa(int(in.WorkerGroupId))
|
|
}
|
|
|
|
if len(in.Time) > utils.NumberOne {
|
|
w.Between = map[string][2]string{"created_at": {
|
|
in.Time[utils.NumberZero], in.Time[utils.NumberOne]}}
|
|
}
|
|
items, err := model.MaskModel{}.Init().Page(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.Fail)
|
|
}
|
|
|
|
return l.ok(items)
|
|
}
|