Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
2ab772f7
Commit
2ab772f7
authored
Aug 24, 2022
by
查济
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-zhaji' into 'develop'
Feature zhaji See merge request fangxinjiang/yifu!186
parents
2939d6a1
a050d457
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
11 deletions
+51
-11
CommonConstants.java
...ud.plus.v1/yifu/common/core/constant/CommonConstants.java
+4
-0
Common.java
.../com/yifu.cloud.plus.v1/yifu/common/core/util/Common.java
+24
-0
TInsuranceEnclosureController.java
.../insurances/controller/TInsuranceEnclosureController.java
+0
-2
TInsuranceEnclosureServiceImpl.java
...surances/service/impl/TInsuranceEnclosureServiceImpl.java
+23
-9
No files found.
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/CommonConstants.java
View file @
2ab772f7
...
...
@@ -245,6 +245,10 @@ public interface CommonConstants {
public
static
final
String
SPOT
=
"."
;
int
FIFTY_INT
=
50
;
int
BYTE
=
1024
;
/**
* 员工初始序列
* @Author pwang
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/util/Common.java
View file @
2ab772f7
...
...
@@ -471,4 +471,28 @@ public class Common {
}
return
obj
;
}
/**
* 商险附件允许上传的文件类型
*
* @Author pwang
* @Date 2020-01-07 15:52
* @param null
* @return
**/
private
static
final
String
insuranceSuffixList
=
"pdf|png|jpg|word|excel|rar|zip"
;
/**
* 判断是否为允许的上传文件类型,true表示允许
*/
public
static
boolean
checkInsuranceFile
(
String
fileName
)
{
// 获取文件后缀
String
suffix
=
getSuffix
(
fileName
);
if
(
null
!=
suffix
)
{
if
(
insuranceSuffixList
.
contains
(
suffix
.
trim
().
toLowerCase
()))
{
return
true
;
}
}
return
false
;
}
}
yifu-insurances/yifu-insurances-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/insurances/controller/TInsuranceEnclosureController.java
View file @
2ab772f7
...
...
@@ -39,8 +39,6 @@ public class TInsuranceEnclosureController {
@Resource
TInsuranceEnclosureService
tInsuranceEnclosureService
;
private
final
OSSUtil
ossUtil
;
/**
* 商险文件上传
*
...
...
yifu-insurances/yifu-insurances-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/insurances/service/impl/TInsuranceEnclosureServiceImpl.java
View file @
2ab772f7
...
...
@@ -13,14 +13,17 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import
com.yifu.cloud.plus.v1.yifu.insurances.entity.TInsuranceEnclosure
;
import
com.yifu.cloud.plus.v1.yifu.insurances.mapper.TInsuranceEnclosureMapper
;
import
com.yifu.cloud.plus.v1.yifu.insurances.service.TInsuranceEnclosureService
;
import
com.yifu.cloud.plus.v1.yifu.insurances.util.ValidityUtil
;
import
com.yifu.cloud.plus.v1.yifu.insurances.vo.InsuranceEnclosureParam
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.time.LocalDateTime
;
import
java.util.Objects
;
/**
* @author Administrator
...
...
@@ -50,10 +53,19 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos
*/
@Override
public
R
uploadInsuranceEnclosure
(
MultipartFile
file
,
String
filePath
,
String
remark
)
throws
IOException
{
String
enclosureName
=
file
.
getOriginalFilename
().
substring
(
0
,
file
.
getOriginalFilename
().
lastIndexOf
(
"."
));
if
(
Common
.
isEmpty
(
file
)){
return
R
.
failed
(
"商险附件为空"
);
}
if
(!
Common
.
checkInsuranceFile
(
file
.
getOriginalFilename
())){
return
R
.
failed
(
"非法的文件类型"
);
}
if
(
file
.
getSize
()
>
(
CommonConstants
.
FIFTY_INT
*
CommonConstants
.
BYTE
*
CommonConstants
.
BYTE
)){
return
R
.
failed
(
"文件超出上传上限"
);
}
String
enclosureName
=
Objects
.
requireNonNull
(
file
.
getOriginalFilename
()).
substring
(
0
,
file
.
getOriginalFilename
().
lastIndexOf
(
"."
));
String
fileName
=
System
.
currentTimeMillis
()
+
"_"
+
file
.
getOriginalFilename
();
//filePath不传默认存储空间的根目录
//
jpg,jpeg,png,bmp
//
支持的附件格式
String
key
=
""
;
if
(!
Common
.
isNotNull
(
filePath
))
{
key
=
fileName
;
...
...
@@ -61,13 +73,17 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos
key
=
filePath
+
"/"
+
fileName
;
}
boolean
flag
=
ossUtil
.
uploadFileByStream
(
file
.
getInputStream
(),
key
,
null
);
FileVo
fileVo
;
TInsuranceEnclosure
insuranceEnclosure
=
new
TInsuranceEnclosure
();
URL
url
=
null
;
if
(
flag
)
{
TInsuranceEnclosure
insuranceEnclosure
=
new
TInsuranceEnclosure
();
log
.
info
(
"文件:"
+
fileName
+
"上传至存储空间"
+
ossUtil
.
getBucketName
()
+
"成功!"
);
insuranceEnclosure
.
setDeleteFlag
(
CommonConstants
.
ZERO_INT
);
insuranceEnclosure
.
setRemark
(
remark
);
if
(
StringUtils
.
isNotBlank
(
remark
)){
if
(!
ValidityUtil
.
validate50
(
remark
)){
return
R
.
failed
(
"备注字段不能超过50"
);
}
else
{
insuranceEnclosure
.
setRemark
(
remark
);
}
}
insuranceEnclosure
.
setEnclosureName
(
enclosureName
);
insuranceEnclosure
.
setEnclosureAddress
(
key
);
try
{
...
...
@@ -77,9 +93,7 @@ public class TInsuranceEnclosureServiceImpl extends ServiceImpl<TInsuranceEnclos
ossUtil
.
deleteObject
(
null
,
key
);
return
R
.
failed
(
"failed:"
+
e
.
getMessage
());
}
url
=
ossUtil
.
getObjectUrl
(
null
,
insuranceEnclosure
.
getEnclosureAddress
());
fileVo
=
new
FileVo
(
insuranceEnclosure
.
getId
().
toString
(),
insuranceEnclosure
.
getEnclosureName
(),
url
.
toString
());
return
R
.
ok
(
fileVo
);
return
R
.
ok
(
"商险附件上传成功"
);
}
else
{
return
R
.
failed
(
"failed:上传至存储空间失败"
);
}
...
...
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