package com.ruoyi.sms.api;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.annotation.Dev;
import com.ruoyi.common.event.SmsSendEvent;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.sms.core.SmsTemplate;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 开发模式下测试api
 */
@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/dev/sms")
@SaIgnore
@ConditionalOnBean(SmsTemplate.class)
public class SmsSendDevApi {

  private final SmsTemplate template;

  @PostMapping("/send")
  @Dev
  public void send(@RequestBody SmsSendEvent event){
    SpringUtils.publishEvent(event);
  }


}
