add apis
CI / changes (push) Successful in 1m35s
CI / ad (push) Successful in 32s
CI / admin (push) Successful in 25s
CI / bff (push) Successful in 22s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 24s
CI / express (push) Successful in 24s
CI / factory (push) Successful in 22s
CI / message (push) Successful in 21s
CI / order (push) Successful in 23s
CI / payment (push) Successful in 23s
CI / percutaneous (push) Successful in 21s
CI / product (push) Successful in 22s
CI / record (push) Successful in 21s
CI / sale (push) Successful in 21s
CI / support (push) Successful in 22s
CI / task (push) Successful in 23s
CI / user (push) Successful in 23s
CI / water (push) Successful in 24s
CI / wecom (push) Successful in 24s
CI / changes (push) Successful in 1m35s
CI / ad (push) Successful in 32s
CI / admin (push) Successful in 25s
CI / bff (push) Successful in 22s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 24s
CI / express (push) Successful in 24s
CI / factory (push) Successful in 22s
CI / message (push) Successful in 21s
CI / order (push) Successful in 23s
CI / payment (push) Successful in 23s
CI / percutaneous (push) Successful in 21s
CI / product (push) Successful in 22s
CI / record (push) Successful in 21s
CI / sale (push) Successful in 21s
CI / support (push) Successful in 22s
CI / task (push) Successful in 23s
CI / user (push) Successful in 23s
CI / water (push) Successful in 24s
CI / wecom (push) Successful in 24s
This commit is contained in:
@@ -83,8 +83,9 @@ type (
|
||||
AuthorizationCancel(ctx context.Context, in *AuthorizationCancelRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
// 更改打开权限开关
|
||||
AuthorizationControl(ctx context.Context, in *AuthorizationControlRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
// 更改打用户端获取授权列表开权限开关
|
||||
// 用户端获取授权列表
|
||||
AuthorizationItems(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
AuthorizationCode(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
InternalBindAdd(ctx context.Context, in *InternalBindAddRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
InternalBindInfo(ctx context.Context, in *InternalBindInfoRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
// 添加用户信息
|
||||
@@ -258,12 +259,17 @@ func (m *defaultEquipment) AuthorizationControl(ctx context.Context, in *Authori
|
||||
return client.AuthorizationControl(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 更改打用户端获取授权列表开权限开关
|
||||
// 用户端获取授权列表
|
||||
func (m *defaultEquipment) AuthorizationItems(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.AuthorizationItems(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultEquipment) AuthorizationCode(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.AuthorizationCode(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultEquipment) InternalBindAdd(ctx context.Context, in *InternalBindAddRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.InternalBindAdd(ctx, in, opts...)
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/redis"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AuthorizationCodeLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewAuthorizationCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthorizationCodeLogic {
|
||||
return &AuthorizationCodeLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AuthorizationCodeLogic) AuthorizationCode(in *equipment.EmptyRequest) (*equipment.Response, error) {
|
||||
adminInfo := utils.GetUserFromCtx(l.ctx)
|
||||
if adminInfo.ID < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNoLoginInfo)
|
||||
}
|
||||
|
||||
key := dao.CodeName + strconv.FormatInt(adminInfo.ID, utils.NumberTen)
|
||||
|
||||
code := utils.RandNumber(utils.NumberSix)
|
||||
out := utils.GetConfigInt("code.out-time")
|
||||
_, err := redis.Client.Set(l.ctx, key, code, time.Duration(out)*time.Second).Result()
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
return l.ok(code)
|
||||
}
|
||||
@@ -177,12 +177,17 @@ func (s *EquipmentServer) AuthorizationControl(ctx context.Context, in *equipmen
|
||||
return l.AuthorizationControl(in)
|
||||
}
|
||||
|
||||
// 更改打用户端获取授权列表开权限开关
|
||||
// 用户端获取授权列表
|
||||
func (s *EquipmentServer) AuthorizationItems(ctx context.Context, in *equipment.EmptyRequest) (*equipment.Response, error) {
|
||||
l := logic.NewAuthorizationItemsLogic(ctx, s.svcCtx)
|
||||
return l.AuthorizationItems(in)
|
||||
}
|
||||
|
||||
func (s *EquipmentServer) AuthorizationCode(ctx context.Context, in *equipment.EmptyRequest) (*equipment.Response, error) {
|
||||
l := logic.NewAuthorizationCodeLogic(ctx, s.svcCtx)
|
||||
return l.AuthorizationCode(in)
|
||||
}
|
||||
|
||||
func (s *EquipmentServer) InternalBindAdd(ctx context.Context, in *equipment.InternalBindAddRequest) (*equipment.Response, error) {
|
||||
l := logic.NewInternalBindAddLogic(ctx, s.svcCtx)
|
||||
return l.InternalBindAdd(in)
|
||||
|
||||
Reference in New Issue
Block a user