Commit fdb908e8 authored by zhouzihao's avatar zhouzihao

dev-发生邮件测试通过

parent 01443501
...@@ -53,6 +53,7 @@ public class CarInfoDecorator extends CaseDecorator { ...@@ -53,6 +53,7 @@ public class CarInfoDecorator extends CaseDecorator {
newRes.setData(carMap); newRes.setData(carMap);
newRes.setSuccess(true); newRes.setSuccess(true);
}else { }else {
newRes.setKey(carInfoUrl);
newRes.setStatus(Signature.matchStatus(response.getStatus())); newRes.setStatus(Signature.matchStatus(response.getStatus()));
newRes.setSuccess(false); newRes.setSuccess(false);
} }
......
...@@ -49,6 +49,7 @@ public class CarListDecorator extends CaseDecorator { ...@@ -49,6 +49,7 @@ public class CarListDecorator extends CaseDecorator {
newRes.setSuccess(true); newRes.setSuccess(true);
} }
}else { }else {
newRes.setKey(carListUrl);
newRes.setStatus(Signature.matchStatus(response.getStatus())); newRes.setStatus(Signature.matchStatus(response.getStatus()));
newRes.setSuccess(false); newRes.setSuccess(false);
} }
......
...@@ -54,6 +54,7 @@ public class CarStatusDecorator extends CaseDecorator{ ...@@ -54,6 +54,7 @@ public class CarStatusDecorator extends CaseDecorator{
newRes.setData(carMap); newRes.setData(carMap);
newRes.setSuccess(true); newRes.setSuccess(true);
}else { }else {
newRes.setKey(carStatusUrl);
newRes.setStatus(Signature.matchStatus(response.getStatus())); newRes.setStatus(Signature.matchStatus(response.getStatus()));
newRes.setSuccess(false); newRes.setSuccess(false);
} }
......
...@@ -18,6 +18,8 @@ public class EmptyCase extends Case { ...@@ -18,6 +18,8 @@ public class EmptyCase extends Case {
this.uid = uid; this.uid = uid;
} }
// FIXME: 更灵活的初始调用
@Override @Override
public Res<Map<String, String>> check() { public Res<Map<String, String>> check() {
Res<Map<String, String>> res = new Res<>(); Res<Map<String, String>> res = new Res<>();
......
...@@ -42,6 +42,7 @@ public class LoginCase extends Case { ...@@ -42,6 +42,7 @@ public class LoginCase extends Case {
res.setSId(sid); res.setSId(sid);
res.setSuccess(true); res.setSuccess(true);
} else { } else {
res.setKey(loginUrl);
res.setSuccess(false); res.setSuccess(false);
res.setStatus(Signature.matchStatus(response.getStatus())); res.setStatus(Signature.matchStatus(response.getStatus()));
} }
......
...@@ -21,4 +21,13 @@ public interface CollectionDealer { ...@@ -21,4 +21,13 @@ public interface CollectionDealer {
* @return * @return
*/ */
String formatData(Map<String, Map<ErrStatus, Long>> data); String formatData(Map<String, Map<ErrStatus, Long>> data);
/**
* 通过名字 错误面板格式化
* @param data
* @param names
* @return
*/
String formatData(Map<String, Map<ErrStatus, Long>> data,Map<String,String> names);
} }
...@@ -2,20 +2,39 @@ package com.vandyo.sentry.core.collectionMachine; ...@@ -2,20 +2,39 @@ package com.vandyo.sentry.core.collectionMachine;
import com.vandyo.sentry.core.dto.ErrStatus; import com.vandyo.sentry.core.dto.ErrStatus;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Objects;
public abstract class DataClearDealer implements CollectionDealer {
public abstract class DataClearDealer implements CollectionDealer{
@Override @Override
public String formatData(Map<String, Map<ErrStatus, Long>> data) { public String formatData(Map<String, Map<ErrStatus, Long>> data) {
return formatData(data, null);
}
@Override
public String formatData(Map<String, Map<ErrStatus, Long>> data, Map<String, String> names) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("接口报错:\n"); builder.append("接口报错:\n");
for(Map.Entry<String,Map<ErrStatus, Long>> entry:data.entrySet()){ for (Map.Entry<String, Map<ErrStatus, Long>> entry : data.entrySet()) {
builder.append(entry.getKey()+" :\n"); builder.append(entry.getKey());
if (Objects.nonNull(names) && names.containsKey(entry.getKey())) {
builder.append(" | " + names.get(entry.getKey()));
}
builder.append(":\n");
Map<ErrStatus, Long> value = entry.getValue(); Map<ErrStatus, Long> value = entry.getValue();
for(Map.Entry<ErrStatus,Long> i:value.entrySet()){ for (Map.Entry<ErrStatus, Long> i : value.entrySet()) {
builder.append("\t"+i.getKey().getDes()+":"+i.getValue()+"次。\n"); builder.append(" " + i.getKey().getDes() + ":" + i.getValue() + "次。\n");
} }
builder.append("\n");
} }
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
builder.append("\n\n 当前时间: " + sdf.format(d));
return builder.toString(); return builder.toString();
} }
} }
package com.vandyo.sentry.core.collectionMachine; package com.vandyo.sentry.core.collectionMachine;
import com.vandyo.sentry.core.config.MapConfig;
import com.vandyo.sentry.core.dto.ErrStatus; import com.vandyo.sentry.core.dto.ErrStatus;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
...@@ -13,14 +14,16 @@ public class EmailDealer extends DataClearDealer { ...@@ -13,14 +14,16 @@ public class EmailDealer extends DataClearDealer {
@Autowired @Autowired
private JavaMailSender javaMailSender; private JavaMailSender javaMailSender;
@Autowired
private MapConfig mapConfig;
@Override @Override
public void deal(Map<String, Map<ErrStatus, Long>> data) { public void deal(Map<String, Map<ErrStatus, Long>> data) {
String content = formatData(data); String content = formatData(data,mapConfig.getDesMap());
SimpleMailMessage message = new SimpleMailMessage(); SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("zhouzihao@vandyo.com"); message.setFrom("zhouzihao@vandyo.com");
message.setTo("1042181618@qq.com"); message.setTo("1042181618@qq.com");
message.setSubject("服务报错"); message.setSubject("[服务报错]");
message.setText(content); message.setText(content);
javaMailSender.send(message); javaMailSender.send(message);
} }
......
...@@ -7,18 +7,24 @@ vandyo: ...@@ -7,18 +7,24 @@ vandyo:
checkmeta: checkmeta:
desMap: desMap:
"[/car/my_car/info]": 车辆信息 "[/car/my_car/info]": 车辆信息
"[/car/car_detect]": 车体检
"[/car/my_car/list]": 车列表
"[/carDynamic/api/status/car/state/get]": 车动态
test: 测试接口 test: 测试接口
timeMap: timeMap:
"[/car/my_car/info]": 6 "[/car/my_car/info]": 6
"[/car/car_detect]": 6
"[/car/my_car/list]": 6
"[/carDynamic/api/status/car/state/get]": 6
test: 2 test: 2
spring: spring:
mail: mail:
host: imap.exmail.qq.com host: smtp.exmail.qq.com
default-encoding: UTF-8 default-encoding: UTF-8
username: zhouzihao username: zhouzihao@vandyo.com
password: zzhcool123 password: ceFMW5jhPn2eZpHn
port: 993 port: 465
properties: properties:
mail: mail:
smtp: smtp:
......
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