Commit 5964d0d8 by yangll

开发邮件内容自主化编写接口

1 parent 18a64b91
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>glsx-ne-shield-api</artifactId> <artifactId>ne-shield-notifycenter-api</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
......
...@@ -19,10 +19,13 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -19,10 +19,13 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/**
* 发送邮件调用Api
*/
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping(value = "/api/notify") @RequestMapping(value = "/api/notify")
class NotifyApiController implements NotifyCenterFeignClient { public class NotifyApiController implements NotifyCenterFeignClient {
@Autowired @Autowired
private SmsService smsService; private SmsService smsService;
...@@ -71,4 +74,16 @@ class NotifyApiController implements NotifyCenterFeignClient { ...@@ -71,4 +74,16 @@ class NotifyApiController implements NotifyCenterFeignClient {
return R.ok(); return R.ok();
} }
/**
* 邮件内容自己拼接而成发送邮件
*
* @param messageDTO 邮件接受实体类
* @return R
*/
@Override
@PostMapping(value = "/sendMailOnlyContent")
public R sendMailOnlyContent(@RequestBody MailTemplateMessageDTO messageDTO) {
mailService.sendSimpleMailOnlyContent(messageDTO.getTo(), messageDTO.getTitle(), messageDTO.getContent());
return R.ok();
}
} }
...@@ -79,4 +79,20 @@ public class MailService { ...@@ -79,4 +79,20 @@ public class MailService {
mailUtils.sendAttachmentMail(to, subject, content, filepaths); mailUtils.sendAttachmentMail(to, subject, content, filepaths);
} }
/**
* 发送文本邮件
*
* @param to 收件人
* @param subject 主题
*/
public void sendSimpleMailOnlyContent(String to, String subject, String content) {
mailUtils.sendTextMail(to, subject, content);
MessageLog log = new MessageLog();
log.setSubject(subject);
log.setToUser(to);
log.setContent(content);
log.setType("MAIL");
messageLogMapper.insert(log);
}
} }
...@@ -50,7 +50,7 @@ public class NotifyApplicationTests { ...@@ -50,7 +50,7 @@ public class NotifyApplicationTests {
args.put("arg1", "刘宇峰"); args.put("arg1", "刘宇峰");
args.put("arg2", "B73493098765"); args.put("arg2", "B73493098765");
args.put("arg3", 1234); args.put("arg3", 1234);
//mailService.sendSimpleMail("levphon@vip.qq.com", "notifycenter test", "MAIL_TEMPLATE_ORDER_PAID_NOTIFY_OPERATOR", args.values()); mailService.sendSimpleMail("592761523@qq.com", "notifycenter test", "MAIL_TEMPLATE_ORDER_PAID_NOTIFY_OPERATOR", args.values());
List<Map<String, String>> filepaths = Lists.newArrayList(); List<Map<String, String>> filepaths = Lists.newArrayList();
Map<String, String> girl1 = Maps.newHashMap(); Map<String, String> girl1 = Maps.newHashMap();
...@@ -58,7 +58,7 @@ public class NotifyApplicationTests { ...@@ -58,7 +58,7 @@ public class NotifyApplicationTests {
girl1.put("filepath", "https://pic.netbian.com/uploads/allimg/211115/232008-1636989608f1ca.jpg"); girl1.put("filepath", "https://pic.netbian.com/uploads/allimg/211115/232008-1636989608f1ca.jpg");
filepaths.add(girl1); filepaths.add(girl1);
mailService.sendAttachmentsMail("levphon@vip.qq.com", "notifycenter test" + DateUtils.format(new Date()), "MAIL_TEMPLATE_ORDER_PAID_NOTIFY_OPERATOR", filepaths); mailService.sendAttachmentsMail("592761523@qq.com", "notifycenter test" + DateUtils.format(new Date()), "MAIL_TEMPLATE_ORDER_PAID_NOTIFY_OPERATOR", filepaths);
Thread.sleep(30000); Thread.sleep(30000);
} }
...@@ -92,4 +92,11 @@ public class NotifyApplicationTests { ...@@ -92,4 +92,11 @@ public class NotifyApplicationTests {
// weixinService.push("wxa9b785873a4b0793", model); // weixinService.push("wxa9b785873a4b0793", model);
} }
@Test
public void testMailOnlyContent() throws Exception {
mailService.sendSimpleMailOnlyContent("592761523@qq.com", "notifycenter test" + DateUtils.format(new Date()), "杨林龙测试");
Thread.sleep(30000);
}
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!