Merge remote-tracking branch 'origin/master'

This commit is contained in:
LiuY 2022-04-19 17:50:58 +08:00
commit 95d1b77a3c
4 changed files with 141 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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<String, Object> 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);
}
}