Files
lone-services/services/store/internal/logic/itemsLogic.go
T
zzw 15a5616308
CI / changes (push) Successful in 1m31s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / aiserver (push) Successful in 0s
CI / analysis (push) Successful in 37s
CI / bff (push) Successful in 18s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 0s
CI / order (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / percutaneous (push) Successful in 0s
CI / product (push) Successful in 0s
CI / record (push) Successful in 1s
CI / sale (push) Successful in 0s
CI / store (push) Successful in 22s
CI / support (push) Successful in 0s
CI / task (push) Successful in 0s
CI / user (push) Successful in 21s
CI / water (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 0s
feat: scan graph
2026-11-04 11:46:54 +08:00

78 lines
1.8 KiB
Go

package logic
import (
"context"
"lone-services/pkg/modelbase"
"lone-services/pkg/utils"
"lone-services/rpc/store/pb"
"lone-services/services/store/internal/dao"
"lone-services/services/store/internal/model"
"lone-services/services/store/internal/svc"
"lone-services/services/store/validator"
"strconv"
"github.com/zeromicro/go-zero/core/logx"
)
type ItemsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
BaseLogic
}
func NewItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemsLogic {
return &ItemsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *ItemsLogic) Items(in *store.ItemsRequest) (*store.Response, error) {
var v validator.StoreItemsValidator
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.StoreInfo
w := modelbase.Params{
Page: int(in.Page),
Size: int(in.Size),
Order: "id desc",
}
w.Like = make(map[string]string)
w.Eq = make(map[string]string)
if len(in.Name) > utils.NumberZero {
w.Like["name LIKE ? "] = "%%" + in.Name + "%%"
}
if in.SaleId > utils.NumberZero {
w.Eq["sale_id"] = strconv.FormatInt(in.SaleId, utils.NumberTen)
}
if in.Status > utils.NumberZero {
w.Eq["status"] = strconv.Itoa(int(in.Status))
}
items, err := model.StoreModel{}.Init().Page(w, &info)
if err != nil {
l.Logger.Error(err)
return l.fail(utils.ErrorNotFund)
}
for i := range info {
item := &info[i]
mobile, dErr := utils.DecryptPhone(item.UserMobile)
item.AesMobile = item.UserMobile
if dErr == nil {
item.UserMobile = utils.DecryptPhoneReplace(mobile)
}
}
items.Items = info
return l.ok(items)
}