Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
easy-affair-show
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
easy-affair-show
Commits
c2a1ca37
Commit
c2a1ca37
authored
Jun 16, 2022
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
素材分组接口bug修改
parent
e1d01e15
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
8 deletions
+150
-8
eas-manager/doc/api.md
eas-manager/doc/api.md
+112
-0
eas-manager/src/main/java/com/mortals/xhx/base/system/upload/service/impl/UploadServiceImpl.java
...hx/base/system/upload/service/impl/UploadServiceImpl.java
+22
-6
eas-manager/src/main/java/com/mortals/xhx/base/system/upload/web/UploadController.java
.../mortals/xhx/base/system/upload/web/UploadController.java
+14
-0
eas-manager/src/main/resources/bootstrap.yml
eas-manager/src/main/resources/bootstrap.yml
+2
-2
No files found.
eas-manager/doc/api.md
View file @
c2a1ca37
...
...
@@ -3248,3 +3248,115 @@ msg|String|消息|-
}
```
## 文件处理
### 上传文件
**请求URL:**
file/upload
**请求方式:**
POST
**内容类型:**
application/json;charset=utf-8
**简要描述:**
上传文件
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:-------
uploadFile|File|是|文件
prePath|String|否|存放子文件夹名称
**请求样例:**
```
{
"uploadFile":"v3egpq",
"prePath":"194smx"
}
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
{
"code":1,
"msg":"成功"
}
```
### 下载文件
**请求URL:** file/common/download
**请求方式:** GET
**内容类型:** application/json;charset=utf-8
**简要描述:** 删除图片分组
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
fileName|String|是|文件名
**请求样例:**
```
http://localhost:8080/eas/file/common/download?fileName=test/2b1a70e34b88405893a7ff1f6db947cc.jpg'
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
{
"code":1,
"msg":"成功"
}
```
### 预览图片
**请求URL:** file/preview
**请求方式:** GET
**内容类型:** application/json;charset=utf-8
**简要描述:** 删除图片分组
**请求参数:**
参数名称|类型|必填|描述
:---|:---|:---|:------
fileName|String|是|文件名
**请求样例:**
```
http://localhost:8080/eas/file/preview/test/2b1a70e34b88405893a7ff1f6db947cc.jpg
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
**响应消息样例:**
```
{
"code":1,
"msg":"成功"
}
```
\ No newline at end of file
eas-manager/src/main/java/com/mortals/xhx/base/system/upload/service/impl/UploadServiceImpl.java
View file @
c2a1ca37
...
...
@@ -16,7 +16,9 @@ import org.springframework.http.MediaType;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.imageio.ImageIO
;
import
javax.servlet.http.HttpServletResponse
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
...
...
@@ -103,14 +105,28 @@ public class UploadServiceImpl implements UploadService {
@Override
public
void
preview
(
String
fileName
,
HttpServletResponse
response
)
{
String
filePath
=
this
.
filePath
+
"/preview/"
+
fileName
;
// String filePath = this.filePath+"/preview/" + fileName;
// try {
// response.setContentType(MediaType.IMAGE_JPEG_VALUE);
// setAttachmentResponseHeader(response, fileName);
// FileUtil.writeToStream(filePath, response.getOutputStream());
// } catch (Exception e) {
// log.error("下载文件失败", e);
// }
String
filePath
=
getFilePath
(
fileName
);
try
{
response
.
setContentType
(
MediaType
.
IMAGE_JPEG_VALUE
);
setAttachmentResponseHeader
(
response
,
fileName
);
FileUtil
.
writeToStream
(
filePath
,
response
.
getOutputStream
());
}
catch
(
Exception
e
)
{
log
.
error
(
"下载文件失败"
,
e
);
File
file
=
new
File
(
filePath
);
BufferedImage
image
=
(
BufferedImage
)
ImageIO
.
read
(
file
);
response
.
setHeader
(
"Pragma"
,
"No-cache"
);
response
.
setHeader
(
"Cache-Control"
,
"No-cache"
);
response
.
setDateHeader
(
"Expires"
,
0L
);
response
.
setContentType
(
"image/jpeg"
);
ImageIO
.
write
(
image
,
"JPEG"
,
response
.
getOutputStream
());
}
catch
(
Exception
var4
)
{
this
.
log
.
debug
(
"响应图片消息异常-->"
+
var4
.
getMessage
());
}
}
...
...
eas-manager/src/main/java/com/mortals/xhx/base/system/upload/web/UploadController.java
View file @
c2a1ca37
...
...
@@ -94,6 +94,20 @@ public class UploadController extends BaseController {
}
}
/**
* 图片预览 (PathVariable)
*
* @param fileName 文件名称
*/
@GetMapping
(
"preview/{prePath}/{fileName}"
)
public
void
preViewPath
(
@PathVariable
(
value
=
"fileName"
)
String
fileName
,
@PathVariable
(
value
=
"prePath"
)
String
prePath
,
HttpServletResponse
response
)
{
try
{
uploadService
.
preview
(
prePath
+
"/"
+
fileName
,
response
);
}
catch
(
Exception
e
)
{
log
.
error
(
"下载文件失败:"
,
e
);
}
}
/**
* 图片预览 (PathVariable)
*
...
...
eas-manager/src/main/resources/bootstrap.yml
View file @
c2a1ca37
...
...
@@ -34,8 +34,8 @@ mybatis:
application
:
auth
:
unloginUrl
:
/refresh,/error,/login/login,/login/index,/login/logout,/
securitycode/createCode,/file/common
/*,/test*,/api/asset/*,/api/*,/zwfw/*,/ws/*,/swagger-ui*,/topic/*,/uploads/*
uncheckUrl
:
/refresh,/error,/login/login,/login/index,/login/logout,/
securitycode/createCode,/file/common
/*,/test*,/api/asset/*,/api/*,/zwfw/*,/ws/*,/swagger-ui*,/topic/*,/uploads/*
unloginUrl
:
/refresh,/error,/login/login,/login/index,/login/logout,/
customer/login/login,customer/login/logout,/securitycode/createCode,/file/common/*,/file/preview
/*,/test*,/api/asset/*,/api/*,/zwfw/*,/ws/*,/swagger-ui*,/topic/*,/uploads/*
uncheckUrl
:
/refresh,/error,/login/login,/login/index,/login/logout,/
customer/login/login,customer/login/logout,/securitycode/createCode,/file/common/*,/file/preview
/*,/test*,/api/asset/*,/api/*,/zwfw/*,/ws/*,/swagger-ui*,/topic/*,/uploads/*
workflow
:
tenantId
:
${spring.application.name}
token
:
...
...
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