package com.zanxiang.game.module.sdk.controller;

import com.zanxiang.game.module.sdk.annotation.ValidLogin;
import com.zanxiang.game.module.sdk.pojo.param.BindPhoneParam;
import com.zanxiang.game.module.sdk.pojo.param.SmsCheckParam;
import com.zanxiang.game.module.sdk.pojo.param.SmsSendParam;
import com.zanxiang.game.module.sdk.pojo.param.UserData;
import com.zanxiang.game.module.sdk.service.ISmsService;
import com.zanxiang.module.util.pojo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author : lingfeng
 * @time : 2022-06-16
 * @description : 短信服务接口
 */
@RestController
@RequestMapping(value = "/api/sms")
public class SmsController {

    @Autowired
    private ISmsService smsService;

    @PostMapping("/send/msg")
    public ResultVO<Boolean> smsSend(@Validated @RequestBody SmsSendParam smsSendParam, UserData userData) {
        return smsService.smsSend(smsSendParam, userData);
    }

    @PostMapping("/check/msg")
    public ResultVO<Boolean> smsCheck(@Validated @RequestBody SmsCheckParam smsCheckParam) {
        return smsService.smsCheck(smsCheckParam);
    }

    @GetMapping("/bind/phone")
    public ResultVO<Map<String, Object>> getBindPhone(@ValidLogin UserData userData) {
        return ResultVO.ok(smsService.getBindPhone(userData));
    }

    @GetMapping("/bind/phone/send")
    public ResultVO<Map<String, Object>> bindPhoneSend(@RequestParam String phone, @ValidLogin UserData userData) {
        return ResultVO.ok(smsService.bindPhoneSend(phone, userData));
    }

    @PostMapping("/bind/phone/check")
    public ResultVO<Map<String, Object>> bindPhoneCheck(@Validated @RequestBody BindPhoneParam param, @ValidLogin UserData userData) {
        return ResultVO.ok(smsService.bindPhoneCheck(param, userData));
    }
}
