Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wlzwh
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
mengmeng
wlzwh
Commits
a96c962e
Commit
a96c962e
authored
Jul 20, 2020
by
mengmeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0720 解决跨域post 预检测option问题;最后完善版本
parent
b241c582
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
109 additions
and
29 deletions
+109
-29
hmit-admin.iml
hmit-admin/hmit-admin.iml
+5
-0
WlUploadInfoController.java
...odules/competition/controller/WlUploadInfoController.java
+19
-13
WlUploadInfoDTO.java
...java/io/hmit/modules/competition/dto/WlUploadInfoDTO.java
+1
-8
WlUploadInfoServiceImpl.java
...les/competition/service/impl/WlUploadInfoServiceImpl.java
+6
-3
hmit-api.iml
hmit-api/hmit-api.iml
+5
-0
WlUploadInfoController.java
.../main/java/io/hmit/controller/WlUploadInfoController.java
+35
-2
WlUploadInfoDTO.java
hmit-api/src/main/java/io/hmit/dto/WlUploadInfoDTO.java
+25
-2
CorsInterceptor.java
...pi/src/main/java/io/hmit/interceptor/CorsInterceptor.java
+2
-0
hmit-common.iml
hmit-common/hmit-common.iml
+6
-1
hmit-generator.iml
hmit-generator/hmit-generator.iml
+5
-0
No files found.
hmit-admin/hmit-admin.iml
View file @
a96c962e
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"CheckStyle-IDEA-Module"
>
<option
name=
"configuration"
>
<map
/>
</option>
</component>
<component
name=
"FacetManager"
>
<facet
type=
"jpa"
name=
"JPA"
>
<configuration>
...
...
hmit-admin/src/main/java/io/hmit/modules/competition/controller/WlUploadInfoController.java
View file @
a96c962e
...
...
@@ -3,6 +3,7 @@ package io.hmit.modules.competition.controller;
import
io.hmit.common.annotation.LogOperation
;
import
io.hmit.common.constant.Constant
;
import
io.hmit.common.page.PageData
;
import
io.hmit.common.utils.ConvertUtils
;
import
io.hmit.common.utils.ExcelUtils
;
import
io.hmit.common.utils.Result
;
import
io.hmit.common.validator.AssertUtils
;
...
...
@@ -47,9 +48,9 @@ public class WlUploadInfoController {
@ApiImplicitParam
(
name
=
Constant
.
PAGE
,
value
=
"当前页码,从1开始"
,
paramType
=
"query"
,
required
=
true
,
dataType
=
"int"
)
,
@ApiImplicitParam
(
name
=
Constant
.
LIMIT
,
value
=
"每页显示记录数"
,
paramType
=
"query"
,
required
=
true
,
dataType
=
"int"
)
,
@ApiImplicitParam
(
name
=
Constant
.
ORDER_FIELD
,
value
=
"排序字段"
,
paramType
=
"query"
,
dataType
=
"String"
)
,
@ApiImplicitParam
(
name
=
Constant
.
ORDER
,
value
=
"排序方式,可选值(asc、desc)"
,
paramType
=
"query"
,
dataType
=
"String"
)
@ApiImplicitParam
(
name
=
Constant
.
ORDER
,
value
=
"排序方式,可选值(asc、desc)"
,
paramType
=
"query"
,
dataType
=
"String"
)
,
})
@RequiresPermissions
(
"competition:wluploadinfo:page"
)
//
@RequiresPermissions("competition:wluploadinfo:page")
public
Result
<
PageData
<
WlUploadInfoDTO
>>
page
(
@ApiIgnore
@RequestParam
Map
<
String
,
Object
>
params
){
PageData
<
WlUploadInfoDTO
>
page
=
wlUploadInfoService
.
page
(
params
);
...
...
@@ -65,6 +66,7 @@ public class WlUploadInfoController {
return
new
Result
<
WlUploadInfoDTO
>().
ok
(
data
);
}
/*
@GetMapping("{name}")
@ApiOperation("信息")
//@RequiresPermissions("competition:wluploadinfo:info")
...
...
@@ -73,6 +75,7 @@ public class WlUploadInfoController {
return new Result<List<WlUploadInfoDTO>>().ok(data);
}
*/
@PostMapping
@ApiOperation
(
"保存"
)
...
...
@@ -87,7 +90,7 @@ public class WlUploadInfoController {
return
new
Result
();
}
else
{
return
new
Result
().
error
();
return
new
Result
().
error
(
500
,
"人员信息已存在!"
);
}
}
...
...
@@ -118,14 +121,16 @@ public class WlUploadInfoController {
return
new
Result
();
}
// @GetMapping("export")
// @ApiOperation("导出")
// @LogOperation("导出")
// @RequiresPermissions("competition:wluploadinfo:export")
// public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
// List<WlUploadInfoDTO> list = wlUploadInfoService.list(params);
// ExcelUtils.exportExcelToTarget(response, "比赛数据", list, WlUploadInfoExcel.class);
// }
@GetMapping
(
"export"
)
@ApiOperation
(
"导出"
)
@LogOperation
(
"导出"
)
@RequiresPermissions
(
"competition:wluploadinfo:export"
)
public
void
export
(
@ApiIgnore
@RequestParam
Map
<
String
,
Object
>
params
,
HttpServletResponse
response
)
throws
Exception
{
List
<
WlUploadInfoDTO
>
list
=
wlUploadInfoService
.
list
(
params
);
ExcelUtils
.
exportExcelToTarget
(
response
,
"比赛人员数据"
,
list
,
WlUploadInfoExcel
.
class
);
}
/*
@PostMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
...
...
@@ -135,7 +140,8 @@ public class WlUploadInfoController {
for(int i=0;i<checklist.size();i++){
list.add(wlUploadInfoService.get(checklist.get(i)));
}
ExcelUtils
.
exportExcelToTarget
(
response
,
"比赛数据"
,
list
,
WlUploadInfoExcel
.
class
);
ExcelUtils.exportExcelToTarget(response, "比赛
人员
数据", list, WlUploadInfoExcel.class);
}
*/
}
\ No newline at end of file
}
hmit-admin/src/main/java/io/hmit/modules/competition/dto/WlUploadInfoDTO.java
View file @
a96c962e
...
...
@@ -58,11 +58,4 @@ public class WlUploadInfoDTO implements Serializable {
@ApiModelProperty
(
value
=
"就餐"
)
private
String
dinner
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
value
=
"修改时间"
)
private
Date
updateTime
;
}
\ No newline at end of file
}
hmit-admin/src/main/java/io/hmit/modules/competition/service/impl/WlUploadInfoServiceImpl.java
View file @
a96c962e
...
...
@@ -28,9 +28,12 @@ public class WlUploadInfoServiceImpl extends CrudServiceImpl<WlUploadInfoDao, Wl
@Override
public
QueryWrapper
<
WlUploadInfoEntity
>
getWrapper
(
Map
<
String
,
Object
>
params
){
String
id
=
(
String
)
params
.
get
(
"id"
);
String
name
=
(
String
)
params
.
get
(
"name"
);
QueryWrapper
<
WlUploadInfoEntity
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
StringUtils
.
isNotBlank
(
id
),
"id"
,
id
);
wrapper
.
or
();
wrapper
.
like
(
StringUtils
.
isNotBlank
(
name
),
"name"
,
name
);
return
wrapper
;
}
...
...
@@ -40,7 +43,7 @@ public class WlUploadInfoServiceImpl extends CrudServiceImpl<WlUploadInfoDao, Wl
public
List
<
WlUploadInfoDTO
>
selectInfo
(
String
name
)
{
List
<
WlUploadInfoEntity
>
wlList
=
baseDao
.
selectByName
(
name
);
List
<
WlUploadInfoDTO
>
finallist
=
new
ArrayList
<>();
// ConvertUtils.sourceToTarget(
finall
ist,WlUploadInfoEntity.class);
// ConvertUtils.sourceToTarget(
wlL
ist,WlUploadInfoEntity.class);
for
(
WlUploadInfoEntity
wlUploadInfoEntity:
wlList
){
WlUploadInfoDTO
wlInfo
=
new
WlUploadInfoDTO
();
BeanUtils
.
copyProperties
(
wlUploadInfoEntity
,
wlInfo
);
...
...
@@ -52,11 +55,11 @@ public class WlUploadInfoServiceImpl extends CrudServiceImpl<WlUploadInfoDao, Wl
@Override
public
boolean
isName
(
String
name
)
{
int
count
=
baseDao
.
isName
(
name
);
System
.
out
.
println
(
count
);
System
.
out
.
println
(
name
+
"信息已存在!"
);
if
(
count
==
0
){
return
true
;
}
else
{
return
false
;
}
}
}
\ No newline at end of file
}
hmit-api/hmit-api.iml
View file @
a96c962e
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"CheckStyle-IDEA-Module"
>
<option
name=
"configuration"
>
<map
/>
</option>
</component>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
...
...
hmit-api/src/main/java/io/hmit/controller/WlUploadInfoController.java
View file @
a96c962e
...
...
@@ -4,6 +4,7 @@ package io.hmit.controller;
import
io.hmit.common.constant.Constant
;
import
io.hmit.common.page.PageData
;
import
io.hmit.annotation.LogOperation
;
import
io.hmit.common.utils.ConvertUtils
;
import
io.hmit.common.utils.Result
;
import
io.hmit.common.validator.AssertUtils
;
import
io.hmit.common.validator.ValidatorUtils
;
...
...
@@ -21,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
springfox.documentation.annotations.ApiIgnore
;
import
sun.net.www.content.text.plain
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -64,24 +66,55 @@ public class WlUploadInfoController {
return
new
Result
<
WlUploadInfoDTO
>().
ok
(
data
);
}
/*
@RequestParam 注解,默认 content-type:application/x-www-form-urlencoded;charset=UTF-8;
当Content-Type:只限于三个值application/x-www-form-urlencoded、multipart/form-data、text/plain
时,为简单请求,不会出现跨域的Option问题
*/
@PostMapping
@ApiOperation
(
"保存"
)
@LogOperation
(
"保存"
)
//@RequiresPermissions("competition:wluploadinfo:save")
public
Result
save
(
@RequestParam
Map
<
String
,
String
>
params
){
WlUploadInfoDTO
dto
=
new
WlUploadInfoDTO
().
assembleWluploadInfo
(
params
);
boolean
flag
=
wlUploadInfoService
.
isName
(
dto
.
getName
());
if
(
flag
){
wlUploadInfoService
.
save
(
dto
);
return
new
Result
();
}
else
{
return
new
Result
().
error
(
500
,
"人员信息已存在!"
);
}
}
/*
最后使用版本
前端使用json格式传输数据,SpringBoot @RequestBody 注解,默认只接收前端使用json进行传输
content-type:application/json;charset=UTF-8;
解决跨域问题,配置cors,前端访问接口使用域名访问,而不是IP+端口的形式
*/
@PostMapping
(
"/bodySave"
)
@ApiOperation
(
"保存"
)
@LogOperation
(
"保存"
)
//@RequiresPermissions("competition:wluploadinfo:save")
public
Result
save
(
@RequestBody
WlUploadInfoDTO
dto
){
//校验数据
ValidatorUtils
.
validateEntity
(
dto
,
AddGroup
.
class
,
DefaultGroup
.
class
);
boolean
flag
=
wlUploadInfoService
.
isName
(
dto
.
getName
());
if
(
flag
){
wlUploadInfoService
.
save
(
dto
);
return
new
Result
();
}
else
{
return
new
Result
().
error
();
return
new
Result
().
error
(
500
,
"人员信息已存在!"
);
}
}
@PutMapping
@ApiOperation
(
"修改"
)
...
...
hmit-api/src/main/java/io/hmit/dto/WlUploadInfoDTO.java
View file @
a96c962e
package
io
.
hmit
.
dto
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.Map
;
/**
...
...
@@ -65,5 +67,26 @@ public class WlUploadInfoDTO implements Serializable {
@ApiModelProperty
(
value
=
"修改时间"
)
private
Date
updateTime
;
}
\ No newline at end of file
public
WlUploadInfoDTO
assembleWluploadInfo
(
Map
<
String
,
String
>
params
){
WlUploadInfoDTO
wlUploadInfoDTO
=
new
WlUploadInfoDTO
();
wlUploadInfoDTO
.
setId
(
IdWorker
.
getId
());
wlUploadInfoDTO
.
setName
(
params
.
get
(
"name"
));
wlUploadInfoDTO
.
setSex
(
params
.
get
(
"sex"
));
wlUploadInfoDTO
.
setEmployer
(
params
.
get
(
"employer"
));
wlUploadInfoDTO
.
setJob
(
params
.
get
(
"job"
));
wlUploadInfoDTO
.
setEmail
(
params
.
get
(
"email"
));
wlUploadInfoDTO
.
setMember
(
params
.
get
(
"member"
));
wlUploadInfoDTO
.
setWithMember
(
params
.
get
(
"withMember"
));
wlUploadInfoDTO
.
setWithRelationship
(
params
.
get
(
"withRelationship"
));
wlUploadInfoDTO
.
setPhone
(
params
.
get
(
"phone"
));
wlUploadInfoDTO
.
setHeight
(
params
.
get
(
"height"
));
wlUploadInfoDTO
.
setWeight
(
params
.
get
(
"weight"
));
wlUploadInfoDTO
.
setDinner
(
params
.
get
(
"dinner"
));
wlUploadInfoDTO
.
setCreateTime
(
new
Date
());
wlUploadInfoDTO
.
setUpdateTime
(
new
Date
());
return
wlUploadInfoDTO
;
}
}
hmit-api/src/main/java/io/hmit/interceptor/CorsInterceptor.java
View file @
a96c962e
...
...
@@ -20,10 +20,12 @@ public class CorsInterceptor implements HandlerInterceptor {
response
.
setHeader
(
"Access-Control-Allow-Headers"
,
"*"
);
// 如果是OPTIONS则结束请求
/*
if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
response.setStatus(HttpStatus.NO_CONTENT.value());
return false;
}
*/
return
true
;
}
...
...
hmit-common/hmit-common.iml
View file @
a96c962e
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"CheckStyle-IDEA-Module"
>
<option
name=
"configuration"
>
<map
/>
</option>
</component>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
...
...
@@ -142,4 +147,4 @@
<orderEntry
type=
"library"
name=
"Maven: com.github.xiaoymin:swagger-bootstrap-ui:1.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.projectlombok:lombok:1.18.4"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
</module>
hmit-generator/hmit-generator.iml
View file @
a96c962e
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"CheckStyle-IDEA-Module"
>
<option
name=
"configuration"
>
<map
/>
</option>
</component>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
...
...
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