package com.ruoyi.sendSMS.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.sendSMS.domain.MessageContent;
import com.ruoyi.sendSMS.service.SendMessageService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/sendMessageController")
public class SendMessageController {

    @Resource
    SendMessageService sendMessageService;

    @PostMapping("/sendMessage")
    public String sendMessage(@RequestBody MessageContent messageContent) {
        return sendMessageService.sendMessage(messageContent.getPhone(), messageContent.getStr(), messageContent.getSMSsignature());
    }

    @PostMapping("/sendEmail")
    public AjaxResult sendEmail(@RequestBody MessageContent messageContent) {
        try {
            MailTools.sendMain(messageContent.getMail(), messageContent.getTitle(), messageContent.getCount());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success("操作成功！");
    }
}
