package camel_oil

import (
	"context"

	"github.com/gogf/gf/v2/errors/gcode"
	v1 "kami/api/camel_oil/v1"
	"kami/internal/errHandler"
	"kami/internal/model"
	"kami/internal/service"
)

func (c *ControllerV1) InputVerificationCode(ctx context.Context, req *v1.InputVerificationCodeReq) (res *v1.InputVerificationCodeRes, err error) {
	// 登录验证
	_, err = service.SysAuth().LoginOnlyLogin(ctx)
	if err != nil {
		err = errHandler.WrapError(ctx, gcode.CodeInternalError, err, "登录校验失败")
		return
	}

	// 构建输入结构
	input := &model.CamelOilTokenLoginInput{
		TokenId: req.TokenId,
		Code:    req.Code,
	}

	// 调用业务逻辑
	_, err = service.CamelOil().InputVerificationCode(ctx, input)
	if err != nil {
		return nil, err
	}

	return &v1.InputVerificationCodeRes{
		Message: "验证码验证成功",
	}, nil
}
