39 lines
902 B
Go
39 lines
902 B
Go
package captcha
|
|
|
|
import (
|
|
"context"
|
|
|
|
"tydata-server/app/main/api/internal/svc"
|
|
"tydata-server/app/main/api/internal/types"
|
|
"tydata-server/pkg/captcha"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetEncryptedSceneIdLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewGetEncryptedSceneIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEncryptedSceneIdLogic {
|
|
return &GetEncryptedSceneIdLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetEncryptedSceneIdLogic) GetEncryptedSceneId() (resp *types.GetEncryptedSceneIdResp, err error) {
|
|
captchaCfg := l.svcCtx.Config.Captcha
|
|
|
|
encryptedSceneId, err := captcha.GenerateEncryptedSceneID(captchaCfg.SceneID, captchaCfg.EKey, 3600)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &types.GetEncryptedSceneIdResp{
|
|
EncryptedSceneId: encryptedSceneId,
|
|
}, nil
|
|
}
|