feat: device info and bind
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
equipmentpb "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeviceInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeviceInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeviceInfoLogic {
|
||||
return &DeviceInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeviceInfoLogic) DeviceInfo(in *analysis.DeviceInfoReq) (*analysis.Response, error) {
|
||||
loginUser := utils.GetUserFromCtx(l.ctx)
|
||||
if !loginUser.Valid || loginUser.ID < utils.NumberOne {
|
||||
return common.FailResponse(utils.ErrorNoLogin), nil
|
||||
}
|
||||
skinType, ok := common.SkinTypeOf(loginUser.ClientCode)
|
||||
if !ok {
|
||||
return common.FailResponse(utils.ErrorAuthority), nil
|
||||
}
|
||||
if l.svcCtx.EquipmentSvcName == utils.StringEmpty {
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
cli, err := svc.GetRpcClient(l.svcCtx.EquipmentSvcName)
|
||||
if err != nil {
|
||||
l.Errorf("device info get equipment rpc: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
out, err := equipmentpb.NewEquipmentClient(cli.Conn()).InternalBindInfo(l.ctx, &equipmentpb.InternalBindInfoRequest{
|
||||
UserId: loginUser.ID,
|
||||
SkinType: skinType,
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("device info internal: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
if out == nil {
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
return &analysis.Response{
|
||||
Code: out.Code,
|
||||
Msg: out.Msg,
|
||||
Data: out.Data,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user