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
17c3b0e8
Commit
17c3b0e8
authored
Nov 01, 2023
by
chentianzhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1111
parent
4a359871
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
262 additions
and
49 deletions
+262
-49
src/main/java/com/zq/email/controller/EmailAttachController.java
+45
-18
src/main/java/com/zq/email/controller/EmailController.java
+13
-0
src/main/java/com/zq/email/entity/EmailContent.java
+3
-0
src/main/java/com/zq/email/feign/AdminFeignClient.java
+3
-0
src/main/java/com/zq/email/feign/fallback/AdminFeignFallbackFactory.java
+5
-0
src/main/java/com/zq/email/service/IEmailAttachService.java
+12
-0
src/main/java/com/zq/email/service/impl/EmailAttachServiceImpl.java
+129
-9
src/main/java/com/zq/email/service/impl/EmailPersonServiceImpl.java
+21
-13
src/main/java/com/zq/email/vo/EmailReqVo.java
+14
-0
src/main/resources/application-dev.yml
+1
-1
src/main/resources/application-product.yml
+2
-2
src/main/resources/application-wanpro.yml
+1
-1
src/main/resources/application.yml
+1
-0
src/main/resources/logback-spring.xml
+1
-1
src/main/resources/mapper/EmailPersonMapper.xml
+11
-4
No files found.
src/main/java/com/zq/email/controller/EmailAttachController.java
View file @
17c3b0e8
...
...
@@ -9,6 +9,8 @@ import cn.hutool.core.util.*;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.zq.common.annotation.AnonymousAccess
;
import
com.zq.common.annotation.rest.AnonymousGetMapping
;
import
com.zq.common.utils.AssertUtils
;
...
...
@@ -75,24 +77,28 @@ public class EmailAttachController {
@ApiOperation
(
"前端调用下载前,判断文件是否是否可以下载"
)
@AnonymousGetMapping
(
"/preDownload/{id}"
)
public
ResultVo
preDownload
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
(
"id"
)
Long
id
)
{
EmailAttach
emailAttach
=
emailAttachService
.
getById
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
byte
[]
bytes
=
null
;
String
download
=
emailAttachService
.
getDownloadPath
(
emailAttach
);
AssertUtils
.
hasText
(
download
,
"下载地址为空"
);
log
.
info
(
"下载文件地址:"
+
download
);
try
{
byte
[]
bytes
=
HttpUtil
.
downloadBytes
(
download
);
AssertUtils
.
isTrue
(
ArrayUtil
.
isNotEmpty
(
bytes
),
"下载文件失败,文件为空"
);
return
ResultVo
.
success
();
}
catch
(
Exception
e
)
{
log
.
error
(
"下载文件失败:"
+
e
.
getLocalizedMessage
(),
e
);
if
(
profile
.
contains
(
"wan"
))
{
return
ResultVo
.
fail
(
"文件可能超过安全时间,禁止从外网访问下载,请从内网查看下载"
);
}
else
{
if
(
StrUtil
.
isNotBlank
(
emailAttach
.
getDownloadPath
())){
bytes
=
emailAttachService
.
downloadNewOaFileByte
(
emailAttach
);
}
else
{
bytes
=
emailAttachService
.
downloadFileByte1
(
emailAttach
);
if
(
bytes
==
null
){
bytes
=
emailAttachService
.
downloadFileByte2
(
emailAttach
);
}
}
if
(
bytes
==
null
){
if
(
profile
.
contains
(
"wan"
)){
return
ResultVo
.
fail
(
"文件超过安全时间,禁止从外网访问下载"
);
}
else
{
return
ResultVo
.
fail
(
"下载文件失败,文件可能不存在"
);
}
}
return
ResultVo
.
success
();
}
@ApiOperation
(
"pc统一下载附件和移动端旧附件下载"
)
...
...
@@ -100,23 +106,44 @@ public class EmailAttachController {
public
void
download
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
(
"id"
)
Long
id
)
{
EmailAttach
emailAttach
=
emailAttachService
.
getById
(
id
);
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
byte
[]
bytes
=
null
;
String
download
=
emailAttachService
.
getDownloadPath
(
emailAttach
);
AssertUtils
.
hasText
(
download
,
"下载地址为空"
);
log
.
info
(
"下载文件地址:"
+
download
);
try
{
byte
[]
bytes
=
HttpUtil
.
downloadBytes
(
download
);
if
(
StrUtil
.
isNotBlank
(
emailAttach
.
getDownloadPath
())){
bytes
=
emailAttachService
.
downloadNewOaFileByte
(
emailAttach
);
}
else
{
bytes
=
emailAttachService
.
downloadFileByte1
(
emailAttach
);
if
(
bytes
==
null
){
bytes
=
emailAttachService
.
downloadFileByte2
(
emailAttach
);
}
}
if
(
bytes
!=
null
){
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename*=UTF-8''"
+
URLEncoder
.
encode
(
emailAttach
.
getAttachName
(),
"UTF-8"
));
response
.
setCharacterEncoding
(
"UTF-8"
);
//ServletUtil.write(response, IoUtil.toStream(bytes),"application/octet-stream");
ServletUtil
.
write
(
response
,
IoUtil
.
toStream
(
bytes
),
FileUtil
.
getMimeType
(
emailAttach
.
getAttachName
())!=
null
?
FileUtil
.
getMimeType
(
emailAttach
.
getAttachName
()):
"application/octet-stream"
);
ServletUtil
.
write
(
response
,
IoUtil
.
toStream
(
bytes
),
FileUtil
.
getMimeType
(
emailAttach
.
getAttachName
())!=
null
?
FileUtil
.
getMimeType
(
emailAttach
.
getAttachName
()):
"application/octet-stream"
);
}
else
{
if
(
profile
.
contains
(
"wan"
)){
AssertUtils
.
isTrue
(
false
,
"文件超过安全时间,禁止从外网访问下载"
);
}
else
{
AssertUtils
.
isTrue
(
false
,
"下载文件失败,文件可能不存在"
);
}
//ServletUtil.write(response, JSON.toJSONString(fail, SerializerFeature.WriteMapNullValue), "application/json;charset=utf-8");
}
}
catch
(
Exception
e
)
{
log
.
error
(
"下载文件失败:"
+
e
.
getLocalizedMessage
(),
e
);
log
.
error
(
e
.
getLocalizedMessage
(),
e
);
if
(
profile
.
contains
(
"wan"
)){
AssertUtils
.
isTrue
(
false
,
"文件超过安全时间,禁止从外网访问下载"
);
}
else
{
AssertUtils
.
isTrue
(
false
,
"下载文件失败,文件可能不存在"
);
}
//ServletUtil.write(response, JSON.toJSONString(ResultVo.fail("下载文件失败:未知异常"), SerializerFeature.WriteMapNullValue), "application/json;charset=utf-8");
}
}
...
...
src/main/java/com/zq/email/controller/EmailController.java
View file @
17c3b0e8
...
...
@@ -12,6 +12,7 @@ import com.zq.email.enums.SearchRangeEnum;
import
com.zq.email.enums.WhetherEnum
;
import
com.zq.email.service.IEmailContentService
;
import
com.zq.email.service.IEmailPersonService
;
import
com.zq.email.utils.DateUtils
;
import
com.zq.email.vo.*
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -22,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import
javax.mail.internet.MimeMessage
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.time.LocalDateTime
;
import
java.util.List
;
/**
...
...
@@ -53,6 +55,11 @@ public class EmailController {
public
ResultVo
total
(
@RequestBody
EmailReqVo
vo
)
{
AssertUtils
.
notNull
(
vo
.
getSearchRange
(),
"缺少参数:searchRange"
);
AssertUtils
.
notNull
(
vo
.
getFolderId
(),
"缺少参数:folderId"
);
if
(
vo
.
getSearchStartTime
()
==
null
&&
vo
.
getSearchStopTime
()==
null
){
vo
.
setSearchStartTime
(
DateUtils
.
getRangeStart
(
0
));
vo
.
setSearchStopTime
(
LocalDateTime
.
now
());
}
return
ResultVo
.
success
(
emailPersonService
.
emailCount
(
vo
));
}
...
...
@@ -61,6 +68,12 @@ public class EmailController {
public
ResultVo
page
(
@RequestBody
EmailReqVo
vo
)
{
AssertUtils
.
notNull
(
vo
.
getSearchRange
(),
"缺少参数:searchRange"
);
AssertUtils
.
notNull
(
vo
.
getFolderId
(),
"缺少参数:folderId"
);
if
(
vo
.
getSearchStartTime
()
==
null
&&
vo
.
getSearchStopTime
()==
null
){
vo
.
setSearchStartTime
(
DateUtils
.
getRangeStart
(
0
));
vo
.
setSearchStopTime
(
LocalDateTime
.
now
());
}
return
ResultVo
.
success
(
emailPersonService
.
emailPage
(
vo
));
}
...
...
src/main/java/com/zq/email/entity/EmailContent.java
View file @
17c3b0e8
...
...
@@ -45,6 +45,9 @@ public class EmailContent implements Serializable {
@TableField
(
exist
=
false
)
private
String
sendUserPhoto
;
@TableField
(
exist
=
false
)
private
String
sendUserDeptName
;
private
String
sendUserName
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
...
...
src/main/java/com/zq/email/feign/AdminFeignClient.java
View file @
17c3b0e8
...
...
@@ -71,6 +71,9 @@ public interface AdminFeignClient {
ResultVo
<
CustomerUserVo
>
getBypCode
(
@PathVariable
String
pCode
);
@AnonymousGetMapping
(
"/dept/getDeptWholeName/{deptId}"
)
public
ResultVo
<
String
>
getDeptWholeName
(
@PathVariable
(
"deptId"
)
Long
deptId
);
...
...
src/main/java/com/zq/email/feign/fallback/AdminFeignFallbackFactory.java
View file @
17c3b0e8
...
...
@@ -84,6 +84,11 @@ public class AdminFeignFallbackFactory implements FallbackFactory<AdminFeignClie
return
ResultVo
.
fail
(
"admin服务调用异常-->get> getBypCode异常"
);
}
@Override
public
ResultVo
<
String
>
getDeptWholeName
(
Long
deptId
)
{
return
ResultVo
.
fail
(
"admin服务调用异常-->get> getDeptWholeName"
);
}
};
}
...
...
src/main/java/com/zq/email/service/IEmailAttachService.java
View file @
17c3b0e8
...
...
@@ -29,6 +29,18 @@ public interface IEmailAttachService extends IService<EmailAttach> {
String
getWpsPreviewUrl
(
Long
id
);
String
getDownloadPath2
(
Long
id
);
String
getDownloadPath2
(
EmailAttach
emailAttach
);
String
getWpsPreviewUrl2
(
Long
id
);
byte
[]
downloadFileByte1
(
EmailAttach
emailAttach
);
byte
[]
downloadFileByte2
(
EmailAttach
emailAttach
);
byte
[]
downloadNewOaFileByte
(
EmailAttach
emailAttach
);
void
updateAttachByContentId
(
EmailContent
emailContent
,
List
<
Long
>
fileIds
);
void
addAttachByContentId
(
EmailContent
emailContent
,
List
<
MultipartFile
>
fileList
);
...
...
src/main/java/com/zq/email/service/impl/EmailAttachServiceImpl.java
View file @
17c3b0e8
...
...
@@ -2,11 +2,14 @@ package com.zq.email.service.impl;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.file.FileNameUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.TokenUtils
;
import
com.zq.common.vo.*
;
...
...
@@ -21,6 +24,8 @@ import com.zq.email.vo.EmailEditVo;
import
com.zq.email.vo.FileViewVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -54,15 +59,20 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getFileIds
()))
{
//拿到旧附件
//list = this.lambdaQuery().eq(EmailAttach::getEmailContentId, content.getId()).in(EmailAttach::getAttachId, vo.getFileIds()).list();
//list = this.lambdaQuery().in(EmailAttach::getAttachId, vo.getFileIds()).list();
for
(
String
fileId
:
vo
.
getFileIds
())
{
//先判断是不是旧附件
LambdaQueryWrapper
<
EmailAttach
>
eq
=
Wrappers
.
lambdaQuery
(
EmailAttach
.
class
)
.
eq
(
EmailAttach:
:
getAttachId
,
fileId
);
EmailAttach
emailAttach
=
this
.
getOne
(
eq
,
false
);
if
(
emailAttach
!=
null
){
if
(
StrUtil
.
isNotBlank
(
emailAttach
.
getDownloadPath
())){
ResultVo
<
SysFileUploadVo
>
uploadFileById
=
fileFeignClient
.
copyFile
(
fileId
,
EmailConstant
.
SYSTEM_TAG
);
//ResultVo<SysFileUploadVo> uploadFileById = fileFeignClient.getUploadFileById(fileId);
if
(
uploadFileById
.
isSuccess
()
&&
uploadFileById
.
getData
()!=
null
){
SysFileUploadVo
data
=
uploadFileById
.
getData
();
EmailAttach
email
Attach
=
EmailAttach
.
builder
()
EmailAttach
new
Attach
=
EmailAttach
.
builder
()
.
emailContentId
(
content
.
getId
())
.
attachId
(
data
.
getId
())
.
attachName
(
data
.
getFileName
())
...
...
@@ -70,13 +80,28 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
.
downloadPath
(
data
.
getDownloadPath
())
.
sendTime
(
content
.
getSendTime
())
.
build
();
list
.
add
(
emailAttach
);
list
.
add
(
newAttach
);
}
}
else
{
EmailAttach
newAttach
=
EmailAttach
.
builder
()
.
emailContentId
(
content
.
getId
())
.
attachId
(
emailAttach
.
getAttachId
())
.
attachName
(
emailAttach
.
getAttachName
())
//.attachSize(emailAttach.getAttachSize())
//.downloadPath(emailAttach.getDownloadPath())
.
sendTime
(
emailAttach
.
getSendTime
())
.
build
();
list
.
add
(
newAttach
);
}
}
}
}
//先检查旧附件
this
.
lambdaUpdate
().
eq
(
EmailAttach:
:
getEmailContentId
,
content
.
getId
()).
remove
();
if
(
CollectionUtil
.
isNotEmpty
(
vo
.
getFileList
()))
{
ResultVo
<
UploadFileListRespVo
>
uploadFileListRespVoResultVo
=
fileFeignClient
.
uploadFileList
(
vo
.
getFileList
().
toArray
(
new
MultipartFile
[
vo
.
getFileList
().
size
()]),
EmailConstant
.
SYSTEM_TAG
,
...
...
@@ -108,10 +133,17 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
List
<
EmailAttach
>
attaches
=
new
ArrayList
<>();
List
<
EmailAttach
>
list
=
this
.
lambdaQuery
().
eq
(
EmailAttach:
:
getEmailContentId
,
contentId
).
orderByAsc
(
EmailAttach:
:
getId
).
list
();
for
(
EmailAttach
attach
:
list
)
{
String
download
=
attach
.
getDownloadPath
();
if
(
StrUtil
.
isNotBlank
(
download
)
&&
profile
.
contains
(
"wan"
)){
attach
.
setDownloadPath
(
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.71"
));
}
String
downloadPath
=
getDownloadPath
(
attach
);
attach
.
setDownloadPath
(
downloadPath
);
// String download = attach.getDownloadPath();
// if (StrUtil.isNotBlank(download)){
// if(profile.contains("wan")) {
// attach.setDownloadPath(download.replaceAll("147.2.3.3", "172.28.1.71"));
// }
// }else{
// attach.setDownloadPath();
//
// }
attaches
.
add
(
attach
);
}
return
attaches
;
...
...
@@ -174,6 +206,7 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
AssertUtils
.
notNull
(
emailAttach
,
"获取附件信息失败"
);
AssertUtils
.
hasText
(
emailAttach
.
getAttachName
(),
"附件名称为空"
);
String
downloadPath
=
this
.
getDownloadPath
(
emailAttach
);
String
suffix
=
emailAttach
.
getAttachName
().
substring
(
emailAttach
.
getAttachName
().
lastIndexOf
(
"."
)
+
1
);
AssertUtils
.
hasText
(
suffix
,
"错误的文件名称("
+
emailAttach
.
getAttachName
()+
"),导致获取文件类型失败"
);
...
...
@@ -199,6 +232,92 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
}
@Override
public
String
getDownloadPath2
(
Long
id
)
{
return
null
;
}
@Override
public
String
getDownloadPath2
(
EmailAttach
emailAttach
)
{
String
download
=
emailAttach
.
getDownloadPath
();
if
(
StrUtil
.
isBlank
(
download
)){
String
year
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyy"
);
String
yearMonth
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMM"
);
String
yearMonthDate
=
DateUtil
.
format
(
emailAttach
.
getSendTime
(),
"yyyyMMdd"
);
String
path
=
"/"
+
year
+
"/"
+
yearMonth
+
"/"
+
yearMonthDate
+
"/"
+
emailAttach
.
getAttachId
()
+
"/"
+
emailAttach
.
getAttachId
()+
"."
+
FileNameUtil
.
getSuffix
(
emailAttach
.
getAttachName
());
if
(
profile
.
equals
(
"product"
)
||
profile
.
equals
(
"test"
))
{
download
=
"http://147.1.3.87/attwjsf_email"
+
path
;
}
else
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
)){
download
=
"http://172.28.1.159:82/attwjsf_yj"
+
path
;
}
}
else
{
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
=
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.71"
);
}
else
{
download
=
download
.
replaceAll
(
"172.28.1.71"
,
"147.2.3.3"
);
}
}
return
download
;
}
@Override
public
String
getWpsPreviewUrl2
(
Long
id
)
{
return
null
;
}
@Override
public
byte
[]
downloadFileByte1
(
EmailAttach
emailAttach
)
{
byte
[]
bytes
=
null
;
String
downloadPath
=
""
;
try
{
downloadPath
=
this
.
getDownloadPath
(
emailAttach
);
bytes
=
HttpUtil
.
downloadBytes
(
downloadPath
);
}
catch
(
Exception
e
){
log
.
error
(
">>>> 1.使用文件名下载文件失败【下载地址:{}, 错误信息:{}"
,
downloadPath
,
e
.
getLocalizedMessage
());
log
.
error
(
e
.
getLocalizedMessage
(),
e
);
bytes
=
null
;
}
return
bytes
;
}
@Override
public
byte
[]
downloadFileByte2
(
EmailAttach
emailAttach
)
{
byte
[]
bytes
=
null
;
String
downloadPath
=
""
;
try
{
downloadPath
=
this
.
getDownloadPath2
(
emailAttach
);
bytes
=
HttpUtil
.
downloadBytes
(
downloadPath
);
}
catch
(
Exception
e
){
log
.
error
(
">>>> 2.使用attachId下载文件失败【下载地址:{}, 错误信息:{}"
,
downloadPath
,
e
.
getLocalizedMessage
());
log
.
error
(
e
.
getLocalizedMessage
(),
e
);
bytes
=
null
;
}
return
bytes
;
}
@Override
public
byte
[]
downloadNewOaFileByte
(
EmailAttach
emailAttach
)
{
String
download
=
emailAttach
.
getDownloadPath
();
byte
[]
bytes
=
null
;
if
(
profile
.
equals
(
"wanpro"
)
||
profile
.
equals
(
"wantest"
))
{
download
=
download
.
replaceAll
(
"147.2.3.3"
,
"172.28.1.71"
);
}
else
{
download
=
download
.
replaceAll
(
"172.28.1.71"
,
"147.2.3.3"
);
}
try
{
bytes
=
HttpUtil
.
downloadBytes
(
download
);
}
catch
(
Exception
e
){
log
.
error
(
">>>> 3.新OA下载文件失败【下载地址:{}, 错误信息:{}"
,
download
,
e
.
getLocalizedMessage
());
log
.
error
(
e
.
getLocalizedMessage
(),
e
);
bytes
=
null
;
}
return
bytes
;
}
@Override
public
void
updateAttachByContentId
(
EmailContent
emailContent
,
List
<
Long
>
fileIds
)
{
List
<
EmailAttach
>
attaches
=
this
.
findByContentId
(
emailContent
.
getId
());
List
<
Long
>
attacheIds
=
attaches
.
stream
().
map
(
e
->
e
.
getId
()).
collect
(
Collectors
.
toList
());
...
...
@@ -210,6 +329,7 @@ public class EmailAttachServiceImpl extends ServiceImpl<EmailAttachMapper, Email
public
void
addAttachByContentId
(
EmailContent
emailContent
,
List
<
MultipartFile
>
fileList
)
{
Long
adminId
=
TokenUtils
.
getAdminId
();
AssertUtils
.
notNull
(
adminId
,
"登录信息异常"
);
ResultVo
<
UploadFileListRespVo
>
uploadFileListRespVoResultVo
=
fileFeignClient
.
uploadFileList
(
fileList
.
toArray
(
new
MultipartFile
[
fileList
.
size
()]),
EmailConstant
.
SYSTEM_TAG
,
adminId
,
...
...
src/main/java/com/zq/email/service/impl/EmailPersonServiceImpl.java
View file @
17c3b0e8
...
...
@@ -83,13 +83,9 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
.
eq
(
vo
.
getPersonType
()!=
null
,
EmailPerson:
:
getPersonType
,
vo
.
getPersonType
())
.
eq
(
vo
.
getIsPerson
()!=
null
,
EmailPerson:
:
getIsPerson
,
vo
.
getIsPerson
())
.
eq
(
vo
.
getIsRead
()!=
null
,
EmailPerson:
:
getIsRead
,
vo
.
getIsRead
())
.
eq
(
vo
.
getIsSend
()!=
null
,
EmailPerson:
:
getIsSend
,
vo
.
getIsSend
());
if
(
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
())
!=
null
){
queryWrapper
.
ge
(
EmailPerson:
:
getSendTime
,
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
()));
queryWrapper
.
le
(
EmailPerson:
:
getSendTime
,
LocalDateTime
.
now
());
}
.
eq
(
vo
.
getIsSend
()!=
null
,
EmailPerson:
:
getIsSend
,
vo
.
getIsSend
())
.
ge
(
vo
.
getSearchStartTime
()!=
null
,
EmailPerson:
:
getSendTime
,
vo
.
getSearchStartTime
())
.
le
(
vo
.
getSearchStopTime
()!=
null
,
EmailPerson:
:
getSendTime
,
vo
.
getSearchStopTime
());
Integer
count
=
this
.
count
(
queryWrapper
);
return
count
!=
null
?
count:
0
;
}
...
...
@@ -108,13 +104,18 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
.
eq
(
vo
.
getPersonType
()!=
null
,
EmailPerson:
:
getPersonType
,
vo
.
getPersonType
())
.
eq
(
vo
.
getIsPerson
()!=
null
,
EmailPerson:
:
getIsPerson
,
vo
.
getIsPerson
())
.
eq
(
vo
.
getIsRead
()!=
null
,
EmailPerson:
:
getIsRead
,
vo
.
getIsRead
())
.
eq
(
vo
.
getIsSend
()!=
null
,
EmailPerson:
:
getIsSend
,
vo
.
getIsSend
());
.
eq
(
vo
.
getIsSend
()!=
null
,
EmailPerson:
:
getIsSend
,
vo
.
getIsSend
())
.
ge
(
vo
.
getSearchStartTime
()!=
null
,
EmailPerson:
:
getSendTime
,
vo
.
getSearchStartTime
())
.
le
(
vo
.
getSearchStopTime
()!=
null
,
EmailPerson:
:
getSendTime
,
vo
.
getSearchStopTime
());
// if (DateUtils.getRangeStart(vo.getSearchRange()) !=null){
// queryWrapper.ge(EmailPerson::getSendTime, DateUtils.getRangeStart(vo.getSearchRange()));
// queryWrapper.le(EmailPerson::getSendTime, LocalDateTime.now());
// }
if
(
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
())
!=
null
){
queryWrapper
.
ge
(
EmailPerson:
:
getSendTime
,
DateUtils
.
getRangeStart
(
vo
.
getSearchRange
()));
queryWrapper
.
le
(
EmailPerson:
:
getSendTime
,
LocalDateTime
.
now
());
}
//queryWrapper.orderByAsc(EmailPerson::getIsRead).orderByDesc(EmailPerson::getSendTime);
queryWrapper
.
orderByDesc
(
EmailPerson:
:
getSendTime
);
//.orderByAsc(EmailPerson::getIsRead);
...
...
@@ -134,17 +135,19 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
ResultVo
<
UserDto
>
senderVo
=
adminFeignClient
.
findById
(
content
.
getSendUserId
());
if
(
senderVo
.
isSuccess
()
&&
senderVo
.
getData
()
!=
null
){
UserDto
data
=
senderVo
.
getData
();
UserDto
userDto
=
new
UserDto
();
if
(
profile
.
contains
(
"wan"
))
{
if
(
StrUtil
.
isNotBlank
(
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
);
}
}
else
{
content
.
setSendUserPhoto
(
data
.
getPhoto
());
}
ResultVo
<
String
>
deptWholeName
=
adminFeignClient
.
getDeptWholeName
(
data
.
getDept
().
getId
());
content
.
setSendUserDeptName
(
deptWholeName
.
getData
());
}
}
record
.
setEmailContent
(
content
);
...
...
@@ -170,6 +173,8 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
vo
.
setIsSend
(
WhetherEnum
.
YES
.
getKey
());
Page
<
EmailPerson
>
page
=
new
Page
<>(
vo
.
getPage
(),
vo
.
getSize
());
page
.
setSearchCount
(
false
).
setOptimizeCountSql
(
false
);
page
=
this
.
baseMapper
.
selectSearchPage
(
page
,
vo
);
if
(
page
!=
null
&&
page
.
getRecords
()!=
null
){
for
(
EmailPerson
person
:
page
.
getRecords
())
{
...
...
@@ -842,7 +847,10 @@ public class EmailPersonServiceImpl extends ServiceImpl<EmailPersonMapper, Email
content
.
setSendUserPhoto
(
data
.
getPhoto
());
//userDto.setPhoto(data.getPhoto());
}
ResultVo
<
String
>
deptWholeName
=
adminFeignClient
.
getDeptWholeName
(
data
.
getDept
().
getId
());
content
.
setSendUserDeptName
(
deptWholeName
.
getData
());
}
}
person
.
setEmailContent
(
content
);
}
...
...
src/main/java/com/zq/email/vo/EmailReqVo.java
View file @
17c3b0e8
package
com
.
zq
.
email
.
vo
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.sun.org.apache.xpath.internal.operations.Bool
;
import
com.zq.common.vo.PageReqVo
;
import
com.zq.email.constants.EmailConstant
;
...
...
@@ -10,7 +11,9 @@ import com.zq.email.enums.WhetherEnum;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -81,4 +84,15 @@ public class EmailReqVo extends PageReqVo {
@ApiModelProperty
(
"发送人Id,邮件管理查询用。"
)
private
Long
sendUserId
;
@ApiModelProperty
(
"查询开始时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
searchStartTime
;
@ApiModelProperty
(
"查询结束时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
searchStopTime
;
}
src/main/resources/application-dev.yml
View file @
17c3b0e8
...
...
@@ -3,7 +3,7 @@ spring:
datasource
:
druid
:
db-type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
${jdbc.driver-class-name}
driverClassName
:
${jdbc.d
b1.d
river-class-name}
username
:
${jdbc.db1.username}
password
:
${jdbc.db1.password}
url
:
${jdbc.db1.base-url}/EMAIL
...
...
src/main/resources/application-product.yml
View file @
17c3b0e8
...
...
@@ -3,10 +3,10 @@ spring:
datasource
:
druid
:
db-type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
${jdbc.driver-class-name}
driverClassName
:
${jdbc.d
b1.d
river-class-name}
username
:
${jdbc.db1.username}
password
:
${jdbc.db1.password}
url
:
${jdbc.db1.base-url}/EMAIL_NEW?
ConfigurePath=/opt/db-config/EMAIL/jdbc_new.conf
url
:
${jdbc.db1.base-url}/EMAIL_NEW?
${jdbc.db1.params}
# 初始连接数
initial-size
:
5
# 最小连接数
...
...
src/main/resources/application-wanpro.yml
View file @
17c3b0e8
...
...
@@ -3,7 +3,7 @@ spring:
datasource
:
druid
:
db-type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
${jdbc.driver-class-name}
driverClassName
:
${jdbc.d
b1.d
river-class-name}
username
:
${jdbc.db1.username}
password
:
${jdbc.db1.password}
url
:
${jdbc.db1.base-url}/EMAIL_NEW
...
...
src/main/resources/application.yml
View file @
17c3b0e8
server
:
port
:
8198
max-http-header-size
:
4048576
#配置数据源
spring
:
application
:
...
...
src/main/resources/logback-spring.xml
View file @
17c3b0e8
...
...
@@ -2,7 +2,7 @@
<configuration>
<contextName>
logback
</contextName>
<property
name=
"log.path"
value=
"/data/logs/
${LOG_PATH:-${PROJECT_NAME}}
"
/>
<property
name=
"log.path"
value=
"/data/logs/
email
"
/>
<!--主要日志文件名-->
<property
name=
"default_log_file"
value=
"email"
/>
<!-- 彩色日志依赖的渲染类 -->
...
...
src/main/resources/mapper/EmailPersonMapper.xml
View file @
17c3b0e8
...
...
@@ -4,7 +4,14 @@
<select
id=
"selectSearchTotal"
resultType=
"integer"
parameterType=
"com.zq.email.vo.EmailSearchReqVo"
>
SELECT
COUNT(1)
count(*)
FROM
"EMAIL_PERSON" EP1
WHERE
EP1."ID" IN
(
SELECT
EP."ID"
FROM
"EMAIL_PERSON" EP
<where>
...
...
@@ -49,7 +56,6 @@
)
</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(
SELECT
...
...
@@ -71,7 +77,7 @@
</where>
)
</if>
<!-- 附件名称-->
<if
test=
"s.attachName!=null and s.attachName!=''"
>
AND EP."EMAIL_CONTENT_ID" IN(
SELECT
...
...
@@ -83,7 +89,8 @@
)
</if>
</where>
GROUP BY EP.id
GROUP BY EP."ID"
)
</select>
...
...
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