package com.cyl.sms.controller;

import com.cyl.sms.service.SmsService;
import com.ruoyi.common.config.properties.SmsProperties;
import com.ruoyi.common.core.domain.model.SmsResult;
import com.ruoyi.common.core.sms.AliyunSmsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/no-auth/sms")
public class SmsController {

    @Autowired
    private SmsService smsService;
    @Autowired
    private SmsProperties smsProperties;

    /**
     * 阿里云短信服务
     */
    @GetMapping("/sendAliyun/{phones}")
    public ResponseEntity<SmsResult> sendAliyun(@PathVariable String phones){
        return smsService.sendAliyun(phones);
    }

    @GetMapping("/sendBcshHasOrderSMS/{phones}")
    public ResponseEntity<SmsResult> sendBcshHasOrderSMS(@PathVariable String phones){
        AliyunSmsUtils util = new AliyunSmsUtils(smsProperties);
        return ResponseEntity.ok(util.sendBcshHasOrderSMS(phones));
    }

    @GetMapping("/sendOrderSuccessSMS/{phones}")
    public ResponseEntity<SmsResult> sendOrderSuccessSMS(@PathVariable String phones){
        AliyunSmsUtils util = new AliyunSmsUtils(smsProperties);
        return ResponseEntity.ok(util.sendOrderSuccessSMS(phones, "2024-12-20", "2024-12-25"));
    }

}
