Commit 9a457fce by chentianzhong

提一个版本

parent d86f2bdf
...@@ -54,7 +54,7 @@ public class EmailController { ...@@ -54,7 +54,7 @@ public class EmailController {
@ApiOperation("列表总数") @ApiOperation("列表总数")
@PostMapping("total") @PostMapping("total")
public ResultVo total(@RequestBody EmailReqVo vo) { public ResultVo total(@RequestBody EmailReqVo vo) {
return ResultVo.success(emailPersonService.emailPage(vo)); return ResultVo.success(emailPersonService.emailCount(vo));
} }
@ApiOperation("列表分页") @ApiOperation("列表分页")
...@@ -64,6 +64,19 @@ public class EmailController { ...@@ -64,6 +64,19 @@ public class EmailController {
} }
@ApiOperation("邮件查询列表总数")
@PostMapping("searchTotal")
public ResultVo searchTotal(@RequestBody EmailSearchReqVo vo) {
return ResultVo.success(emailPersonService.searchTotal(vo));
}
@ApiOperation("邮件查询列表分页")
@PostMapping("searchPage")
public ResultVo searchPage(@RequestBody EmailSearchReqVo vo) {
return ResultVo.success(emailPersonService.searchPage(vo));
}
@ApiOperation("写邮件") @ApiOperation("写邮件")
@PostMapping("edit") @PostMapping("edit")
public ResultVo edit(EmailEditVo vo) { public ResultVo edit(EmailEditVo vo) {
......
...@@ -15,6 +15,8 @@ import lombok.RequiredArgsConstructor; ...@@ -15,6 +15,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* <p> * <p>
* 前端控制器 * 前端控制器
...@@ -41,16 +43,23 @@ public class EmailFolderController { ...@@ -41,16 +43,23 @@ public class EmailFolderController {
} }
@ApiOperation("获取自定义文件夹") @ApiOperation("获取个人自定义文件夹")
@PostMapping("otherFolderList") @PostMapping("otherFolderList")
public ResultVo otherFolderList() { public ResultVo selfCustomFolders() {
OnlineUserDto adminContext = TokenUtils.getAdminContext(); OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!"); AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
return ResultVo.success(this.emailFolderService.lambdaQuery() return ResultVo.success(emailFolderService.selfCustomFolders(adminContext.getUserId()));
.eq(EmailFolder::getUserId, adminContext.getUserId()) }
.orderByAsc(EmailFolder::getSort).list());
@ApiOperation("获取个人自定义文件夹")
@PostMapping("deleteFolder")
public ResultVo deleteFolder(@RequestBody List<Long> folderIdList) {
emailFolderService.deleteFolders(folderIdList);
return ResultVo.success();
} }
@ApiOperation("编辑个人文件夹") @ApiOperation("编辑个人文件夹")
@PostMapping("edit") @PostMapping("edit")
public ResultVo edit(@RequestBody EmailFolderVo vo) { public ResultVo edit(@RequestBody EmailFolderVo vo) {
......
...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.email.entity.EmailPerson; import com.zq.email.entity.EmailPerson;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zq.email.vo.EmailReqVo; import com.zq.email.vo.EmailReqVo;
import com.zq.email.vo.EmailSearchReqVo;
import org.apache.ibatis.annotations.Param;
/** /**
* <p> * <p>
...@@ -15,4 +17,7 @@ import com.zq.email.vo.EmailReqVo; ...@@ -15,4 +17,7 @@ import com.zq.email.vo.EmailReqVo;
*/ */
public interface EmailPersonMapper extends BaseMapper<EmailPerson> { public interface EmailPersonMapper extends BaseMapper<EmailPerson> {
Integer selectSearchTotal(@Param("s") EmailSearchReqVo vo);
Page<EmailPerson> selectSearchPage(Page<EmailPerson> page, @Param("s") EmailSearchReqVo vo);
} }
package com.zq.email.service; package com.zq.email.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.vo.OnlineUserDto; import com.zq.common.vo.OnlineUserDto;
import com.zq.email.entity.EmailContent; import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.EmailDegreeVo; import com.zq.email.vo.*;
import com.zq.email.vo.EmailEditVo; import io.swagger.models.auth.In;
import com.zq.email.vo.EmailTaskVo;
/** /**
* <p> * <p>
...@@ -22,4 +22,5 @@ public interface IEmailContentService extends IService<EmailContent> { ...@@ -22,4 +22,5 @@ public interface IEmailContentService extends IService<EmailContent> {
void setTaskEmail(EmailTaskVo vo); void setTaskEmail(EmailTaskVo vo);
void setDegreeEmail(EmailDegreeVo vo); void setDegreeEmail(EmailDegreeVo vo);
} }
...@@ -21,4 +21,7 @@ public interface IEmailFolderService extends IService<EmailFolder> { ...@@ -21,4 +21,7 @@ public interface IEmailFolderService extends IService<EmailFolder> {
void editFolder(EmailFolderVo vo); void editFolder(EmailFolderVo vo);
List selfCustomFolders(Long userId);
void deleteFolders(List<Long> folderIdList);
} }
...@@ -57,5 +57,7 @@ public interface IEmailPersonService extends IService<EmailPerson> { ...@@ -57,5 +57,7 @@ public interface IEmailPersonService extends IService<EmailPerson> {
void resumeEmail(List<Long> personIdList); void resumeEmail(List<Long> personIdList);
Integer searchTotal(EmailSearchReqVo vo);
Page searchPage(EmailSearchReqVo vo);
} }
...@@ -2,6 +2,7 @@ package com.zq.email.service.impl; ...@@ -2,6 +2,7 @@ package com.zq.email.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.utils.AssertUtils; import com.zq.common.utils.AssertUtils;
import com.zq.common.vo.OnlineUserDto; import com.zq.common.vo.OnlineUserDto;
import com.zq.email.entity.EmailContent; import com.zq.email.entity.EmailContent;
...@@ -12,6 +13,7 @@ import com.zq.email.service.IEmailContentService; ...@@ -12,6 +13,7 @@ import com.zq.email.service.IEmailContentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zq.email.vo.EmailDegreeVo; import com.zq.email.vo.EmailDegreeVo;
import com.zq.email.vo.EmailEditVo; import com.zq.email.vo.EmailEditVo;
import com.zq.email.vo.EmailReqVo;
import com.zq.email.vo.EmailTaskVo; import com.zq.email.vo.EmailTaskVo;
import net.bytebuddy.matcher.CollectionErasureMatcher; import net.bytebuddy.matcher.CollectionErasureMatcher;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -46,6 +48,7 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema ...@@ -46,6 +48,7 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
content.setSendTime(LocalDateTime.now()); content.setSendTime(LocalDateTime.now());
content.setReplyId(vo.getReplyId()); content.setReplyId(vo.getReplyId());
content.setIsTask(vo.getIsTask()); content.setIsTask(vo.getIsTask());
content.setReplyContent(vo.getReplyContent());
if (vo.getRemind().contains(RemindEnum.SMS_REMIND.getKey())){ if (vo.getRemind().contains(RemindEnum.SMS_REMIND.getKey())){
content.setSmsRemind(WhetherEnum.YES.getKey()); content.setSmsRemind(WhetherEnum.YES.getKey());
...@@ -59,6 +62,14 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema ...@@ -59,6 +62,14 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
content.setMessageRemind(WhetherEnum.NO.getKey()); content.setMessageRemind(WhetherEnum.NO.getKey());
} }
if (CollectionUtil.isNotEmpty(vo.getReceiver())){
StringBuffer r = new StringBuffer();
for (Long userId : vo.getReceiver()) {
r.append(userId).append(",");
}
content.setUserList(r.toString());
}
if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())){ if (CollectionUtil.isNotEmpty(vo.getReceiveDeptList())){
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
for (Long deptId : vo.getReceiveDeptList()) { for (Long deptId : vo.getReceiveDeptList()) {
......
...@@ -68,6 +68,25 @@ public class EmailFolderServiceImpl extends ServiceImpl<EmailFolderMapper, Email ...@@ -68,6 +68,25 @@ public class EmailFolderServiceImpl extends ServiceImpl<EmailFolderMapper, Email
this.saveOrUpdate(folder); this.saveOrUpdate(folder);
} }
@Override
public List selfCustomFolders(Long userId) {
return this.lambdaQuery()
.eq(EmailFolder::getUserId, userId)
.orderByAsc(EmailFolder::getSort).list();
}
@Override
public void deleteFolders(List<Long> folderIdList) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
for (Long folderId : folderIdList) {
EmailFolder folder = this.getById(folderId);
AssertUtils.notNull(folder, "删除失败,获取文件夹异常(folderId:+"+folderId+")");
AssertUtils.isTrue(folder.getUserId().equals(adminContext.getUserId()) , "删除失败,非本用户文件夹无法删除(folderId:+"+folderId+")");
}
this.removeByIds(folderIdList);
}
private List<EmailFolderDto> toEmailFolderDto(List<EmailFolder> folderList) { private List<EmailFolderDto> toEmailFolderDto(List<EmailFolder> folderList) {
List<EmailFolderDto> folderDtoList = new ArrayList<>(); List<EmailFolderDto> folderDtoList = new ArrayList<>();
......
...@@ -39,6 +39,7 @@ import org.springframework.core.io.InputStreamResource; ...@@ -39,6 +39,7 @@ import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -368,6 +369,89 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email ...@@ -368,6 +369,89 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
this.updateBatchById(personList); this.updateBatchById(personList);
} }
@Override
public Integer searchTotal(EmailSearchReqVo vo) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
switch (vo.getFolderId()){
case 1: //收件箱
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
break;
case 2: //部门邮件
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsPerson(WhetherEnum.NO.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
break;
case 3: //草稿箱
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.NO.getKey());
break;
case 4: //已发送
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
break;
case 5: //回收站
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsSend(WhetherEnum.YES.getKey());
break;
default: //其他文件夹
break;
}
vo.setUserId(adminContext.getUserId());
Integer total = this.baseMapper.selectSearchTotal(vo);
return total!=null?total:0;
}
@Override
public Page searchPage(EmailSearchReqVo vo) {
OnlineUserDto adminContext = TokenUtils.getAdminContext();
AssertUtils.notNull(adminContext, "登录已失效,请重新登录后再次尝试!");
switch (vo.getFolderId()){
case 1: //收件箱
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
break;
case 2: //部门邮件
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsPerson(WhetherEnum.NO.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
break;
case 3: //草稿箱
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.NO.getKey());
break;
case 4: //已发送
vo.setPersonType(EmailConstant.TYPE_EMAIL_SEND);
vo.setIsPerson(WhetherEnum.YES.getKey());
vo.setIsSend(WhetherEnum.YES.getKey());
break;
case 5: //回收站
vo.setPersonType(EmailConstant.TYPE_EMAIL_RECEIVE);
vo.setIsSend(WhetherEnum.YES.getKey());
break;
default: //其他文件夹
break;
}
vo.setUserId(adminContext.getUserId());
Page<EmailPerson> page = new Page<>(vo.getPage(), vo.getSize());
Page<EmailPerson> page1 = this.baseMapper.selectSearchPage(page, vo);
if (page!=null && page1.getRecords()!=null){
for (EmailPerson person : page1.getRecords()) {
EmailContent content = this.emailContentService.getById(person.getEmailContentId());
person.setEmailContent(content);
}
}
return page1;
}
private void saveEmailSender(OnlineUserDto adminContext, EmailContent content, EmailEditVo vo) { private void saveEmailSender(OnlineUserDto adminContext, EmailContent content, EmailEditVo vo) {
EmailPerson sender = EmailPerson.builder() EmailPerson sender = EmailPerson.builder()
.emailContentId(content.getId()) .emailContentId(content.getId())
......
...@@ -38,6 +38,9 @@ public class EmailEditVo { ...@@ -38,6 +38,9 @@ public class EmailEditVo {
@ApiModelProperty("回复短信id") @ApiModelProperty("回复短信id")
private Long replyId; private Long replyId;
@ApiModelProperty("回复短信内容")
private String replyContent;
@ApiModelProperty("是否任务邮件 0否 1是") @ApiModelProperty("是否任务邮件 0否 1是")
private Integer isTask = 0; private Integer isTask = 0;
......
package com.zq.email.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zq.common.vo.PageReqVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel(description = "查询邮件")
@Data
public class EmailSearchReqVo extends PageReqVo {
@ApiModelProperty(value = "文件夹ID")
private Integer folderId;
@ApiModelProperty(value = "是否已读")
private Integer isRead;
@ApiModelProperty(value = "开始时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
@ApiModelProperty(value = "结束时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
@ApiModelProperty(value = "发件人")
private Long sendUserId;
// @ApiModelProperty(value = "收件人")
// private List<Long> receiveUserId;
@ApiModelProperty(value = "标题关键字")
private String title;
@ApiModelProperty(value = "内容关键字")
private String content;
@ApiModelProperty(value = "附件关键字")
private String attachName;
@ApiModelProperty("是否已发送 :前端不用传")
private Integer isSend;
@ApiModelProperty("人员类型:前端不用传")
private Integer personType;
@ApiModelProperty("是否个人邮件:前端不用传")
private Integer isPerson ;
@ApiModelProperty("当前人员id :前端不用传")
private Long userId;
}
...@@ -2,4 +2,123 @@ ...@@ -2,4 +2,123 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zq.email.mapper.EmailPersonMapper"> <mapper namespace="com.zq.email.mapper.EmailPersonMapper">
<select id="selectSearchTotal" resultType="integer" parameterType="com.zq.email.vo.EmailSearchReqVo">
SELECT
COUNT(1)
FROM
"EMAIL_PERSON" EP
LEFT JOIN
"EMAIL_CONTENT" EC
ON EP."EMAIL_CONTENT_ID" = EC."ID"
LEFT JOIN
"EMAIL_ATTACH" EA
ON EC."ID" = EA."EMAIL_CONTENT_ID"
<where>
<if test="s.folderId != null">
AND EP."FOLDER_ID" = #{s.folderId}
</if>
<if test="s.personType != null">
AND EP."IS_PERSON" = #{s.personType}
</if>
<if test="s.isSend != null">
AND EP."IS_SEND" = #{s.isSend}
</if>
<if test="s.personType != null">
AND EP."PERSON_TYPE" = #{s.personType}
</if>
<if test="s.userId != null">
AND EP."USER_ID" = #{s.userId}
</if>
<if test="s.isRead != null">
AND EP."IS_READ" = #{s.isRead}
</if>
<if test="s.startTime != null and s.endTime!=null ">
AND EP."SEND_TIME" BETWEEN #{s.startTime} AND ${s.endTime}
</if>
<if test="s.sendUserId != null">
AND EC."SEND_USER_ID" =?
</if>
<if test="s.title != null and s.title !='' ">
AND EC."TITLE" LIKE concat('%', #{s.title}, '%')
</if>
<if test="s.content != null and s.content !='' ">
AND EC."CONTENT" LIKE concat('%', #{s.content}, '%')
</if>
<if test="s.attachName != null and s.attachName !='' ">
AND EC."ATTACH_NAME" LIKE concat('%', #{s.attachName}, '%')
</if>
</where>
ORDER BY EP."ID" DESC
</select>
<select id="selectSearchPage" resultType="com.zq.email.entity.EmailPerson" parameterType="com.zq.email.vo.EmailSearchReqVo">
SELECT
EP.*
FROM
"EMAIL_PERSON" EP
LEFT JOIN
"EMAIL_CONTENT" EC
ON EP."EMAIL_CONTENT_ID" = EC."ID"
LEFT JOIN
"EMAIL_ATTACH" EA
ON EC."ID" = EA."EMAIL_CONTENT_ID"
<where>
<if test="s.folderId != null">
AND EP."FOLDER_ID" = #{s.folderId}
</if>
<if test="s.isPerson != null">
AND EP."IS_PERSON" = #{s.isPerson}
</if>
<if test="s.isSend != null">
AND EP."IS_SEND" = #{s.isSend}
</if>
<if test="s.personType != null">
AND EP."PERSON_TYPE" = #{s.personType}
</if>
<if test="s.userId != null">
AND EP."USER_ID" = #{s.userId}
</if>
<if test="s.isRead != null">
AND EP."IS_READ" = #{s.isRead}
</if>
<if test="s.startTime != null and s.endTime!=null ">
AND EP."SEND_TIME" &gt;= #{s.startTime}
AND EP."SEND_TIME" &lt;= #{s.endTime}
</if>
<if test="s.sendUserId != null">
AND EC."SEND_USER_ID" = #{s.sendUserId}
</if>
<if test="s.title != null and s.title !='' ">
AND EC."TITLE" LIKE concat('%', #{s.title}, '%')
</if>
<if test="s.content != null and s.content !='' ">
AND EC."CONTENT" LIKE concat('%', #{s.content}, '%')
</if>
<if test="s.attachName != null and s.attachName !='' ">
AND EC."ATTACH_NAME" LIKE concat('%', #{s.attachName}, '%')
</if>
</where>
ORDER BY EP."ID" DESC
</select>
</mapper> </mapper>
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