Commit aeb05cca by chentianzhong

搜索邮件

parent 4ced4205
......@@ -16,7 +16,7 @@ public enum EmailFolderEnum {
FOLDER_OUTBOX(3, "草稿箱"),
FOLDER_ALREADY_SEND(4, "已发送"),
FOLDER_ALREADY_DELETE(5, "回收站"),
FOLDER_OTHER(6, "邮箱(文件夹)"),
FOLDER_OTHER(6, "我的文件夹"),
FOLDER_MANAGE(7, "邮件管理"),
;
......
......@@ -3,6 +3,7 @@ package com.zq.email.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -698,9 +699,9 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
case FOLDER_ALREADY_SEND: //已发送
if (vo.getSendUserId()!=null){
vo.setFolderId(null);
vo.setUserId(vo.getSendUserId());
vo.setUserId(adminContext.getUserId());
vo.setSendUserId(adminContext.getUserId());
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
//vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
}else{
......@@ -751,23 +752,26 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
break;
case FOLDER_ALREADY_SEND: //已发送
if (vo.getSendUserId() != null) {
if (vo.getReceiveUserId() != null) {
vo.setFolderId(null);
vo.setUserId(vo.getSendUserId());
vo.setUserId(adminContext.getUserId());
vo.setSendUserId(adminContext.getUserId());
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
//vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
} else {
vo.setUserId(adminContext.getUserId());
vo.setSendUserId(adminContext.getUserId());
// vo.setUserId(vo.getReceiveUserId());
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
//vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
}
break;
case FOLDER_ALREADY_DELETE: //回收站
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsSend(WhetherEnum.YES.getKey());
vo.setUserId(adminContext.getUserId());
//vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
//vo.setIsSend(WhetherEnum.YES.getKey());
break;
default: //其他文件夹
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
......@@ -775,17 +779,16 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
break;
}
}
vo.setUserId(adminContext.getUserId());
Page<EmailPerson> page = new Page<>(vo.getPage(), vo.getSize());
page = this.baseMapper.selectSearchPage(page, vo);
if (page!=null && page.getRecords()!=null){
for (EmailPerson person : page.getRecords()) {
EmailContent content = this.emailContentService.getById(person.getEmailContentId());
if(vo.getFolderId().equals(EmailFolderEnum.FOLDER_ALREADY_SEND.getKey())){
//if(vo.getFolderId().equals(EmailFolderEnum.FOLDER_ALREADY_SEND.getKey())){
person.setEmailAttachList(this.emailAttachService.findByContentId(content.getId()));
person.setReceiverList(this.findReceiverByContentId(content.getId(), null));
}
//}
//发送人头像
if (vo.getIsSenderPhoto()){
ResultVo<UserDto> senderVo = adminFeignClient.findById(content.getSendUserId());
......@@ -793,7 +796,12 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
UserDto data = senderVo.getData();
UserDto userDto = new UserDto();
if (profile.contains("wan")) {
content.setSendUserPhoto(StrUtil.isNotBlank(data.getPhoto())?data.getPhoto().replace("http://147.1.3.87", "http://172.28.1.159:82"):data.getPhoto());
// content.setSendUserPhoto(StrUtil.isNotBlank(data.getPhoto())?data.getPhoto()
// .replace("http://147.1.3.87", "http://172.28.1.159:82"):data.getPhoto());
String replace = data.getPhoto()
.replace("http://147.1.3.87", "http://172.28.1.159:82")
.replace("http://147.2.3.3", "http://172.28.1.71");
content.setSendUserPhoto(replace);
//userDto.setPhoto();
}else{
content.setSendUserPhoto(data.getPhoto());
......@@ -962,6 +970,9 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
.eq(sendTime!=null, EmailPerson::getSendTime, sendTime)
.eq(EmailPerson::getFolderId,folderId);
//switch遇到null
if(ObjectUtil.isNotEmpty(EmailFolderEnum.getEnumByKey(folderId.intValue()))) {
switch (EmailFolderEnum.getEnumByKey(folderId.intValue())) {
case FOLDER_INBOX: //收件箱
queryWrapper
......@@ -1001,6 +1012,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
break;
}
}else{
queryWrapper
.eq(EmailPerson::getUserId, adminContext.getUserId());
}
EmailPerson emailPerson = this.getOne(queryWrapper, false);
AssertUtils.notNull(emailPerson, "邮件人员信息不匹配");
......@@ -1021,6 +1036,9 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
.eq(sendTime!=null, EmailPerson::getSendTime, sendTime)
.eq(EmailPerson::getFolderId,folderId);
//switch遇到null
if(ObjectUtil.isNotEmpty(EmailFolderEnum.getEnumByKey(folderId.intValue()))) {
switch (EmailFolderEnum.getEnumByKey(folderId.intValue())) {
case FOLDER_INBOX: //收件箱
queryWrapper
......@@ -1060,6 +1078,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
break;
}
}else{
queryWrapper
.eq(EmailPerson::getUserId, adminContext.getUserId());
}
EmailPerson emailPerson = this.getOne(queryWrapper, false);
AssertUtils.notNull(emailPerson, "获取收件人信息失败");
......
......@@ -50,8 +50,6 @@ public class EmailSearchReqVo extends PageReqVo {
private Integer isPerson ;
@ApiModelProperty("当前人员id :前端不用传")
private Long userId;
@ApiModelProperty("是否获取人员头像")
private Boolean isSenderPhoto = false;
......
......@@ -2,4 +2,5 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailFolderMapper">
</mapper>
......@@ -4,7 +4,7 @@
<select id="selectSearchTotal" resultType="integer" parameterType="com.zq.email.vo.EmailSearchReqVo">
SELECT
COUNT(1)
COUNT(EP."ID")
FROM
"EMAIL_PERSON" EP
<where>
......@@ -36,19 +36,18 @@
AND EP."SEND_TIME" &lt;= #{s.endTime}
</if>
<!-- 已发送,收件人 -->
<!-- <if test="s.receiveUserId != null">-->
<!-- AND EP."ID" IN(-->
<!-- SELECT-->
<!-- EP2."ID"-->
<!-- FROM-->
<!-- "EMAIL_PERSON" EP2-->
<!-- WHERE-->
<!-- EP2."PERSON_TYPE" = 2-->
<!-- AND EP2."IS_SEND" = 1-->
<!-- AND EP2."USER_ID" = #{s.receiveUserId}-->
<!-- )-->
<!-- </if>-->
<if test="s.receiveUserId != null">
AND EP."EMAIL_CONTENT_ID" IN(
SELECT
EP2."EMAIL_CONTENT_ID"
FROM
"EMAIL_PERSON" EP2
WHERE
EP2."PERSON_TYPE" = 2
AND EP2."IS_SEND" = 1
AND EP2."USER_ID" = #{s.receiveUserId}
)
</if>
<!-- 其他文件夹,发件人、标题、内容 -->
<if test="s.sendUserId != null or (s.title!=null and s.title!='') or (s.content!=null and s.content!='')">
......@@ -84,12 +83,21 @@
)
</if>
</where>
GROUP BY EP.id
</select>
<select id="selectSearchPage" resultType="com.zq.email.entity.EmailPerson" parameterType="com.zq.email.vo.EmailSearchReqVo">
SELECT
EP1.*
FROM
"EMAIL_PERSON" EP1
WHERE
EP1."ID" IN
(
SELECT
EP.*
EP."ID"
FROM
"EMAIL_PERSON" EP
<where>
......@@ -121,20 +129,18 @@
AND EP."SEND_TIME" &lt;= #{s.endTime}
</if>
<!-- 已发送,收件人 -->
<!-- <if test="s.receiveUserId != null">-->
<!-- AND EP."ID" IN(-->
<!-- SELECT-->
<!-- EP2."ID"-->
<!-- FROM-->
<!-- "EMAIL_PERSON" EP2-->
<!-- WHERE-->
<!-- EP2."PERSON_TYPE" = 2-->
<!-- AND EP2."IS_SEND" = 1-->
<!-- AND EP2."USER_ID" = #{s.receiveUserId}-->
<!-- )-->
<!-- </if>-->
<if test="s.receiveUserId != null">
AND EP."EMAIL_CONTENT_ID" IN(
SELECT
EP2."EMAIL_CONTENT_ID"
FROM
"EMAIL_PERSON" EP2
WHERE
EP2."PERSON_TYPE" = 2
AND EP2."IS_SEND" = 1
AND EP2."USER_ID" = #{s.receiveUserId}
)
</if>
<if test="s.sendUserId != null or (s.title!=null and s.title!='') or (s.content!=null and s.content!='')">
AND EP."EMAIL_CONTENT_ID" IN(
......@@ -169,7 +175,9 @@
)
</if>
</where>
ORDER BY EP."SEND_TIME" DESC
GROUP BY EP."ID"
)
ORDER BY EP1."SEND_TIME" DESC
</select>
......
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