package logic import ( "context" "lone-services/pkg/modelbase" "lone-services/pkg/utils" "lone-services/services/order/internal/dao" "lone-services/services/order/internal/model" "lone-services/services/order/validator" "strconv" "lone-services/rpc/order/pb" "lone-services/services/order/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type WebAddressItemsLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger BaseLogic } func NewWebAddressItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebAddressItemsLogic { return &WebAddressItemsLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *WebAddressItemsLogic) WebAddressItems(in *order.TypeRequest) (*order.Response, error) { var v validator.WebAddressItemsValidator 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.WebAddressInfo w := modelbase.Params{ Order: "`default` asc, `status` desc", Not: map[string]string{"status": strconv.Itoa(utils.StatusDel)}, Eq: map[string]string{ "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), "type": strconv.Itoa(int(in.Type))}, } err := model.AddressModel{}.Init().Items(w, &info) if err != nil { l.Logger.Error(err) return l.fail(utils.ErrorNotFund) } for key, v := range info { mobile, aErr := utils.DecryptPhone(v.Mobile) if aErr == nil { info[key].Mobile = mobile } } return l.ok(info) }