order address apis
This commit is contained in:
@@ -2,6 +2,12 @@ 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"
|
||||
@@ -24,8 +30,34 @@ func NewWebAddressItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *W
|
||||
}
|
||||
}
|
||||
|
||||
func (l *WebAddressItemsLogic) WebAddressItems(in *order.EmptyRequest) (*order.Response, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
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))},
|
||||
}
|
||||
|
||||
return &order.Response{}, nil
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user