66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
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 AddressByStoreLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewAddressByStoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressByStoreLogic {
|
|
return &AddressByStoreLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *AddressByStoreLogic) AddressByStore(in *order.AddressByStoreItemsRequest) (*order.Response, error) {
|
|
var v validator.AddressByStoreItemsValidator
|
|
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.Address
|
|
w := modelbase.Params{
|
|
Order: "id desc",
|
|
Eq: map[string]string{
|
|
"target_id": strconv.FormatInt(in.StoreId, utils.NumberTen),
|
|
"type": strconv.Itoa(dao.AddressTypeStore),
|
|
"status": utils.StringStatusOk,
|
|
},
|
|
}
|
|
|
|
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].AesMobile = v.Mobile
|
|
info[key].Mobile = utils.DecryptPhoneReplace(mobile)
|
|
}
|
|
}
|
|
return l.ok(info)
|
|
}
|