55 lines
1.3 KiB
Go
55 lines
1.3 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"
|
|
|
|
store "lone-services/rpc/store/pb"
|
|
"lone-services/services/store/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type WebInfoLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewWebInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebInfoLogic {
|
|
return &WebInfoLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *WebInfoLogic) WebInfo(in *store.EmptyRequest) (*store.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
var info dao.StoreInfo
|
|
modelObj := model.StoreModel{}.Init()
|
|
w := modelbase.Params{Eq: map[string]string{"id": strconv.FormatInt(adminInfo.BizId, utils.NumberTen)}}
|
|
err := modelObj.GetOne(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
|
|
if info.Id < utils.NumberOne {
|
|
return l.fail(utils.ErrorNotFund)
|
|
}
|
|
mobile, dErr := utils.DecryptPhone(info.UserMobile)
|
|
if dErr == nil {
|
|
info.UserMobile = mobile
|
|
}
|
|
return l.ok(info)
|
|
}
|