package com.ruoyi.sendSMS.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.sendSMS.service.SendMessageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

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

    @Resource
    SendMessageService sendMessageService;

    @GetMapping("/sendMessage")
    public String sendMessage(@RequestParam(value = "phone") String phone, @RequestParam(value = "str") String str, @RequestParam(value = "SMSsignature") String SMSsignature) {
        return sendMessageService.sendMessage(phone, str, SMSsignature);
    }

    @GetMapping("/sendEmail")
    public AjaxResult sendEmail(@RequestParam(value = "mail") String mail, @RequestParam(value = "title") String title, @RequestParam(value = "count") String count) {
        try {
            MailTools.sendMain(mail, title, count);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return AjaxResult.success("操作成功！");
    }
}
