Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
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
hubin
long-tern-care-service
Commits
1f15439d
Commit
1f15439d
authored
Feb 10, 2023
by
董天德
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev_20230209_xuhd'
parents
68dd0cdd
66a5d5dc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
0 deletions
+21
-0
ResultCode.java
...-core/src/main/java/com/hungraim/ltc/util/ResultCode.java
+2
-0
FileUploadConfig.java
...java/com/hungraim/ltc/system/config/FileUploadConfig.java
+3
-0
FileUploadController.java
.../hungraim/ltc/system/controller/FileUploadController.java
+9
-0
bootstrap.yml
system/system-admin-service/src/main/resources/bootstrap.yml
+7
-0
No files found.
common/common-core/src/main/java/com/hungraim/ltc/util/ResultCode.java
View file @
1f15439d
...
...
@@ -31,6 +31,8 @@ public enum ResultCode implements IResultCode, Serializable {
TOKEN_INVALID_OR_EXPIRED
(
"A0230"
,
"token无效或已过期"
),
// 请求参数错误,参数校验不通过
REQUEST_PARAM_ERROR
(
"Q0001"
,
"请求参数错误"
),
//文件类型不匹配
FILE_TYPE_ERROR
(
"F0001"
,
"文件类型不支持"
),
// 请求参数错误,参数校验不通过
SRV_ORGAN_NOT_QUERY
(
"S0001"
,
"未查询到数据"
),
/**
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/config/FileUploadConfig.java
View file @
1f15439d
...
...
@@ -4,11 +4,14 @@ import lombok.Data;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
@Data
@ConfigurationProperties
(
prefix
=
"file.upload"
)
public
class
FileUploadConfig
{
private
String
path
;
private
List
<
String
>
type
;
}
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/FileUploadController.java
View file @
1f15439d
...
...
@@ -38,7 +38,16 @@ public class FileUploadController {
if
(
null
==
uploadType
||
null
==
file
)
{
return
Result
.
failed
(
ResultCode
.
REQUEST_PARAM_ERROR
);
}
//过滤上传资料类型
String
originalFilename
=
file
.
getOriginalFilename
();
//文件类型
String
fileType
=
originalFilename
.
substring
(
file
.
getOriginalFilename
().
lastIndexOf
(
"."
));
List
<
String
>
fileTypes
=
fileUploadConfig
.
getType
();
log
.
info
(
"支持图片类型:"
+
fileTypes
+
",上传的图片类型:"
+
fileType
);
if
(!
fileTypes
.
contains
(
fileType
)){
log
.
info
(
"上传文件错误"
);
return
Result
.
failed
(
ResultCode
.
FILE_TYPE_ERROR
);
}
String
realPath
=
FileUtils
.
uploadFile
(
file
,
fileUploadConfig
.
getPath
());
log
.
info
(
"文件上传成功:{}"
,
realPath
);
Long
attachId
=
attachService
.
saveFileInfo
(
originalFilename
,
realPath
,
uploadType
);
...
...
system/system-admin-service/src/main/resources/bootstrap.yml
View file @
1f15439d
...
...
@@ -35,3 +35,10 @@ mybatis-plus:
file
:
upload
:
path
:
E:/workspace/upload
type
:
-
.JPG
-
.JPEG
-
.jpg
-
.jpeg
-
.png
-
.PNG
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