Files
lone-services/services/store/internal/logic/getInfoByIdLogic.go
T
gjs 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
store and chore
2026-09-17 16:16:11 +08:00

73 lines
1.9 KiB
Go

package logic
import (
"context"
"lone-services/pkg/modelbase"
"lone-services/pkg/utils"
"lone-services/services/store/internal/dao"
"lone-services/services/store/internal/model"
"strconv"
"lone-services/rpc/store/pb"
"lone-services/services/store/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
type GetInfoByIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetInfoByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetInfoByIdLogic {
return &GetInfoByIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetInfoByIdLogic) GetInfoById(in *store.IdRequest) (*store.InfoResponse, error) {
var info dao.StoreInfo
modelObj := model.StoreModel{}.Init()
w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(in.Id, utils.NumberTen)}}
err := modelObj.GetOne(w, &info)
if err != nil {
l.Logger.Error(err)
return nil, status.Error(codes.Internal, utils.Fail.Msg)
}
if info.Id < utils.NumberOne {
return nil, status.Error(codes.Internal, utils.ErrorNotFund.Msg)
}
if info.Id > utils.NumberZero {
mobile, dErr := utils.DecryptPhone(info.UserMobile)
if dErr == nil {
return nil, status.Error(codes.Internal, utils.ErrorEncryptAesError.Msg)
}
info.UserMobile = mobile
}
return &store.InfoResponse{
Id: info.Id,
Name: info.Name,
Contact: info.Contact,
UserMobile: info.UserMobile,
IdCard: info.IdCard,
BusinessLicense: info.BusinessLicense,
Images: info.Images,
Content: info.Content,
OpenTime: info.OpenTime,
Address: info.Address,
City: info.City,
County: info.County,
DistrictIds: info.District,
Area: info.Area,
BankInfo: info.BankInfo,
}, nil
}