Commit d86f2bdf by chentianzhong

提一个版本

parent 6ee498e4
......@@ -4,6 +4,7 @@ package com.zq.email.controller;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo;
import com.zq.email.service.IEmailContentService;
import com.zq.email.vo.EmailDegreeVo;
import com.zq.email.vo.EmailReqVo;
import com.zq.email.vo.EmailTaskVo;
import io.swagger.annotations.Api;
......@@ -42,4 +43,14 @@ public class EmailContentController {
return ResultVo.success();
}
@ApiOperation("设置邮件紧急程度")
@PostMapping("setDegreeEmail")
public ResultVo setDegreeEmail(@RequestBody EmailDegreeVo vo) {
AssertUtils.notEmpty(vo.getContentId(), "缺少参数: contentId");
AssertUtils.notNull(vo.getDegree(), "缺少参数: degree");
emailContentService.setDegreeEmail(vo);
return ResultVo.success();
}
}
......@@ -161,7 +161,7 @@ public class EmailController {
@PostMapping("afterEmail")
public ResultVo afterEmail(@RequestBody EmailLastAndAfterReqVo vo) {
AssertUtils.notNull(vo.getFolderId(), "缺少参数:folderId");
EmailPerson person = this.emailPersonService.lastAndAfterEmail(vo, 0);
EmailPerson person = this.emailPersonService.lastAndAfterEmail(vo, 1);
AssertUtils.notNull(person, "没有下一封了");
return ResultVo.success(person);
}
......
package com.zq.email.controller;
import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.ResultVo;
import com.zq.email.enums.EmailDegreeEnum;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 前端控制器
......@@ -14,7 +22,12 @@ import org.springframework.web.bind.annotation.RestController;
* @since 2023-03-06
*/
@RestController
@RequestMapping("/email/emailLabel")
public class EmailLabelController {
@RequestMapping("/email/other")
public class EmailOtherController {
@ApiOperation("获取紧急程度")
@PostMapping("degreeList")
public ResultVo degreeList() {
return ResultVo.success(EmailDegreeEnum.toList());
}
}
......@@ -9,6 +9,7 @@ import com.zq.email.service.IEmailPersonService;
import com.zq.email.vo.EmailDetailVo;
import com.zq.email.vo.EmailFolderMoveVo;
import com.zq.email.vo.EmailReadVo;
import com.zq.email.vo.EmailSendVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
......@@ -42,8 +43,15 @@ public class EmailPersonController {
}
@ApiOperation("任务邮件回复详情")
@PostMapping("findTaskEmailByContentId")
public ResultVo findTaskEmailByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailPersonService.findTaskEmailByContentId(vo.getContentId()));
}
@ApiOperation("邮件收件人详情")
@PostMapping("findReceiverByContentId")
@PostMapping("findReceiverByContentId")
public ResultVo findReceiverByContentId(@RequestBody EmailDetailVo vo) {
AssertUtils.notNull(vo.getContentId(), "缺少参数:contentId");
return ResultVo.success(emailPersonService.findReceiverByContentId(vo.getContentId()));
......@@ -81,6 +89,31 @@ public class EmailPersonController {
}
@ApiOperation("单条记录收件记录撤回")
@PostMapping("recallPerson")
public ResultVo recallPerson(@RequestBody EmailSendVo vo) {
this.emailPersonService.recallPerson(vo);
return ResultVo.success();
}
@ApiOperation("邮件撤回(只能撤回收件人未读的邮件)")
@PostMapping("recallEmail")
public ResultVo recallEmail(@RequestParam(value = "contentId")Long contentId) {
this.emailPersonService.recallEmail(contentId);
return ResultVo.success();
}
@ApiOperation("回收站恢复")
@PostMapping("resumeEmail")
public ResultVo resumeEmail(@RequestBody List<Long> personIdList) {
this.emailPersonService.resumeEmail(personIdList);
return ResultVo.success();
}
......
......@@ -53,6 +53,10 @@ public class EmailContent implements Serializable {
private Long replyId;
private String replyContent;
private String userList;
private String deptList;
private Integer isTask;
......
......@@ -55,6 +55,8 @@ public class EmailPerson implements Serializable {
private Long folderId;
private Long oldFolderId;
private Integer isRead;
private Integer isSend;
......
package com.zq.email.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 文件夹
*/
public enum EmailDegreeEnum {
DEGREE_COMMON(0, "一般"),
DEGREE_IMPORTANT(1, "紧急"),
DEGREE_URGENT(2, "重要"),
;
private Integer key;
private String value;
EmailDegreeEnum(Integer key, String value) {
this.key = key;
this.value = value;
}
public static EmailDegreeEnum getEnumByKey(Integer key){
for (EmailDegreeEnum value : EmailDegreeEnum.values()) {
if(value.getKey() == key){
return value;
}
}
return null;
}
/**
* 根据keu获取秘密级别值
* @param key
* @return
*/
public static String getValueByKey(Integer key) {
for (EmailDegreeEnum value : EmailDegreeEnum.values()) {
if (value.getKey().equals(key)) {
return value.getValue();
}
}
return null;
}
public static List<Map<Integer, String>> toList(){
List<Map<Integer, String>> list = new ArrayList<>();
for (EmailDegreeEnum degreeEnum : EmailDegreeEnum.values()) {
Map<Integer, String> map = new HashMap<>();
map.put(degreeEnum.getKey(), degreeEnum.getValue());
list.add(map);
}
return list;
}
public Integer getKey() {
return key;
}
public void setKey(Integer key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
......@@ -3,6 +3,7 @@ package com.zq.email.service;
import com.zq.common.vo.OnlineUserDto;
import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.EmailDegreeVo;
import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailTaskVo;
......@@ -19,4 +20,6 @@ public interface IEmailContentService extends IService<EmailContent> {
EmailContent saveContent(EmailEditVo vo, OnlineUserDto adminContext);
void setTaskEmail(EmailTaskVo vo);
void setDegreeEmail(EmailDegreeVo vo);
}
......@@ -32,6 +32,8 @@ public interface IEmailPersonService extends IService<EmailPerson> {
List<EmailPerson> findReceiverByContentId(Long contentId);
List<EmailPerson> findTaskEmailByContentId(Long contentId);
List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId);
void readAllEmails(Long folderId);
......@@ -48,4 +50,12 @@ public interface IEmailPersonService extends IService<EmailPerson> {
// 0上一封 1下一封
EmailPerson lastAndAfterEmail(EmailLastAndAfterReqVo vo, Integer type);
void recallPerson(EmailSendVo vo);
void recallEmail(Long contentId);
void resumeEmail(List<Long> personIdList);
}
......@@ -10,6 +10,7 @@ import com.zq.email.enums.WhetherEnum;
import com.zq.email.mapper.EmailContentMapper;
import com.zq.email.service.IEmailContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.email.vo.EmailDegreeVo;
import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailTaskVo;
import net.bytebuddy.matcher.CollectionErasureMatcher;
......@@ -73,4 +74,9 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
public void setTaskEmail(EmailTaskVo vo) {
this.lambdaUpdate().in(EmailContent::getId, vo.getContentId()).set(EmailContent::getIsTask, vo.getIsTask()).update();
}
@Override
public void setDegreeEmail(EmailDegreeVo vo) {
this.lambdaUpdate().in(EmailContent::getId, vo.getContentId()).set(EmailContent::getDegree, vo.getDegree()).update();
}
}
......@@ -115,6 +115,7 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
queryWrapper.ge(EmailPerson::getSendTime, DateUtils.getRangeStart(vo.getSearchRange()));
queryWrapper.le(EmailPerson::getSendTime, LocalDateTime.now());
}
queryWrapper.orderByDesc(EmailPerson::getId).orderByAsc(EmailPerson::getIsRead);
page = this.page(page, queryWrapper);
if (page!=null && CollectionUtil.isNotEmpty(page.getRecords())){
for (EmailPerson record : page.getRecords()) {
......@@ -154,11 +155,12 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
@Override
public void moveEmailFolder(EmailFolderMoveVo vo) {
List<EmailPerson> emailPeople = this.listByIds(vo.getPersonIdList());
for (EmailPerson emailPerson : emailPeople) {
List<EmailPerson> personList = this.listByIds(vo.getPersonIdList());
for (EmailPerson emailPerson : personList) {
emailPerson.setOldFolderId(emailPerson.getFolderId());
emailPerson.setFolderId(vo.getFolderId());
}
this.updateBatchById(emailPeople);
this.updateBatchById(personList);
}
@Override
......@@ -170,6 +172,24 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
}
@Override
public List<EmailPerson> findTaskEmailByContentId(Long contentId) {
List<EmailPerson> personList = this.lambdaQuery()
.eq(EmailPerson::getEmailContentId, contentId)
.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE)
.orderByAsc(EmailPerson::getId).list();
for (EmailPerson person : personList) {
List<EmailContent> list = this.emailContentService.lambdaQuery()
.eq(EmailContent::getReplyId, person.getEmailContentId())
.eq(EmailContent::getSendUserId, person.getUserId())
.list();
if (CollectionUtil.isNotEmpty(list)){
person.setEmailContent(list.get(0));
}
}
return personList;
}
@Override
public List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId) {
List<DeptSimpleDto> deptDtoList = new ArrayList<>();
EmailContent content = this.emailContentService.getById(contentId);
......@@ -210,9 +230,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
this.lambdaUpdate()
.eq(EmailPerson::getUserId, adminContext.getUserId())
.eq(EmailPerson::getFolderId, folderId)
//.eq(EmailPerson::getFolderId, EmailFolderEnum.FOLDER_INBOX.getKey())
.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE)
.eq(EmailPerson::getIsRead, WhetherEnum.YES.getKey())
.set(EmailPerson::getFolderId, EmailFolderEnum.FOLDER_OUTBOX.getKey())
.set(EmailPerson::getFolderId, EmailFolderEnum.FOLDER_ALREADY_DELETE.getKey())
.update();
}
......@@ -296,16 +317,17 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
LambdaQueryWrapper<EmailPerson> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EmailPerson::getUserId, adminContext.getUserId())
.eq( EmailPerson::getFolderId, vo.getFolderId())
.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE);
.eq( EmailPerson::getFolderId, vo.getFolderId());
//.eq(EmailPerson::getPersonType, EmailConstant.TYPE_EMAIL_RECEIVE);
if (type.equals(WhetherEnum.YES.getKey())){
queryWrapper.gt(EmailPerson::getId, vo.getCurrentPersonId());
}else if (type.equals(WhetherEnum.NO.getKey())){
queryWrapper.lt(EmailPerson::getId, vo.getCurrentPersonId());
}else if (type.equals(WhetherEnum.NO.getKey())){
queryWrapper.gt(EmailPerson::getId, vo.getCurrentPersonId());
}else{
AssertUtils.isTrue(false, "向上或向下查询参数不对");
}
List<EmailPerson> list = this.list(queryWrapper);
EmailPerson person = this.getOne(queryWrapper, false);
if (person!=null){
EmailContent content = this.emailContentService.getById(person.getEmailContentId());
......@@ -316,6 +338,36 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
return null;
}
@Override
public void recallPerson(EmailSendVo vo){
this.lambdaUpdate()
.in(EmailPerson::getId, vo.getPersonIdList())
.set(EmailPerson::getIsSend, vo.getIsSend())
.update();
}
@Override
public void recallEmail(Long contentId) {
this.lambdaUpdate()
.eq(EmailPerson::getEmailContentId, contentId)
.eq(EmailPerson::getIsRead, WhetherEnum.NO.getKey())
.set(EmailPerson::getIsSend, WhetherEnum.NO.getKey()).update();
}
@Override
public void resumeEmail(List<Long> personIdList) {
List<EmailPerson> personList = new ArrayList<>();
for (Long id : personIdList) {
EmailPerson person = this.getById(id);
if (person!=null && person.getOldFolderId()!=null){
person.setFolderId(person.getOldFolderId());
person.setOldFolderId(null);
personList.add(person);
}
}
this.updateBatchById(personList);
}
private void saveEmailSender(OnlineUserDto adminContext, EmailContent content, EmailEditVo vo) {
EmailPerson sender = EmailPerson.builder()
.emailContentId(content.getId())
......
package com.zq.email.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Api("更改重要程度")
@Data
public class EmailDegreeVo {
@ApiModelProperty("contentId集合")
private List<Long> contentId;
@ApiModelProperty("0:一般 1 重要 2紧急")
private Integer degree;
}
......@@ -14,6 +14,8 @@ public class EmailFolderMoveVo {
private Long folderId;
private Long oldFolderId;
private List<Long> personIdList;
......
......@@ -18,7 +18,7 @@ public class EmailLastAndAfterReqVo {
private Integer isPerson ;
@ApiModelProperty("是否已发送")
private Integer isSend;
@ApiModelProperty("查询范围,默认最近三个月")
@ApiModelProperty("当前对象的personId")
private Long currentPersonId;
}
package com.zq.email.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Api("移动邮件到其他文件夹Vo")
@Data
public class EmailSendVo {
@ApiModelProperty("personId集合")
private List<Long> personIdList;
@ApiModelProperty("0:未读 1:已读")
private Integer isSend;
}
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