38 lines
905 B
Go
38 lines
905 B
Go
package captcha
|
|
|
|
import (
|
|
"context"
|
|
|
|
"qnc-server/app/main/api/internal/svc"
|
|
"qnc-server/app/main/api/internal/types"
|
|
"qnc-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() (*types.GetEncryptedSceneIdResp, error) {
|
|
cfg := l.svcCtx.Config.Captcha
|
|
encrypted, err := captcha.GenerateEncryptedSceneID(cfg.SceneID, cfg.EKey, 3600)
|
|
if err != nil {
|
|
l.Errorf("generate encrypted scene id error: %+v", err)
|
|
return nil, err
|
|
}
|
|
return &types.GetEncryptedSceneIdResp{
|
|
EncryptedSceneId: encrypted,
|
|
}, nil
|
|
}
|