Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
email
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈天仲
email
Commits
854c3519
Commit
854c3519
authored
Mar 07, 2023
by
chentianzhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3333
parent
eafbca4e
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
459 additions
and
111 deletions
+459
-111
src/main/java/com/zq/email/constants/EmailConstant.java
+2
-2
src/main/java/com/zq/email/controller/EmailAttachController.java
+23
-0
src/main/java/com/zq/email/controller/EmailController.java
+18
-0
src/main/java/com/zq/email/controller/EmailFolderController.java
+11
-4
src/main/java/com/zq/email/controller/EmailPersonController.java
+31
-0
src/main/java/com/zq/email/dto/EmailFolderDto.java
+1
-1
src/main/java/com/zq/email/entity/EmailAttach.java
+6
-4
src/main/java/com/zq/email/entity/EmailContent.java
+5
-3
src/main/java/com/zq/email/entity/EmailFolder.java
+2
-2
src/main/java/com/zq/email/entity/EmailLabel.java
+2
-2
src/main/java/com/zq/email/entity/EmailPerson.java
+6
-4
src/main/java/com/zq/email/feign/AdminFeignClient.java
+2
-37
src/main/java/com/zq/email/feign/FileFeignClient.java
+30
-0
src/main/java/com/zq/email/feign/fallback/AdminFeignFallbackFactory.java
+4
-36
src/main/java/com/zq/email/feign/fallback/FileFeignFallbackFactory.java
+48
-0
src/main/java/com/zq/email/service/IEmailAttachService.java
+8
-0
src/main/java/com/zq/email/service/IEmailFolderService.java
+5
-0
src/main/java/com/zq/email/service/IEmailPersonService.java
+7
-0
src/main/java/com/zq/email/service/impl/EmailAttachServiceImpl.java
+52
-0
src/main/java/com/zq/email/service/impl/EmailContentServiceImpl.java
+2
-1
src/main/java/com/zq/email/service/impl/EmailFolderServiceImpl.java
+31
-1
src/main/java/com/zq/email/service/impl/EmailPersonServiceImpl.java
+91
-6
src/main/java/com/zq/email/vo/EmailDetailVo.java
+20
-0
src/main/java/com/zq/email/vo/EmailEditVo.java
+8
-5
src/main/java/com/zq/email/vo/EmailFolderMoveVo.java
+20
-0
src/main/java/com/zq/email/vo/EmailFolderVo.java
+20
-0
src/main/java/com/zq/email/vo/EmailReqVo.java
+4
-3
No files found.
src/main/java/com/zq/email/constants/EmailConstant.java
View file @
854c3519
...
...
@@ -13,9 +13,9 @@ public class EmailConstant {
//人员类型
/**发送人*/
public
static
final
String
TYPE_EMAIL_SEND
=
"1"
;
public
static
final
Integer
TYPE_EMAIL_SEND
=
1
;
/**接收人*/
public
static
final
String
TYPE_EMAIL_RECEIVE
=
"2"
;
public
static
final
Integer
TYPE_EMAIL_RECEIVE
=
2
;
//邮件服务系统标识
public
static
final
String
SYSTEM_TAG
=
"oa-email"
;
...
...
src/main/java/com/zq/email/controller/EmailAttachController.java
View file @
854c3519
package
com
.
zq
.
email
.
controller
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.service.IEmailAttachService
;
import
com.zq.email.vo.EmailDetailVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
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
;
...
...
@@ -13,8 +25,19 @@ import org.springframework.web.bind.annotation.RestController;
* @author chentianzhong
* @since 2023-03-06
*/
@Api
(
tags
=
"附件接口"
)
@RestController
@RequestMapping
(
"/email/emailAttach"
)
@Slf4j
@RequiredArgsConstructor
public
class
EmailAttachController
{
private
final
IEmailAttachService
emailAttachService
;
@ApiOperation
(
"获取附件"
)
@PostMapping
public
ResultVo
detail
(
@RequestBody
EmailDetailVo
vo
)
{
AssertUtils
.
notNull
(
vo
.
getContentId
(),
"缺少参数:contentId"
);
return
ResultVo
.
success
(
emailAttachService
.
findByContentId
(
vo
.
getContentId
()));
}
}
src/main/java/com/zq/email/controller/EmailController.java
View file @
854c3519
...
...
@@ -5,9 +5,13 @@ import cn.hutool.core.collection.CollectionUtil;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.enums.EmailFolderEnum
;
import
com.zq.email.enums.WhetherEnum
;
import
com.zq.email.service.IEmailContentService
;
import
com.zq.email.service.IEmailPersonService
;
import
com.zq.email.vo.EmailDetailVo
;
import
com.zq.email.vo.EmailEditVo
;
import
com.zq.email.vo.EmailReqVo
;
import
io.swagger.annotations.Api
;
...
...
@@ -35,6 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
EmailController
{
private
final
IEmailPersonService
emailPersonService
;
private
final
IEmailContentService
emailContentService
;
@ApiOperation
(
"列表总数"
)
@PostMapping
(
"total"
)
...
...
@@ -53,11 +58,24 @@ public class EmailController {
@PostMapping
(
"edit"
)
public
ResultVo
edit
(
@RequestBody
EmailEditVo
vo
)
{
AssertUtils
.
hasText
(
vo
.
getTitle
(),
"缺少参数:title"
);
AssertUtils
.
notNull
(
vo
.
getIsSend
(),
"缺少参数: isSend"
);
AssertUtils
.
isTrue
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
())
||
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
()),
"缺少参数:receiver和 receiveDeptList"
);
emailPersonService
.
emailEditVo
(
vo
);
return
ResultVo
.
success
();
}
@ApiOperation
(
"邮件详情,这个接口如果前端从列表能获取到显示就不用调用"
)
@PostMapping
(
"detail"
)
public
ResultVo
detail
(
@RequestBody
EmailDetailVo
vo
)
{
AssertUtils
.
notNull
(
vo
.
getPersonId
(),
"缺少参数:id"
);
EmailPerson
emailPerson
=
emailPersonService
.
getById
(
vo
.
getPersonId
());
AssertUtils
.
notNull
(
emailPerson
,
"获取邮件对应人员信息失败"
);
EmailContent
content
=
emailContentService
.
getById
(
emailPerson
.
getEmailContentId
());
AssertUtils
.
notNull
(
content
,
"获取邮件内容失败"
);
emailPerson
.
setEmailContent
(
content
);
return
ResultVo
.
success
(
emailPerson
);
}
...
...
src/main/java/com/zq/email/controller/EmailFolderController.java
View file @
854c3519
...
...
@@ -5,15 +5,15 @@ import com.zq.common.utils.AssertUtils;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.entity.EmailFolder
;
import
com.zq.email.service.IEmailFolderService
;
import
com.zq.email.vo.EmailFolderMoveVo
;
import
com.zq.email.vo.EmailFolderVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
/**
* <p>
...
...
@@ -40,4 +40,11 @@ public class EmailFolderController {
return
ResultVo
.
success
(
emailFolderService
.
selfFolderList
(
adminContext
.
getUserId
()));
}
@ApiOperation
(
"编辑个人文件夹"
)
@PostMapping
(
"edit"
)
public
ResultVo
edit
(
@RequestBody
EmailFolderVo
vo
)
{
emailFolderService
.
editFolder
(
vo
);
return
ResultVo
.
success
();
}
}
src/main/java/com/zq/email/controller/EmailPersonController.java
View file @
854c3519
package
com
.
zq
.
email
.
controller
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.service.IEmailPersonService
;
import
com.zq.email.vo.EmailDetailVo
;
import
com.zq.email.vo.EmailFolderMoveVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
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
;
...
...
@@ -13,8 +24,28 @@ import org.springframework.web.bind.annotation.RestController;
* @author chentianzhong
* @since 2023-03-06
*/
@Api
(
tags
=
"邮件人员接口"
)
@RestController
@RequestMapping
(
"/email/emailPerson"
)
@Slf4j
@RequiredArgsConstructor
public
class
EmailPersonController
{
private
final
IEmailPersonService
emailPersonService
;
@ApiOperation
(
"移动邮件到个人文件夹"
)
@PostMapping
(
"move"
)
public
ResultVo
edit
(
@RequestBody
EmailFolderMoveVo
vo
)
{
emailPersonService
.
moveEmailFolder
(
vo
);
return
ResultVo
.
success
();
}
@ApiOperation
(
"邮件收件人详情"
)
@PostMapping
(
"byContentId"
)
public
ResultVo
byContentId
(
@RequestBody
EmailDetailVo
vo
)
{
AssertUtils
.
notNull
(
vo
.
getContentId
(),
"缺少参数:contentId"
);
return
ResultVo
.
success
(
emailPersonService
.
findByContentId
(
vo
.
getContentId
()));
}
}
src/main/java/com/zq/email/dto/EmailFolderDto.java
View file @
854c3519
...
...
@@ -17,7 +17,7 @@ import java.util.List;
@NoArgsConstructor
public
class
EmailFolderDto
{
private
Integer
folderId
;
private
Long
folderId
;
private
String
folderName
;
...
...
src/main/java/com/zq/email/entity/EmailAttach.java
View file @
854c3519
...
...
@@ -7,8 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import
java.io.Serializable
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.*
;
/**
* <p>
...
...
@@ -22,12 +21,15 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"email_attach"
)
@ApiModel
(
value
=
"EmailAttach对象"
,
description
=
""
)
@AllArgsConstructor
@NoArgsConstructor
@Builder
public
class
EmailAttach
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
SSIGN_UUID
)
private
Integer
id
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
UTO
)
private
Long
id
;
private
Long
emailContentId
;
...
...
src/main/java/com/zq/email/entity/EmailContent.java
View file @
854c3519
...
...
@@ -27,8 +27,8 @@ public class EmailContent implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
SSIGN_UUID
)
private
Integer
id
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
UTO
)
private
Long
id
;
private
String
title
;
...
...
@@ -48,8 +48,10 @@ public class EmailContent implements Serializable {
private
Integer
messageRemind
;
private
Long
replId
;
private
Long
repl
y
Id
;
private
String
deptList
;
private
Integer
isTask
;
}
src/main/java/com/zq/email/entity/EmailFolder.java
View file @
854c3519
...
...
@@ -25,8 +25,8 @@ public class EmailFolder implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"folder_id"
,
type
=
IdType
.
A
SSIGN_UUID
)
private
Integer
folderId
;
@TableId
(
value
=
"folder_id"
,
type
=
IdType
.
A
UTO
)
private
Long
folderId
;
private
Long
userId
;
...
...
src/main/java/com/zq/email/entity/EmailLabel.java
View file @
854c3519
...
...
@@ -25,8 +25,8 @@ public class EmailLabel implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
SSIGN_UUID
)
private
Integer
id
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
UTO
)
private
Long
id
;
private
String
labelName
;
...
...
src/main/java/com/zq/email/entity/EmailPerson.java
View file @
854c3519
...
...
@@ -8,8 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import
java.io.Serializable
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.*
;
/**
* <p>
...
...
@@ -23,12 +22,15 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"email_person"
)
@ApiModel
(
value
=
"EmailPerson对象"
,
description
=
""
)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public
class
EmailPerson
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
SSIGN_UUID
)
private
Integer
id
;
@TableId
(
value
=
"id"
,
type
=
IdType
.
A
UTO
)
private
Long
id
;
private
Long
emailContentId
;
...
...
src/main/java/com/zq/email/feign/AdminFeignClient.java
View file @
854c3519
...
...
@@ -24,46 +24,11 @@ public interface AdminFeignClient {
@GetMapping
(
"/oauth/getOnlineUser"
)
OnlineUserDto
getTokenUserInfo
();
@GetMapping
(
"/oauth/getUserInfoByToken"
)
ResultVo
getUserInfoByToken
(
@RequestParam
String
token
);
@GetMapping
(
"/users/getUserById/{userId}"
)
@AnonymousAccess
CustomerUserVo
getUserById
(
@PathVariable
Long
userId
);
@AnonymousAccess
@PostMapping
(
"/users/getUserByUserName"
)
ResultVo
<
CustomerUserVo
>
getUserByUserName
(
@RequestParam
String
userName
);
@Log
(
"根据人员标识查询用户"
)
@ApiOperation
(
"根据人员标识查询用户"
)
@AnonymousAccess
@GetMapping
(
"/users/getBypCode/{pCode}"
)
public
ResultVo
<
CustomerUserVo
>
getBypCode
(
@PathVariable
String
pCode
);
// @ApiOperation("根据部门id查询部门信息")
// @GetMapping("/dept/getByDeptId/{deptId}")
// ResultVo<DeptVo> getByDeptId(@PathVariable Long deptId);
//
// @Log("根据部门机构标识查询部门信息")
// @ApiOperation("根据部门机构标识查询部门信息")
// @AnonymousAccess
// @GetMapping("/dept/getByDeptName/{orgCode}")
// public ResultVo<DeptVo> getByOrgCode(@PathVariable("orgCode") String orgCode);
//
// @ApiOperation("根据法院代码查询法院信息")
// @AnonymousAccess
// @GetMapping("/court/getCourtByFYCode/{code}")
// public ResultVo<OrgFyxx> getCourtByFYCode(@PathVariable String code);
//
// @ApiOperation("根据法院分级码查询法院信息")
// @AnonymousAccess
// @GetMapping("/court/getCourtByCode/{code}")
// public ResultVo<OrgFyxx> getCourtByCode(@PathVariable String code);
//
// @AnonymousAccess
// @ApiOperation("分级获取基层院 1-获取全区法院(高院除外) 2-获取中院 3-获取基层院 4-全部法院")
// @GetMapping("/court/findAll/{type}")
// public ResultVo<List<OrgFyxx>> findAllCourt(@PathVariable Integer type);
@GetMapping
(
value
=
"/users/getUserByDeptId/{deptId}"
)
ResultVo
<
List
<
CustomerUserVo
>>
getUserByDeptId
(
@PathVariable
(
value
=
"deptId"
)
Long
deptId
);
}
src/main/java/com/zq/email/feign/FileFeignClient.java
0 → 100644
View file @
854c3519
package
com
.
zq
.
email
.
feign
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.common.vo.SysFileUploadVo
;
import
com.zq.common.vo.UploadFileListRespVo
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
@FeignClient
(
name
=
"FILE-SERVER"
,
path
=
"/file"
)
public
interface
FileFeignClient
{
@PostMapping
(
value
=
"/uploadFileList"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
ResultVo
<
UploadFileListRespVo
>
uploadFileList
(
@RequestPart
(
"fileList"
)
MultipartFile
[]
fileList
,
@RequestParam
(
"systemTag"
)
String
systemTag
,
@RequestParam
(
"userId"
)
Long
userId
,
@RequestParam
(
"businessId"
)
String
businessId
);
@GetMapping
(
value
=
"/getUploadFileById/{id}"
)
ResultVo
<
SysFileUploadVo
>
getUploadFileById
(
@PathVariable
String
id
);
@GetMapping
(
value
=
"/downloadFile/{fileId}"
)
ResponseEntity
<
Resource
>
download
(
@PathVariable
String
fileId
);
}
src/main/java/com/zq/email/feign/fallback/AdminFeignFallbackFactory.java
View file @
854c3519
...
...
@@ -30,52 +30,20 @@ public class AdminFeignFallbackFactory implements FallbackFactory<AdminFeignClie
return
null
;
}
@Override
public
ResultVo
getUserInfoByToken
(
String
token
)
{
LOG
.
error
(
"获取当前登入用户信息失败"
);
return
ResultVo
.
fail
(
"getUserInfoByToken:获取当前登入用户信息失败"
);
}
@Override
public
CustomerUserVo
getUserById
(
Long
userId
)
{
LOG
.
error
(
"根据userId获取人员信息失败"
);
return
null
;
}
@Override
public
ResultVo
<
CustomerUserVo
>
getUserByUserName
(
String
userName
)
{
return
ResultVo
.
fail
(
"根据用户名获取人员信息失败,admin异常信息:"
+
msg
);
public
ResultVo
<
List
<
CustomerUserVo
>>
getUserByDeptId
(
Long
deptId
)
{
LOG
.
error
(
"根据deptId获取部门人员信息失败"
);
return
null
;
}
@Override
public
ResultVo
<
CustomerUserVo
>
getBypCode
(
String
pCode
)
{
return
ResultVo
.
fail
(
"根据人员标识获取人员信息失败,admin异常信息:"
+
msg
);
}
// @Override
// public ResultVo<DeptVo> getByDeptId(Long deptId) {
// return ResultVo.fail("根据部门id获取部门信息失败,admin异常信息:"+msg);
// }
//
// @Override
// public ResultVo<DeptVo> getByOrgCode(String orgCode) {
// return ResultVo.fail("根据部门标识获取部门信息失败,admin异常信息:"+msg);
// }
//
// @Override
// public ResultVo<OrgFyxx> getCourtByFYCode(String code) {
// return ResultVo.fail("根据法院代码获取法院信息失败,admin异常信息:"+msg);
// }
//
// @Override
// public ResultVo<OrgFyxx> getCourtByCode(String code) {
// return ResultVo.fail("根据法院分级码获取法院信息失败,admkin异常信息:"+msg);
// }
//
// @Override
// public ResultVo<List<OrgFyxx>> findAllCourt(Integer type) {
// return ResultVo.fail("获取法院信息失败,admin异常信息:"+msg);
// }
};
}
}
src/main/java/com/zq/email/feign/fallback/FileFeignFallbackFactory.java
0 → 100644
View file @
854c3519
package
com
.
zq
.
email
.
feign
.
fallback
;
import
com.zq.common.vo.*
;
import
com.zq.email.feign.AdminFeignClient
;
import
com.zq.email.feign.FileFeignClient
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.cloud.openfeign.FallbackFactory
;
import
org.springframework.core.io.Resource
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
@Component
public
class
FileFeignFallbackFactory
implements
FallbackFactory
<
FileFeignClient
>
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
FileFeignFallbackFactory
.
class
);
@Override
public
FileFeignClient
create
(
Throwable
throwable
)
{
String
msg
=
throwable
==
null
?
""
:
throwable
.
getMessage
();
if
(!
StringUtils
.
isEmpty
(
msg
))
{
LOG
.
error
(
"admin服务调用异常,异常原因:"
+
msg
);
}
return
new
FileFeignClient
()
{
@Override
public
ResultVo
<
UploadFileListRespVo
>
uploadFileList
(
MultipartFile
[]
fileList
,
String
systemTag
,
Long
userId
,
String
businessId
)
{
LOG
.
error
(
"上传多附件失败"
);
return
ResultVo
.
fail
(
"上传多附件失败"
);
}
@Override
public
ResultVo
<
SysFileUploadVo
>
getUploadFileById
(
String
id
)
{
LOG
.
error
(
"根据文件服务id获取文件对象失败"
);
return
ResultVo
.
fail
(
"根据文件服务id获取文件对象失败"
);
}
@Override
public
ResponseEntity
<
Resource
>
download
(
String
fileId
)
{
LOG
.
error
(
"下载文件失败(fileId:"
+
fileId
+
")"
);
return
null
;
}
};
}
}
src/main/java/com/zq/email/service/IEmailAttachService.java
View file @
854c3519
...
...
@@ -2,6 +2,10 @@ package com.zq.email.service;
import
com.zq.email.entity.EmailAttach
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.zq.email.entity.EmailContent
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
/**
* <p>
...
...
@@ -13,4 +17,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public
interface
IEmailAttachService
extends
IService
<
EmailAttach
>
{
void
saveAttach
(
List
<
MultipartFile
>
fileIdList
,
EmailContent
content
);
List
<
EmailAttach
>
findByContentId
(
Long
contentId
);
}
src/main/java/com/zq/email/service/IEmailFolderService.java
View file @
854c3519
...
...
@@ -2,6 +2,8 @@ package com.zq.email.service;
import
com.zq.email.entity.EmailFolder
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.zq.email.vo.EmailFolderMoveVo
;
import
com.zq.email.vo.EmailFolderVo
;
import
java.util.List
;
...
...
@@ -16,4 +18,7 @@ import java.util.List;
public
interface
IEmailFolderService
extends
IService
<
EmailFolder
>
{
List
selfFolderList
(
Long
userId
);
void
editFolder
(
EmailFolderVo
vo
);
}
src/main/java/com/zq/email/service/IEmailPersonService.java
View file @
854c3519
...
...
@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.zq.email.entity.EmailPerson
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.zq.email.vo.EmailEditVo
;
import
com.zq.email.vo.EmailFolderMoveVo
;
import
com.zq.email.vo.EmailReqVo
;
import
java.util.List
;
/**
* <p>
* 服务类
...
...
@@ -21,4 +24,8 @@ public interface IEmailPersonService extends IService<EmailPerson> {
Page
<
EmailPerson
>
emailPage
(
EmailReqVo
vo
);
void
emailEditVo
(
EmailEditVo
vo
);
void
moveEmailFolder
(
EmailFolderMoveVo
vo
);
List
<
EmailPerson
>
findByContentId
(
Long
contentId
);
}
src/main/java/com/zq/email/service/impl/EmailAttachServiceImpl.java
View file @
854c3519
package
com
.
zq
.
email
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.*
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.entity.EmailAttach
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.feign.FileFeignClient
;
import
com.zq.email.mapper.EmailAttachMapper
;
import
com.zq.email.service.IEmailAttachService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.tools.jstat.Token
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* <p>
...
...
@@ -15,6 +30,43 @@ import org.springframework.stereotype.Service;
* @since 2023-03-06
*/
@Service
@RequiredArgsConstructor
public
class
EmailAttachServiceImpl
extends
ServiceImpl
<
EmailAttachMapper
,
EmailAttach
>
implements
IEmailAttachService
{
private
final
FileFeignClient
fileFeignClient
;
@Override
public
void
saveAttach
(
List
<
MultipartFile
>
fileIdList
,
EmailContent
content
)
{
//先检查旧附件
this
.
lambdaUpdate
().
eq
(
EmailAttach:
:
getEmailContentId
,
content
.
getId
()).
remove
();
ResultVo
<
UploadFileListRespVo
>
uploadFileListRespVoResultVo
=
fileFeignClient
.
uploadFileList
(
fileIdList
.
toArray
(
new
MultipartFile
[
fileIdList
.
size
()]),
EmailConstant
.
SYSTEM_TAG
,
content
.
getSendUserId
(),
String
.
valueOf
(
content
.
getId
()));
AssertUtils
.
isTrue
(
uploadFileListRespVoResultVo
.
isSuccess
(),
"上传文件失败"
);
UploadFileListRespVo
data
=
uploadFileListRespVoResultVo
.
getData
();
AssertUtils
.
isTrue
(
data
!=
null
&&
CollectionUtil
.
isNotEmpty
(
data
.
getUploadFileRespVos
()),
"上传文件失败,结果为空"
);
List
<
EmailAttach
>
attachList
=
new
ArrayList
<>();
for
(
UploadFileRespVo
uploadFileRespVo
:
data
.
getUploadFileRespVos
())
{
EmailAttach
emailAttach
=
EmailAttach
.
builder
()
.
emailContentId
(
content
.
getId
())
.
attachId
(
uploadFileRespVo
.
getId
())
.
attachName
(
uploadFileRespVo
.
getFileName
())
.
attachSize
(
uploadFileRespVo
.
getSize
())
.
downloadPath
(
uploadFileRespVo
.
getDownloadPath
())
.
sendTime
(
content
.
getSendTime
())
.
build
();
attachList
.
add
(
emailAttach
);
}
this
.
saveBatch
(
attachList
);
}
@Override
public
List
<
EmailAttach
>
findByContentId
(
Long
contentId
)
{
return
this
.
lambdaQuery
().
eq
(
EmailAttach:
:
getEmailContentId
,
contentId
).
orderByAsc
(
EmailAttach:
:
getId
).
list
();
}
}
src/main/java/com/zq/email/service/impl/EmailContentServiceImpl.java
View file @
854c3519
...
...
@@ -40,7 +40,8 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
content
.
setSendUserEmail
(
adminContext
.
getUserName
());
content
.
setSendUserName
(
adminContext
.
getNickName
());
content
.
setSendTime
(
LocalDateTime
.
now
());
content
.
setReplId
(
vo
.
getReplId
());
content
.
setReplyId
(
vo
.
getReplyId
());
content
.
setIsTask
(
vo
.
getIsTask
());
if
(
vo
.
getRemind
().
contains
(
RemindEnum
.
SMS_REMIND
.
getKey
())){
content
.
setSmsRemind
(
WhetherEnum
.
YES
.
getKey
());
...
...
src/main/java/com/zq/email/service/impl/EmailFolderServiceImpl.java
View file @
854c3519
package
com
.
zq
.
email
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.email.dto.EmailFolderDto
;
import
com.zq.email.entity.EmailFolder
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.enums.EmailFolderEnum
;
import
com.zq.email.mapper.EmailFolderMapper
;
import
com.zq.email.service.IEmailFolderService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.email.service.IEmailPersonService
;
import
com.zq.email.vo.EmailFolderMoveVo
;
import
com.zq.email.vo.EmailFolderVo
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
...
...
@@ -21,12 +29,16 @@ import java.util.List;
* @since 2023-03-06
*/
@Service
@RequiredArgsConstructor
public
class
EmailFolderServiceImpl
extends
ServiceImpl
<
EmailFolderMapper
,
EmailFolder
>
implements
IEmailFolderService
{
@Override
public
List
selfFolderList
(
Long
userId
)
{
List
<
EmailFolder
>
folderList
=
this
.
lambdaQuery
().
eq
(
EmailFolder:
:
getUserId
,
userId
).
orderByAsc
(
EmailFolder:
:
getSort
).
list
();
List
<
EmailFolder
>
folderList
=
this
.
lambdaQuery
()
.
eq
(
EmailFolder:
:
getUserId
,
userId
)
.
orderByAsc
(
EmailFolder:
:
getSort
).
list
();
List
<
EmailFolderDto
>
folderDtoList
=
toEmailFolderDto
(
folderList
);
List
<
EmailFolderDto
>
list
=
EmailFolderEnum
.
toList
();
if
(
CollectionUtil
.
isNotEmpty
(
folderDtoList
)){
...
...
@@ -39,6 +51,24 @@ public class EmailFolderServiceImpl extends ServiceImpl<EmailFolderMapper, Email
return
list
;
}
@Override
public
void
editFolder
(
EmailFolderVo
vo
)
{
OnlineUserDto
adminContext
=
TokenUtils
.
getAdminContext
();
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
EmailFolder
folder
=
new
EmailFolder
();
if
(
vo
.
getFolderId
()!=
null
){
folder
=
this
.
getById
(
vo
.
getFolderId
());
}
folder
.
setFolderName
(
vo
.
getFolderName
());
folder
.
setUserId
(
adminContext
.
getUserId
());
folder
.
setUserEmail
(
adminContext
.
getUserName
());
folder
.
setSort
(
vo
.
getSort
());
folder
.
setEmailSize
(
vo
.
getEmailSize
());
this
.
saveOrUpdate
(
folder
);
}
private
List
<
EmailFolderDto
>
toEmailFolderDto
(
List
<
EmailFolder
>
folderList
)
{
List
<
EmailFolderDto
>
folderDtoList
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
folderList
)){
...
...
src/main/java/com/zq/email/service/impl/EmailPersonServiceImpl.java
View file @
854c3519
...
...
@@ -5,23 +5,29 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.CustomerUserVo
;
import
com.zq.common.vo.OnlineUserDto
;
import
com.zq.common.vo.ResultVo
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.entity.EmailContent
;
import
com.zq.email.entity.EmailPerson
;
import
com.zq.email.enums.EmailFolderEnum
;
import
com.zq.email.enums.WhetherEnum
;
import
com.zq.email.feign.AdminFeignClient
;
import
com.zq.email.mapper.EmailPersonMapper
;
import
com.zq.email.service.IEmailAttachService
;
import
com.zq.email.service.IEmailContentService
;
import
com.zq.email.service.IEmailPersonService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.email.utils.DateUtils
;
import
com.zq.email.vo.EmailEditVo
;
import
com.zq.email.vo.EmailFolderMoveVo
;
import
com.zq.email.vo.EmailReqVo
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
...
...
@@ -37,6 +43,8 @@ import java.util.List;
public
class
EmailPersonServiceImpl
extends
ServiceImpl
<
EmailPersonMapper
,
EmailPerson
>
implements
IEmailPersonService
{
private
final
IEmailContentService
emailContentService
;
private
final
IEmailAttachService
emailAttachService
;
private
final
AdminFeignClient
adminFeignClient
;
@Override
public
Integer
emailCount
(
EmailReqVo
vo
)
{
...
...
@@ -82,29 +90,106 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
AssertUtils
.
notNull
(
adminContext
,
"登录已失效,请重新登录后再次尝试!"
);
//邮件
EmailContent
content
=
emailContentService
.
saveContent
(
vo
,
adminContext
);
if
(
content
!=
null
)
{
//附件
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getFileId
()))
{
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getFileList
()))
{
emailAttachService
.
saveAttach
(
vo
.
getFileList
(),
content
);
}
//person,先删除
this
.
lambdaUpdate
().
eq
(
EmailPerson:
:
getEmailContentId
,
content
.
getId
()).
remove
();
//发件人
this
.
saveEmailSender
(
adminContext
,
content
,
vo
);
//vo.getIsSend() == 1就发送
if
(
vo
.
getIsSend
()!=
null
&&
vo
.
getIsSend
().
equals
(
WhetherEnum
.
YES
.
getKey
()))
{
//增加收件人
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
()))
{
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiver
()))
{
this
.
saveEmailReceiver
(
vo
.
getReceiver
(),
content
,
vo
);
}
//增加收件部门
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
()))
{
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getReceiveDeptList
()))
{
this
.
saveEmailReceiveDept
(
vo
.
getReceiveDeptList
(),
content
,
vo
);
}
}
}
}
@Override
public
void
moveEmailFolder
(
EmailFolderMoveVo
vo
)
{
List
<
EmailPerson
>
emailPeople
=
this
.
listByIds
(
vo
.
getPersonIdList
());
for
(
EmailPerson
emailPerson
:
emailPeople
)
{
emailPerson
.
setFolderId
(
vo
.
getFolderId
());
}
this
.
updateBatchById
(
emailPeople
);
}
private
void
saveEmailReceiveDept
(
List
<
Long
>
receiveDeptList
,
EmailContent
content
,
EmailEditVo
vo
)
{
@Override
public
List
<
EmailPerson
>
findByContentId
(
Long
contentId
)
{
return
this
.
lambdaQuery
().
eq
(
EmailPerson:
:
getEmailContentId
,
contentId
).
orderByAsc
(
EmailPerson:
:
getId
).
list
();
}
private
void
saveEmailSender
(
OnlineUserDto
adminContext
,
EmailContent
content
,
EmailEditVo
vo
)
{
EmailPerson
sender
=
EmailPerson
.
builder
()
.
userId
(
adminContext
.
getUserId
())
.
userEmail
(
adminContext
.
getUserName
())
.
deptId
(
adminContext
.
getDeptId
())
.
deptName
(
adminContext
.
getDeptName
())
.
courtCode
(
adminContext
.
getCourtCode
())
.
personType
(
EmailConstant
.
TYPE_EMAIL_SEND
)
.
sendTime
(
content
.
getSendTime
())
.
folderId
(
vo
.
getIsSend
().
equals
(
WhetherEnum
.
YES
.
getKey
())
?
EmailFolderEnum
.
FOLDER_ALREADY_SEND
.
getKey
().
longValue
()
:
EmailFolderEnum
.
FOLDER_OUTBOX
.
getKey
().
longValue
())
.
isRead
(
WhetherEnum
.
YES
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
isTask
(
vo
.
getIsTask
())
.
build
();
this
.
save
(
sender
);
}
private
void
saveEmailReceiveDept
(
List
<
Long
>
deptIds
,
EmailContent
content
,
EmailEditVo
vo
)
{
List
<
EmailPerson
>
receiverList
=
new
ArrayList
<>();
for
(
Long
deptId
:
deptIds
)
{
ResultVo
<
List
<
CustomerUserVo
>>
userByDeptId
=
adminFeignClient
.
getUserByDeptId
(
deptId
);
AssertUtils
.
isTrue
(
userByDeptId
.
isSuccess
(),
"获取部门人员失败(deptId: "
+
deptId
+
")"
);
AssertUtils
.
notNull
(
userByDeptId
.
getData
(),
"获取部门人员为null(deptId: "
+
deptId
+
")"
);
for
(
CustomerUserVo
receiver
:
userByDeptId
.
getData
())
{
EmailPerson
receivePerson
=
EmailPerson
.
builder
()
.
userId
(
receiver
.
getUserId
())
.
userEmail
(
receiver
.
getUsername
())
.
deptId
(
receiver
.
getDeptId
())
.
courtCode
(
receiver
.
getCourtCode
())
.
personType
(
EmailConstant
.
TYPE_EMAIL_RECEIVE
)
.
sendTime
(
content
.
getSendTime
())
.
folderId
(
EmailFolderEnum
.
FOLDER_DEPT_INBOX
.
getKey
().
longValue
())
.
isRead
(
WhetherEnum
.
NO
.
getKey
())
.
isPerson
(
WhetherEnum
.
NO
.
getKey
())
.
isTask
(
vo
.
getIsTask
())
.
build
();
receiverList
.
add
(
receivePerson
);
}
}
this
.
saveBatch
(
receiverList
);
}
private
void
saveEmailReceiver
(
List
<
Long
>
receiver
,
EmailContent
content
,
EmailEditVo
vo
)
{
private
void
saveEmailReceiver
(
List
<
Long
>
receiverIds
,
EmailContent
content
,
EmailEditVo
vo
)
{
List
<
EmailPerson
>
receiverList
=
new
ArrayList
<>();
for
(
Long
userId
:
receiverIds
)
{
CustomerUserVo
receiver
=
adminFeignClient
.
getUserById
(
userId
);
AssertUtils
.
notNull
(
receiver
,
"获取收件人失败(userId: "
+
userId
+
")"
);
EmailPerson
receivePerson
=
EmailPerson
.
builder
()
.
userId
(
receiver
.
getUserId
())
.
userEmail
(
receiver
.
getUsername
())
.
deptId
(
receiver
.
getDeptId
())
.
courtCode
(
receiver
.
getCourtCode
())
.
personType
(
EmailConstant
.
TYPE_EMAIL_RECEIVE
)
.
sendTime
(
content
.
getSendTime
())
.
folderId
(
EmailFolderEnum
.
FOLDER_INBOX
.
getKey
().
longValue
())
.
isRead
(
WhetherEnum
.
NO
.
getKey
())
.
isPerson
(
WhetherEnum
.
YES
.
getKey
())
.
isTask
(
vo
.
getIsTask
())
.
build
();
receiverList
.
add
(
receivePerson
);
}
this
.
saveBatch
(
receiverList
);
}
...
...
src/main/java/com/zq/email/vo/EmailDetailVo.java
0 → 100644
View file @
854c3519
package
com
.
zq
.
email
.
vo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Api
(
"邮件详情参数"
)
@Data
public
class
EmailDetailVo
{
@ApiModelProperty
(
"personId"
)
private
Long
personId
;
@ApiModelProperty
(
"contentId"
)
private
Long
contentId
;
@ApiModelProperty
(
"文件夹Id"
)
private
Long
folderId
;
}
src/main/java/com/zq/email/vo/EmailEditVo.java
View file @
854c3519
...
...
@@ -7,7 +7,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.util.List
;
@Api
(
"
新建邮件对应VO
"
)
@Api
(
"
发送邮件参数
"
)
@Data
public
class
EmailEditVo
{
...
...
@@ -36,12 +36,15 @@ public class EmailEditVo {
private
List
<
String
>
fileId
;
@ApiModelProperty
(
"回复短信id"
)
private
Long
replId
;
private
Long
repl
y
Id
;
@ApiModelProperty
(
"是否任务邮件"
)
private
Boolean
isTask
;
@ApiModelProperty
(
"是否任务邮件
0否 1是
"
)
private
Integer
isTask
=
0
;
@ApiModelProperty
(
"是否发送 0:发件箱 1:发送"
)
private
Integer
isSend
;
private
Integer
isSend
=
0
;
@ApiModelProperty
(
"附件"
)
private
List
<
MultipartFile
>
fileList
;
}
src/main/java/com/zq/email/vo/EmailFolderMoveVo.java
0 → 100644
View file @
854c3519
package
com
.
zq
.
email
.
vo
;
import
io.swagger.annotations.Api
;
import
lombok.Data
;
import
java.util.List
;
/**
* Created by Chen Tianzhong in 2023/3/6
*/
@Api
(
"移动邮件到个人文件夹"
)
@Data
public
class
EmailFolderMoveVo
{
private
Long
folderId
;
private
List
<
Long
>
personIdList
;
}
src/main/java/com/zq/email/vo/EmailFolderVo.java
0 → 100644
View file @
854c3519
package
com
.
zq
.
email
.
vo
;
import
io.swagger.annotations.Api
;
import
lombok.Data
;
/**
* Created by Chen Tianzhong in 2023/3/6
*/
@Api
(
"编辑个人文件夹参数"
)
@Data
public
class
EmailFolderVo
{
private
Long
folderId
;
private
String
folderName
;
private
Integer
sort
;
private
Integer
emailSize
;
}
src/main/java/com/zq/email/vo/EmailReqVo.java
View file @
854c3519
...
...
@@ -4,6 +4,7 @@ package com.zq.email.vo;
import
com.zq.common.vo.PageReqVo
;
import
com.zq.email.constants.EmailConstant
;
import
com.zq.email.enums.EmailFolderEnum
;
import
com.zq.email.enums.SearchRangeEnum
;
import
com.zq.email.enums.WhetherEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -12,19 +13,19 @@ import lombok.Data;
import
java.util.Date
;
import
java.util.List
;
@ApiModel
(
description
=
"
收件箱前端Vo
"
)
@ApiModel
(
description
=
"
邮件列表参数
"
)
@Data
public
class
EmailReqVo
extends
PageReqVo
{
@ApiModelProperty
(
value
=
"文件夹ID,默认收件箱"
)
private
Integer
folderId
=
EmailFolderEnum
.
FOLDER_INBOX
.
getKey
();
@ApiModelProperty
(
"人员类型, 默认接收人"
)
private
String
personType
=
EmailConstant
.
TYPE_EMAIL_RECEIVE
;
private
Integer
personType
=
EmailConstant
.
TYPE_EMAIL_RECEIVE
;
@ApiModelProperty
(
"是否个人邮件,默认是"
)
private
Integer
isPerson
=
WhetherEnum
.
YES
.
getKey
();
@ApiModelProperty
(
"是否已发送, 默认是"
)
private
Integer
isSend
=
WhetherEnum
.
YES
.
getKey
();
@ApiModelProperty
(
"查询范围,默认最近三个月"
)
private
Integer
searchRange
;
private
Integer
searchRange
=
SearchRangeEnum
.
LAST_THREE_MONTHS
.
getKey
()
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment