package com.storlead.sms.api;

import cn.hutool.core.util.StrUtil;
import com.storlead.framework.common.result.Result;
import com.storlead.sms.spi.SmsCaptchaScene;
import com.storlead.sms.spi.SmsCaptchaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 短信发送 HTTP 接口
 */
@Api(tags = "短信: 短信")
@RestController
@RequestMapping("/sys/sms")
public class SmsLogApiController {

    @Resource
    private SmsCaptchaService smsCaptchaService;

    @ApiOperation("发送登录验证码")
    @PostMapping("/sendLoginVerifyCode")
    public Result<?> sendLoginVerifyCode(String mobile) {
        if (StrUtil.isBlank(mobile)) {
            return Result.error("参数错误");
        }
        return Result.result(smsCaptchaService.sendCaptcha(mobile, SmsCaptchaScene.LOGIN));
    }
}
