From d7c1cd4e2647fc168478a4a1398f84a48dca9116 Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Tue, 19 Apr 2022 17:50:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0APP=E5=86=85=E9=83=A8?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/api/mail/MailAppController.java | 40 ++++++++++ .../systemoa/pojo/vos/mail/MailSendVO.java | 18 +++++ .../systemoa/service/mail/IMailService.java | 7 ++ .../service/mail/impl/MailServiceImpl.java | 76 +++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java diff --git a/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java b/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java new file mode 100644 index 0000000..405d7ce --- /dev/null +++ b/src/main/java/cn/com/tenlion/systemoa/controller/app/api/mail/MailAppController.java @@ -0,0 +1,40 @@ +package cn.com.tenlion.systemoa.controller.app.api.mail; + +import cn.com.tenlion.systemoa.pojo.vos.carapply.CarApplyVO; +import cn.com.tenlion.systemoa.pojo.vos.mail.MailSendVO; +import cn.com.tenlion.systemoa.service.mail.IMailService; +import ink.wgink.annotation.CheckRequestBodyAnnotation; +import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.result.ErrorResult; +import ink.wgink.pojo.result.SuccessResult; +import io.swagger.annotations.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @author xwangs + * @create 2022-04-19 17:18 + * @description + */ +@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "内部邮件APP接口") +@RestController +@RequestMapping(ISystemConstant.APP_PREFIX + "/mail") +public class MailAppController extends DefaultBaseController { + + @Autowired + private IMailService mailService; + + @ApiOperation(value = "批量发送内部邮件接口", notes = "批量发送内部邮件接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("save-app-send-mail-branch") + public SuccessResult save(@RequestHeader("token") String token, + @RequestBody MailSendVO vo) { + mailService.appSendMail(token, vo); + return new SuccessResult(); + } + +} diff --git a/src/main/java/cn/com/tenlion/systemoa/pojo/vos/mail/MailSendVO.java b/src/main/java/cn/com/tenlion/systemoa/pojo/vos/mail/MailSendVO.java index 337173a..ea6e395 100644 --- a/src/main/java/cn/com/tenlion/systemoa/pojo/vos/mail/MailSendVO.java +++ b/src/main/java/cn/com/tenlion/systemoa/pojo/vos/mail/MailSendVO.java @@ -1,5 +1,7 @@ package cn.com.tenlion.systemoa.pojo.vos.mail; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.ToString; @@ -10,21 +12,37 @@ import lombok.ToString; */ @Data @ToString +@ApiModel public class MailSendVO { + @ApiModelProperty(name = "mailId", value = "逻辑主键") private String mailId; + @ApiModelProperty(name = "recipientIds", value = "收件人IDs-逗号分割") private String recipientIds; + @ApiModelProperty(name = "recipientNames", value = "收件人名字") private String recipientNames; + @ApiModelProperty(name = "copyForIds", value = "抄送人IDs-逗号分割") private String copyForIds; + @ApiModelProperty(name = "copyForNames", value = "抄送人名字") private String copyForNames; + @ApiModelProperty(name = "secretIds", value = "密送人IDs-逗号分割") private String secretIds; + @ApiModelProperty(name = "secretNames", value = "密送人名字") private String secretNames; + @ApiModelProperty(name = "title", value = "邮件主题") private String title; + @ApiModelProperty(name = "mailFiles", value = "附件IDs") private String mailFiles; + @ApiModelProperty(name = "contentRich", value = "富文本内容") private String contentRich; + @ApiModelProperty(name = "content", value = "纯文本内容") private String content; + @ApiModelProperty(name = "creator", value = "发件人ID") private String creator; + @ApiModelProperty(name = "gmtCreate", value = "发件时间") private String gmtCreate; + @ApiModelProperty(name = "modifier", value = "系统默认字段") private String modifier; + @ApiModelProperty(name = "gmtModified", value = "系统默认字段") private String gmtModified; } diff --git a/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java b/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java index 58c9ed5..e1b626c 100644 --- a/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java +++ b/src/main/java/cn/com/tenlion/systemoa/service/mail/IMailService.java @@ -64,4 +64,11 @@ public interface IMailService { String recipientNames, String title, String content) throws Exception; + + /** + * APP-发送内部邮件接口 + * @param token 用户token + * @param vo 邮件VO + */ + void appSendMail(String token, MailSendVO vo); } diff --git a/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java b/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java index b9f225c..4e2b744 100644 --- a/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java +++ b/src/main/java/cn/com/tenlion/systemoa/service/mail/impl/MailServiceImpl.java @@ -10,7 +10,9 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.common.component.SecurityComponent; +import ink.wgink.exceptions.SaveException; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.app.AppTokenUser; import ink.wgink.pojo.bos.UserInfoBO; import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.result.SuccessResultList; @@ -364,4 +366,78 @@ public class MailServiceImpl extends DefaultBaseService implements IMailService saveParam.put("mailIdLink", uuid); mailDao.saveInboxMail(saveParam); } + + @Override + public void appSendMail(String token, MailSendVO vo) { + if(vo.getRecipientIds() == null || "".equals(vo.getRecipientIds())){ + throw new SaveException("收件人不为空"); + } + AppTokenUser appTokenUser = getAppTokenUser(token); + Map saveParam = new HashMap<>(); + // 发件人 + saveParam.put("creator", appTokenUser.getId()); + saveParam.put("modifier", appTokenUser.getId()); + String createTime = DateUtil.getTime(); + saveParam.put("gmtCreate", createTime); + saveParam.put("gmtModified", createTime); + // 处理收件人 + saveParam.put("recipientIds", vo.getRecipientIds()); + String[] recipientArray = vo.getRecipientIds().split(","); + String recipientNames = ""; + for(String s : recipientArray){ + UserDTO userDTO = userService.get(s); + if(userDTO == null){ + continue; + } + if("".equals(recipientNames)){ + recipientNames += userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; + } else { + recipientNames += "," + userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; + } + } + saveParam.put("recipientNames", recipientNames); + + // 处理抄送人 + saveParam.put("copyForIds", vo.getCopyForIds()); + String[] copyForArray = vo.getCopyForIds().split(","); + String copyForNames = ""; + for(String s : copyForArray){ + UserDTO userDTO = userService.get(s); + if(userDTO == null){ + continue; + } + if("".equals(copyForNames)){ + copyForNames += userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; + } else { + copyForNames += "," + userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; + } + } + saveParam.put("copyForNames", copyForNames); + + // 处理密送 + saveParam.put("secretIds", vo.getSecretIds()); + String[] secretArray = vo.getSecretIds().split(","); + String secretNames = ""; + for(String s : secretArray){ + UserDTO userDTO = userService.get(s); + if(userDTO == null){ + continue; + } + if("".equals(secretNames)){ + secretNames += userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; + } else { + secretNames += "," + userDTO.getUserUsername() + "[" + userDTO.getUserName() + "]"; + } + } + saveParam.put("secretNames", secretNames); + // 邮件内容 + String uuid = UUIDUtil.getUUID(); + saveParam.put("mailId", uuid); + saveParam.put("title", vo.getTitle()); + saveParam.put("contentRich", vo.getContent()); + saveParam.put("content", vo.getContent()); + mailDao.saveSendMail(saveParam); + saveParam.put("mailIdLink", uuid); + mailDao.saveInboxMail(saveParam); + } }