package com.ningdatech.carapi.irs.controller;

import com.ningdatech.carapi.irs.manage.SmsManage;
import com.ningdatech.carapi.irs.service.SmsService;
import com.ningdatech.carapi.open.model.dto.UserLoginDTO;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname SmsController
 * @Description
 * @Date 2023/3/1 17:06
 * @Author PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/open/api/sms/")
@RequiredArgsConstructor
public class SmsController {

    private final SmsService service;

    private final SmsManage smsManage;

    @ApiOperation(value = "sms send", notes = "sms")
    @GetMapping("/send")
    public String send(@RequestParam String content) {
        String mobile = "15058187290";
        return service.sendMessage(mobile, content);
    }

    @ApiOperation("获取验证码")
    @PostMapping("/get-code")
    public String getCode(@RequestBody UserLoginDTO param) {
        return smsManage.getCode(param);
    }

    @ApiOperation(value = "send sms code", notes = "get sms code")
    @PostMapping("/send-sms-code")
    public String sendSmsCode(@RequestBody UserLoginDTO param) {
        return smsManage.sendSmsCode(param.getMobile(), param.getVerificationCode());
    }

}
