package com.ai.da.controller; import com.ai.da.service.EmailService; import com.alibaba.fastjson.JSONObject; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.thymeleaf.context.Context; import jakarta.annotation.Resource; import java.util.Collections; @Api(tags = "邮件模块") @Slf4j @RestController @RequestMapping("/api/email") public class EmailController { @Resource private EmailService emailService; @GetMapping("/loadSingleTemplate") public void loadSingleEmailTemplate(){ emailService.loadSingleEmailTemplate("templates\\upgrade\\122899_AiDA发版完成通知中文版.html"); } @GetMapping("/loadTemplate") public void loadTemplatesFromResources(){ emailService.loadTemplatesFromResources("templates"); } @GetMapping("/sendEmailTest") public void sendEmailTest(){ Context context = new Context(); context.setVariable("username", "小白"); JSONObject jsonObject = new JSONObject(); jsonObject.put("username", "小白"); emailService.sendEmail(Collections.singletonList("xupei3360@163.com"), jsonObject, "132124_affiliate_accepted_en.html", "测试邮件", null, null ); } }