Commit 170cf423 by 穆龙飞

modify:修改邮件发送逻辑

parent 67841586
...@@ -100,6 +100,12 @@ ...@@ -100,6 +100,12 @@
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.netease.yanxuan</groupId>
<artifactId>yanxuan-qc-service-client</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<!-- spring --> <!-- spring -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -229,6 +235,11 @@ ...@@ -229,6 +235,11 @@
<version>${org.aspectj.version}</version> <version>${org.aspectj.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.netease.yanxuan</groupId>
<artifactId>yanxuan-qc-service-client</artifactId>
</dependency>
<!-- yanxuan --> <!-- yanxuan -->
<!--默认引入apollo配置--> <!--默认引入apollo配置-->
<dependency> <dependency>
......
...@@ -13,7 +13,7 @@ import tk.mybatis.spring.annotation.MapperScan; ...@@ -13,7 +13,7 @@ import tk.mybatis.spring.annotation.MapperScan;
/** /**
* 项目启动类 * 项目启动类
*/ */
@ComponentScan(basePackages = {"com.netease.mail.yanxuan.change", "com.netease.yanxuan.user"}) @ComponentScan(basePackages = {"com.netease.mail.yanxuan.change", "com.netease.yanxuan.user", "com.netease.mail.yanxuan.qc"})
@MapperScan("com.netease.mail.yanxuan.change.dal.mapper") @MapperScan("com.netease.mail.yanxuan.change.dal.mapper")
@EnableApolloConfig @EnableApolloConfig
@EnableMissaClients(basePackages = "com.netease.mail.yanxuan.change") @EnableMissaClients(basePackages = "com.netease.mail.yanxuan.change")
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.netease.mail.yanxuan.change.integration.email.service.UasClientService; import com.netease.mail.yanxuan.change.integration.email.service.UasClientService;
import com.netease.mail.yanxuan.change.integration.flow.email.EmailRpcService; import com.netease.mail.yanxuan.change.integration.flow.email.EmailRpcService;
import com.netease.mail.yanxuan.qc.service.client.remote.UasClient;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -12,8 +13,6 @@ import org.springframework.stereotype.Service; ...@@ -12,8 +13,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.io.File; import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -31,6 +30,9 @@ public class UasClientServiceImpl implements UasClientService { ...@@ -31,6 +30,9 @@ public class UasClientServiceImpl implements UasClientService {
@Autowired @Autowired
private EmailRpcService service; private EmailRpcService service;
@Autowired
private UasClient uasClient;
@Override @Override
public void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList, List<File> fileList) { public void sendEmail(String subject, String content, Collection<String> toList, Collection<String> ccList, List<File> fileList) {
if (!CollectionUtils.isEmpty(toList)) { if (!CollectionUtils.isEmpty(toList)) {
...@@ -39,21 +41,8 @@ public class UasClientServiceImpl implements UasClientService { ...@@ -39,21 +41,8 @@ public class UasClientServiceImpl implements UasClientService {
params.put("cc", StringUtils.join(ccList, ",")); params.put("cc", StringUtils.join(ccList, ","));
} }
logger.info(JSONObject.toJSONString("邮箱接口入参 subject={},content={},toList={},ccList={}"), subject, content, StringUtils.join(toList, ","), params.get("cc")); logger.info(JSONObject.toJSONString("邮箱接口入参 subject={},content={},toList={},ccList={}"), subject, content, StringUtils.join(toList, ","), params.get("cc"));
String appendStr = null; //String res = service.sendEmail(subject,content,StringUtils.join(toList, ","),params.get("cc"));
try { uasClient.sendEmail(subject, content, toList, ccList, null);
appendStr = "subject=" + URLEncoder.encode(subject, "UTF-8")
+ "&to=" + URLEncoder.encode(StringUtils.join(toList, ","), "UTF-8")
+ "&cc=" + URLEncoder.encode(params.get("cc"), "UTF-8")
+ "&content=" + URLEncoder.encode(content, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String res = service.sendEmail(appendStr);
this.logger.info("[op:sendEmail] res={} ", res);
JSONObject jsonObject = JSON.parseObject(res);
if (jsonObject.getInteger("code") != 200) {
this.logger.error("SendEmail", null, "send email failed, subject={},toList={},ccList={}", new Object[]{subject, JSON.toJSONString(toList), JSON.toJSONString(ccList)});
}
} }
} }
......
...@@ -3,7 +3,6 @@ package com.netease.mail.yanxuan.change.integration.flow.email; ...@@ -3,7 +3,6 @@ package com.netease.mail.yanxuan.change.integration.flow.email;
import com.netease.yanxuan.missa.client.annotation.MissaClient; import com.netease.yanxuan.missa.client.annotation.MissaClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.Map; import java.util.Map;
...@@ -20,6 +19,9 @@ public interface EmailRpcService { ...@@ -20,6 +19,9 @@ public interface EmailRpcService {
@PostMapping("/push/email/qc") @PostMapping("/push/email/qc")
String sendEmail(@RequestBody String str); String sendEmail(@RequestParam(name = "subject")String subject,
@RequestParam(name = "content")String content,
@RequestParam(name = "to") String to,
@RequestParam(name = "cc",required = false)String cc);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment