first commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package secretlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"tianyuan-api/apps/sentinel/internal/model"
|
||||
"tianyuan-api/apps/sentinel/internal/svc"
|
||||
"tianyuan-api/apps/sentinel/sentinel"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetSecretByUserIdLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetSecretByUserIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSecretByUserIdLogic {
|
||||
return &GetSecretByUserIdLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetSecretByUserIdLogic) GetSecretByUserId(in *sentinel.GetRecordByIdRequest) (*sentinel.Secret, error) {
|
||||
secretModel, err := l.svcCtx.SecretsModel.FindOneByUserId(l.ctx, in.Id)
|
||||
if err != nil {
|
||||
if err == model.ErrNotFound {
|
||||
return nil, errors.New("请先进行企业认证")
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &sentinel.Secret{
|
||||
SecretId: secretModel.SecretId,
|
||||
AesKey: secretModel.AesKey,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user