You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
704 B
Go
36 lines
704 B
Go
package captcha
|
|
|
|
import (
|
|
"context"
|
|
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
|
|
"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
|
|
|
|
"net/http"
|
|
)
|
|
|
|
type GetCaptchaLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
r *http.Request
|
|
}
|
|
|
|
func NewGetCaptchaLogic(r *http.Request, ctx context.Context, svcCtx *svc.ServiceContext) *GetCaptchaLogic {
|
|
return &GetCaptchaLogic{
|
|
r: r,
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *GetCaptchaLogic) GetCaptcha() (resp *types.CaptchaInfo, err error) {
|
|
id, b64s, err := l.svcCtx.Captcha.Generate()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp = &types.CaptchaInfo{
|
|
CaptchaId: id,
|
|
Base64: b64s,
|
|
}
|
|
return
|
|
}
|