feat: sale manager
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
chore "lone-services/rpc/chore/pb"
|
||||
"lone-services/services/chore/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DecryptMobileLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
type DecryptMobileData struct {
|
||||
Mobile string `json:"mobile"`
|
||||
}
|
||||
|
||||
func NewDecryptMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DecryptMobileLogic {
|
||||
return &DecryptMobileLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DecryptMobileLogic) DecryptMobile(in *chore.DecryptMobileReq) (*chore.Response, error) {
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return failResponse(utils.ErrorNoLoginInfo), nil
|
||||
}
|
||||
|
||||
originMobile := in.GetOriginMobile()
|
||||
if originMobile == utils.StringEmpty {
|
||||
return failResponse(utils.ErrorParams), nil
|
||||
}
|
||||
|
||||
mobile, err := utils.DecryptPhone(originMobile)
|
||||
if err != nil {
|
||||
l.Errorf("decrypt mobile: %v", err)
|
||||
return &chore.Response{
|
||||
Code: int32(utils.ErrorDecryptAesError.GetCode()),
|
||||
Msg: utils.ErrorDecryptAesError.GetMsg(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
return okResponse(DecryptMobileData{Mobile: mobile}), nil
|
||||
}
|
||||
Reference in New Issue
Block a user