91 lines
2.5 KiB
Go
91 lines
2.5 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"
|
|
"strconv"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
type GetInfoByIdsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetInfoByIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetInfoByIdsLogic {
|
|
return &GetInfoByIdsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetInfoByIdsLogic) GetInfoByIds(in *store.IdsRequest) (*store.ItemsResponse, error) {
|
|
var info []dao.StoreInfo
|
|
modelObj := model.StoreModel{}.Init()
|
|
var ids []string
|
|
for _, id := range in.Ids {
|
|
ids = append(ids, strconv.FormatInt(id, utils.NumberTen))
|
|
}
|
|
w := modelbase.Params{In: map[string][]string{"id": ids}}
|
|
err := modelObj.Items(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return nil, status.Error(codes.Internal, utils.Fail.Msg)
|
|
}
|
|
|
|
if len(info) < utils.NumberOne {
|
|
return nil, status.Error(codes.Internal, utils.ErrorNotFund.Msg)
|
|
}
|
|
|
|
var items []*store.InfoResponse
|
|
for _, item := range info {
|
|
mobile, _ := utils.DecryptPhone(item.UserMobile)
|
|
|
|
items = append(items, &store.InfoResponse{
|
|
Id: item.Id,
|
|
Name: item.Name,
|
|
UserName: item.UserName,
|
|
Contact: item.Contact,
|
|
UserMobile: mobile,
|
|
IdCard: item.IdCard,
|
|
BusinessLicense: item.BusinessLicense,
|
|
Images: item.Images,
|
|
StoreImages: item.StoreImages,
|
|
Content: item.Content,
|
|
OpenTime: item.OpenTime,
|
|
Address: item.Address,
|
|
Province: item.Province,
|
|
ProvinceName: item.ProvinceName,
|
|
City: item.City,
|
|
CityName: item.CityName,
|
|
County: item.County,
|
|
CountyName: item.CountyName,
|
|
DistrictIds: item.District,
|
|
Area: item.Area,
|
|
BankInfo: item.BankInfo,
|
|
Type: item.Type,
|
|
SaleId: item.SaleId,
|
|
LongitudeWgs84: item.LongitudeWgs84,
|
|
LatitudeWgs84: item.LatitudeWgs84,
|
|
LongitudeGcj02: item.LongitudeGcj02,
|
|
LatitudeGcj02: item.LatitudeGcj02,
|
|
BuyAmount: item.BuyAmount,
|
|
ResidualNumber: item.ResidualNumber,
|
|
Status: item.Status,
|
|
CreateTime: item.CreateTime.String(),
|
|
})
|
|
}
|
|
|
|
return &store.ItemsResponse{Items: items}, nil
|
|
}
|