添加邮件发送

This commit is contained in:
yyhouc 2023-05-19 10:16:12 +08:00
parent 3c58250ddf
commit a4804c6324
2 changed files with 33 additions and 1 deletions

View File

@ -164,4 +164,10 @@ public class DisasterInfo implements Serializable {
*/
private Date respondedTime;
/**
* Allocation 是否是分配
*/
@TableField(exist = false)
private String allocation;
}

View File

@ -23,6 +23,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
@ -344,7 +345,7 @@ public class DisasterInfoController {
Boolean flag = disasterInfoService.updateById(disasterInfo);
return R.data(flag);
}
private final EmailService emailService;
@ApiOperationSupport(order = 6)
@ApiOperation(value = "提交", notes = "传入Tool")
@PostMapping("/submit")
@ -355,6 +356,31 @@ public class DisasterInfoController {
one.setStatus(1);
one.setManagerId(disasterInfo.getChiefId());
guestManageDisasterRefService.updateById(one);
//判断是否是分配
String Allocation = disasterInfo.getAllocation();
if(!StringUtil.isEmpty(Allocation)){
GuestInfo user = guestInfoService.getById(disasterInfo.getChiefId());
//发送邮件
Email email = new Email();
email.setSubject("You have a new pending disaster");
String text ="Disaster Keyword:" + disasterInfo.getDisasterKeyword()+"<br>";
text+= "Disaster Time:" + disasterInfo.getDisasterTime()+"<br>";
//disaster_country
text+= "Disaster Country:" + disasterInfo.getDisasterCountry()+"<br>";
//vordm_id
text+= "VORDM ID:" + disasterInfo.getVordmId()+"<br>";
email.setText(text);
String [] to = new String[]{user.getEmail()};
email.setTos(to);
email.setHtmlText(true);
try {
emailService.sendMimeMessage(email);
} catch (Exception e) {
return R.fail("发送失败");
}
}
return R.status(disasterInfoService.saveOrUpdate(disasterInfo));
}