44 lines
952 B
Go
44 lines
952 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/rpc/percutaneous/pb"
|
|
"lone-services/services/percutaneous/internal/dao"
|
|
"lone-services/services/percutaneous/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetWsCodeLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewGetWsCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWsCodeLogic {
|
|
return &GetWsCodeLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetWsCodeLogic) GetWsCode(in *percutaneous.GetWsCodeRequest) (*percutaneous.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
|
|
Type := "app"
|
|
if in.Type == utils.NumberOne {
|
|
Type = "operation"
|
|
}
|
|
|
|
key := utils.MD5Encrypt(fmt.Sprintf("%d%s%s", adminInfo.ID, dao.WsCode, Type))
|
|
|
|
return l.ok(key)
|
|
}
|