package com.ruoyi.sms.controller;


import com.ruoyi.response.ResponseData;
import com.ruoyi.sms.MessageCodeService;
import com.ruoyi.sms.controller.vo.SendMesReq;
import com.ruoyi.vo.RyController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 发送短信
 **/
@Slf4j
@Api(tags = "发送短信验证码")
@RequestMapping(value = "/api/sms")
@RestController
@CrossOrigin
public class AppSmsController extends RyController {


    /**
     * 短信类型
     */
    @Value("${sms.sms_type}")
    private String smsType;


    @Autowired
    private MessageCodeService messageCodeService;


    /**
     * 功能描述:发送短信
     */
    @RequestMapping(value = "/send/msg", method = RequestMethod.POST)
    @ApiOperation(value = "发送短信验证码")
    public ResponseData sendMsg(@RequestBody @Valid SendMesReq req) {
        return messageCodeService.sendMsg(req,getUserVo(),smsType);
    }

}
