Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
aroad_aqsc
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
许言琪
aroad_aqsc
Commits
355b0fe5
提交
355b0fe5
authored
4月 25, 2019
作者:
宋文杰
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(emergency plan): add the restful api for emergency plan file upload
上级
88e76940
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
88 行增加
和
3 行删除
+88
-3
EmergencyPlanController.java
...ule/emergencyplan/controller/EmergencyPlanController.java
+44
-0
UpFileResponse.java
...phant/framework/galaxy/aroad/response/UpFileResponse.java
+27
-0
ResourceServerConfiguration.java
...xy/aroad/security/config/ResourceServerConfiguration.java
+3
-0
WebSecurityConfigurer.java
...k/galaxy/aroad/security/config/WebSecurityConfigurer.java
+2
-1
application-dev.yml
src/main/resources/application-dev.yml
+12
-2
没有找到文件。
src/main/java/com/elephant/framework/galaxy/aroad/module/emergencyplan/controller/EmergencyPlanController.java
浏览文件 @
355b0fe5
...
...
@@ -6,9 +6,15 @@ import com.elephant.framework.galaxy.aroad.response.R;
import
com.elephant.framework.galaxy.aroad.module.common.annotation.SysLog
;
import
com.elephant.framework.galaxy.aroad.module.emergencyplan.entity.EmergencyPlan
;
import
com.elephant.framework.galaxy.aroad.module.emergencyplan.service.EmergencyPlanService
;
import
com.elephant.framework.galaxy.aroad.response.UpFileResponse
;
import
lombok.AllArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
com.elephant.framework.galaxy.aroad.module.common.controller.BaseController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
/**
...
...
@@ -79,4 +85,42 @@ public class EmergencyPlanController extends BaseController {
return
new
R
<>(
emergencyPlanService
.
removeById
(
planId
));
}
@PostMapping
(
"/upload"
)
@ResponseBody
public
UpFileResponse
upload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
if
(
file
.
isEmpty
())
{
return
null
;
}
// 获取文件名
String
fileName
=
file
.
getOriginalFilename
();
// 获取文件的后缀名
// String suffixName = fileName.substring(fileName.lastIndexOf("."));
// 文件上传路径
String
filePath
=
"./src/main/resources/images/"
;
// 解决中文问题,liunx 下中文路径,图片显示问题
//fileName = UUID.randomUUID() + suffixName;
File
dest
=
new
File
(
filePath
+
fileName
);
// 检测是否存在目录
if
(!
dest
.
getParentFile
().
exists
())
{
dest
.
getParentFile
().
mkdirs
();
}
try
{
// file.transferTo(dest);
FileOutputStream
out
=
new
FileOutputStream
(
filePath
+
fileName
);
out
.
write
(
file
.
getBytes
());
out
.
flush
();
out
.
close
();
return
UpFileResponse
.
builder
()
.
name
(
fileName
)
.
url
(
"/images/"
+
fileName
)
.
build
();
}
catch
(
IllegalStateException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
src/main/java/com/elephant/framework/galaxy/aroad/response/UpFileResponse.java
0 → 100644
浏览文件 @
355b0fe5
package
com
.
elephant
.
framework
.
galaxy
.
aroad
.
response
;
import
lombok.Builder
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @program:
* @description:
* @author: songwenjie
* @create: 2019-04-25 10:34
**/
@Data
@Builder
public
class
UpFileResponse
implements
Serializable
{
/**
* 文件名称
*/
private
String
name
;
/**
* 文件路径
*/
private
String
url
;
}
src/main/java/com/elephant/framework/galaxy/aroad/security/config/ResourceServerConfiguration.java
浏览文件 @
355b0fe5
...
...
@@ -3,6 +3,7 @@ package com.elephant.framework.galaxy.aroad.security.config;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.builders.WebSecurity
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter
;
...
...
@@ -28,4 +29,6 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
.
disable
();
}
}
src/main/java/com/elephant/framework/galaxy/aroad/security/config/WebSecurityConfigurer.java
浏览文件 @
355b0fe5
...
...
@@ -30,7 +30,7 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
.
loginProcessingUrl
(
"/token/form"
)
.
and
()
.
authorizeRequests
()
.
antMatchers
(
"/token/**"
).
permitAll
()
.
antMatchers
(
new
String
[]{
"/token/**"
,
"/images/**"
}
).
permitAll
()
.
anyRequest
().
authenticated
()
.
and
().
csrf
().
disable
();
}
...
...
@@ -43,6 +43,7 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
*/
@Override
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
ignoring
().
antMatchers
(
"/images/**"
);
}
@Bean
...
...
src/main/resources/application-dev.yml
浏览文件 @
355b0fe5
server
:
port
:
999
9
port
:
898
9
spring
:
mvc
:
static-path-pattern
:
/images/*
resources
:
static-locations
:
classpath:images/
servlet
:
multipart
:
enabled
:
true
max-file-size
:
512000
# 最大支持文件大小
max-request-size
:
512000
# 最大支持请求大小
datasource
:
driver-class-name
:
com.mysql.jdbc.Driver
url
:
jdbc:mysql://127.0.0.1:3306/aroad?useUnicode=true&characterEncoding=utf-8&useSSL=false
username
:
root
password
:
root
password
:
123456
cache
:
type
:
redis
redis
:
...
...
@@ -26,6 +35,7 @@ spring:
max-wait
:
-1ms
max-active
:
8
shutdown-timeout
:
100ms
mybatis-plus
:
mapper-locations
:
classpath:/mapper/*/*.xml
configuration
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论