|
@@ -0,0 +1,64 @@
|
|
|
+package com.fdkankan.manage.controller;
|
|
|
+
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.response.ResultData;
|
|
|
+import com.fdkankan.manage.entity.MailTemplate;
|
|
|
+import com.fdkankan.manage.service.IMailTemplateService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/service/manage")
|
|
|
+public class EmailTemplateController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IMailTemplateService mailTemplateService;
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ public ResultData list(){
|
|
|
+ return ResultData.ok(mailTemplateService.list());
|
|
|
+ }
|
|
|
+ @GetMapping("/getInfo")
|
|
|
+ public ResultData getInfo(@RequestParam(required = false) Integer mailTemplateId){
|
|
|
+ if(mailTemplateId == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ return ResultData.ok(mailTemplateService.getById(mailTemplateId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * sendMail 4Dkankan@4dage.com
|
|
|
+ * sendPassword 6996790AAaa
|
|
|
+ * sendHost smtp.exmail.qq.com
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ public ResultData save(@RequestBody MailTemplate mailTemplate){
|
|
|
+ if(StringUtils.isBlank(mailTemplate.getSendMail()) || StringUtils.isBlank(mailTemplate.getSendPassword())
|
|
|
+ || StringUtils.isBlank(mailTemplate.getSubject()) || StringUtils.isBlank(mailTemplate.getMsg())){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ mailTemplate.setSendHost("smtp.exmail.qq.com");
|
|
|
+ mailTemplateService.save(mailTemplate);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ public ResultData update(@RequestBody MailTemplate mailTemplate){
|
|
|
+ if(mailTemplate.getId() == null ){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ mailTemplateService.updateById(mailTemplate);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public ResultData delete(@RequestBody MailTemplate mailTemplate){
|
|
|
+ if(mailTemplate.getId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ mailTemplateService.removeById(mailTemplate.getId());
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+}
|