order address apis
This commit is contained in:
@@ -2,9 +2,13 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/rpc/order/pb"
|
||||
"lone-services/services/order/internal/dao"
|
||||
"lone-services/services/order/internal/model"
|
||||
"lone-services/services/order/internal/svc"
|
||||
"strconv"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -25,7 +29,63 @@ func NewAddressItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Addre
|
||||
}
|
||||
|
||||
func (l *AddressItemLogic) AddressItem(in *order.AddressItemsRequest) (*order.Response, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
var info []dao.Address
|
||||
w := modelbase.Params{
|
||||
Page: int(in.Page),
|
||||
Size: int(in.Size),
|
||||
Order: "id desc",
|
||||
}
|
||||
|
||||
return &order.Response{}, nil
|
||||
w.Like = make(map[string]string)
|
||||
w.Eq = make(map[string]string)
|
||||
w.Other = make(map[string]string)
|
||||
if len(in.Name) > utils.NumberZero {
|
||||
w.Like["name LIKE ? "] = "%%" + in.Name + "%%"
|
||||
}
|
||||
//Time string
|
||||
if len(in.Mobile) > utils.NumberZero {
|
||||
phone := utils.GetSearchPhone(in.Mobile)
|
||||
if len(phone) > utils.NumberZero {
|
||||
w.Like["mobile LIKE ? "] = "%%" + phone + "%%"
|
||||
}
|
||||
}
|
||||
if in.DistrictId > utils.NumberZero {
|
||||
w.Other["FIND_IN_SET(?, district_ids)"] = strconv.FormatInt(in.DistrictId, utils.NumberTen)
|
||||
}
|
||||
if len(in.Name) > utils.NumberZero {
|
||||
w.Eq["name"] = in.Name
|
||||
}
|
||||
if in.StoreId > utils.NumberZero {
|
||||
w.Eq["target_id"] = strconv.FormatInt(in.StoreId, utils.NumberTen)
|
||||
w.Eq["type"] = strconv.Itoa(dao.AddressTypeStore)
|
||||
}
|
||||
if in.SaleId > utils.NumberZero {
|
||||
w.Eq["target_id"] = strconv.FormatInt(in.SaleId, utils.NumberTen)
|
||||
w.Eq["type"] = strconv.Itoa(dao.AddressTypeSale)
|
||||
}
|
||||
|
||||
if len(in.Time) > utils.NumberZero {
|
||||
w.Other["create_time > ?"] = in.Time[utils.NumberZero]
|
||||
w.Other["create_time < ?"] = in.Time[utils.NumberOne]
|
||||
}
|
||||
|
||||
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
|
||||
l.Logger.Error(mobile)
|
||||
info[key].Mobile = utils.DecryptPhoneReplace(mobile)
|
||||
l.Logger.Error(utils.DecryptPhoneReplace(mobile))
|
||||
}
|
||||
}
|
||||
return l.ok(info)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user