2b19937065
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 25s
CI / chore (push) Successful in 24s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / product (push) Successful in 1s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 24s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
75 lines
1.9 KiB
Go
75 lines
1.9 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,
|
|
Contact: item.Contact,
|
|
UserMobile: mobile,
|
|
IdCard: item.IdCard,
|
|
BusinessLicense: item.BusinessLicense,
|
|
Images: item.Images,
|
|
Content: item.Content,
|
|
OpenTime: item.OpenTime,
|
|
Address: item.Address,
|
|
City: item.City,
|
|
County: item.County,
|
|
DistrictIds: item.District,
|
|
Area: item.Area,
|
|
BankInfo: item.BankInfo,
|
|
})
|
|
}
|
|
|
|
return &store.ItemsResponse{Items: items}, nil
|
|
}
|