package validation

import (
	"context"

	"kami/internal/errHandler"

	v1 "kami/api/validation/v1"
	"kami/internal/service"

	"github.com/gogf/gf/v2/errors/gcode"
)

func (c *ControllerV1) GetCaptcha(ctx context.Context, req *v1.GetCaptchaReq) (res *v1.GetCaptchaRes, err error) {
	var idKeyC, base64stringC string
	idKeyC, base64stringC, err = service.Captcha().GetVerifyImgString(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "获取验证码失败")
		return
	}
	res = &v1.GetCaptchaRes{
		Key: idKeyC,
		Img: base64stringC,
	}
	return
}
