Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
900ca221
Commit
900ca221
authored
Dec 10, 2019
by
Elune
Browse files
代码优化
parent
a9e12b5c
Changes
26
Hide whitespace changes
Inline
Side-by-side
eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java
View file @
900ca221
...
@@ -26,13 +26,13 @@ public class GenConfigController {
...
@@ -26,13 +26,13 @@ public class GenConfigController {
@ApiOperation
(
"查询"
)
@ApiOperation
(
"查询"
)
@GetMapping
(
value
=
"/{tableName}"
)
@GetMapping
(
value
=
"/{tableName}"
)
public
ResponseEntity
get
(
@PathVariable
String
tableName
){
public
ResponseEntity
<
Object
>
get
(
@PathVariable
String
tableName
){
return
new
ResponseEntity
<>(
genConfigService
.
find
(
tableName
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
genConfigService
.
find
(
tableName
),
HttpStatus
.
OK
);
}
}
@ApiOperation
(
"修改"
)
@ApiOperation
(
"修改"
)
@PutMapping
@PutMapping
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
GenConfig
genConfig
){
public
ResponseEntity
<
Object
>
emailConfig
(
@Validated
@RequestBody
GenConfig
genConfig
){
return
new
ResponseEntity
<>(
genConfigService
.
update
(
genConfig
.
getTableName
(),
genConfig
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
genConfigService
.
update
(
genConfig
.
getTableName
(),
genConfig
),
HttpStatus
.
OK
);
}
}
}
}
eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java
View file @
900ca221
...
@@ -38,13 +38,13 @@ public class GeneratorController {
...
@@ -38,13 +38,13 @@ public class GeneratorController {
@ApiOperation
(
"查询数据库数据"
)
@ApiOperation
(
"查询数据库数据"
)
@GetMapping
(
value
=
"/tables/all"
)
@GetMapping
(
value
=
"/tables/all"
)
public
ResponseEntity
getTables
(){
public
ResponseEntity
<
Object
>
getTables
(){
return
new
ResponseEntity
<>(
generatorService
.
getTables
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
generatorService
.
getTables
(),
HttpStatus
.
OK
);
}
}
@ApiOperation
(
"查询数据库数据"
)
@ApiOperation
(
"查询数据库数据"
)
@GetMapping
(
value
=
"/tables"
)
@GetMapping
(
value
=
"/tables"
)
public
ResponseEntity
getTables
(
@RequestParam
(
defaultValue
=
""
)
String
name
,
public
ResponseEntity
<
Object
>
getTables
(
@RequestParam
(
defaultValue
=
""
)
String
name
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
size
){
@RequestParam
(
defaultValue
=
"10"
)
Integer
size
){
int
[]
startEnd
=
PageUtil
.
transToStartEnd
(
page
+
1
,
size
);
int
[]
startEnd
=
PageUtil
.
transToStartEnd
(
page
+
1
,
size
);
...
@@ -53,7 +53,7 @@ public class GeneratorController {
...
@@ -53,7 +53,7 @@ public class GeneratorController {
@ApiOperation
(
"查询字段数据"
)
@ApiOperation
(
"查询字段数据"
)
@GetMapping
(
value
=
"/columns"
)
@GetMapping
(
value
=
"/columns"
)
public
ResponseEntity
getTables
(
@RequestParam
String
tableName
){
public
ResponseEntity
<
Object
>
getTables
(
@RequestParam
String
tableName
){
List
<
ColumnInfo
>
columnInfos
=
generatorService
.
getColumns
(
tableName
);
List
<
ColumnInfo
>
columnInfos
=
generatorService
.
getColumns
(
tableName
);
// 异步同步表信息
// 异步同步表信息
generatorService
.
sync
(
columnInfos
);
generatorService
.
sync
(
columnInfos
);
...
@@ -62,14 +62,14 @@ public class GeneratorController {
...
@@ -62,14 +62,14 @@ public class GeneratorController {
@ApiOperation
(
"保存字段数据"
)
@ApiOperation
(
"保存字段数据"
)
@PutMapping
@PutMapping
public
ResponseEntity
save
(
@RequestBody
List
<
ColumnInfo
>
columnInfos
){
public
ResponseEntity
<
HttpStatus
>
save
(
@RequestBody
List
<
ColumnInfo
>
columnInfos
){
generatorService
.
save
(
columnInfos
);
generatorService
.
save
(
columnInfos
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
@ApiOperation
(
"生成代码"
)
@ApiOperation
(
"生成代码"
)
@PostMapping
(
value
=
"/{tableName}/{type}"
)
@PostMapping
(
value
=
"/{tableName}/{type}"
)
public
ResponseEntity
generator
(
@PathVariable
String
tableName
,
@PathVariable
Integer
type
,
HttpServletRequest
request
,
HttpServletResponse
response
){
public
ResponseEntity
<
Object
>
generator
(
@PathVariable
String
tableName
,
@PathVariable
Integer
type
,
HttpServletRequest
request
,
HttpServletResponse
response
){
if
(!
generatorEnabled
&&
type
==
0
){
if
(!
generatorEnabled
&&
type
==
0
){
throw
new
BadRequestException
(
"此环境不允许生成代码,请选择预览或者下载查看!"
);
throw
new
BadRequestException
(
"此环境不允许生成代码,请选择预览或者下载查看!"
);
}
}
...
@@ -84,6 +84,6 @@ public class GeneratorController {
...
@@ -84,6 +84,6 @@ public class GeneratorController {
break
;
break
;
default
:
throw
new
BadRequestException
(
"没有这个选项"
);
default
:
throw
new
BadRequestException
(
"没有这个选项"
);
}
}
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java
View file @
900ca221
...
@@ -61,14 +61,14 @@ public interface GeneratorService {
...
@@ -61,14 +61,14 @@ public interface GeneratorService {
* @param columns 字段信息
* @param columns 字段信息
* @return /
* @return /
*/
*/
ResponseEntity
preview
(
GenConfig
genConfig
,
List
<
ColumnInfo
>
columns
);
ResponseEntity
<
Object
>
preview
(
GenConfig
genConfig
,
List
<
ColumnInfo
>
columns
);
/**
/**
* 打包下载
* 打包下载
* @param genConfig 配置信息
* @param genConfig 配置信息
* @param columns 字段信息
* @param columns 字段信息
* @param request
* @param request
/
* @param response
* @param response
/
*/
*/
void
download
(
GenConfig
genConfig
,
List
<
ColumnInfo
>
columns
,
HttpServletRequest
request
,
HttpServletResponse
response
);
void
download
(
GenConfig
genConfig
,
List
<
ColumnInfo
>
columns
,
HttpServletRequest
request
,
HttpServletResponse
response
);
}
}
eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java
View file @
900ca221
...
@@ -27,10 +27,9 @@ public interface LogRepository extends JpaRepository<Log,Long>, JpaSpecification
...
@@ -27,10 +27,9 @@ public interface LogRepository extends JpaRepository<Log,Long>, JpaSpecification
/**
/**
* 根据日志类型删除信息
* 根据日志类型删除信息
* @param logType
* @param logType
日志类型
*/
*/
@Query
(
nativeQuery
=
true
,
value
=
"delete from log where log_type = ?1"
)
@Query
(
nativeQuery
=
true
,
value
=
"delete from log where log_type = ?1"
)
@Modifying
@Modifying
@Transactional
void
deleteByLogType
(
String
logType
);
void
deleteByLogType
(
String
logType
);
}
}
eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java
View file @
900ca221
...
@@ -11,7 +11,6 @@ import org.springframework.http.HttpStatus;
...
@@ -11,7 +11,6 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -50,14 +49,14 @@ public class LogController {
...
@@ -50,14 +49,14 @@ public class LogController {
@GetMapping
@GetMapping
@ApiOperation
(
"日志查询"
)
@ApiOperation
(
"日志查询"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
criteria
.
setLogType
(
"INFO"
);
criteria
.
setLogType
(
"INFO"
);
return
new
ResponseEntity
<>(
logService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
logService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
"/user"
)
@GetMapping
(
value
=
"/user"
)
@ApiOperation
(
"用户日志查询"
)
@ApiOperation
(
"用户日志查询"
)
public
ResponseEntity
getUserLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getUserLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
criteria
.
setLogType
(
"INFO"
);
criteria
.
setLogType
(
"INFO"
);
criteria
.
setBlurry
(
SecurityUtils
.
getUsername
());
criteria
.
setBlurry
(
SecurityUtils
.
getUsername
());
return
new
ResponseEntity
<>(
logService
.
queryAllByUser
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
logService
.
queryAllByUser
(
criteria
,
pageable
),
HttpStatus
.
OK
);
...
@@ -66,7 +65,7 @@ public class LogController {
...
@@ -66,7 +65,7 @@ public class LogController {
@GetMapping
(
value
=
"/error"
)
@GetMapping
(
value
=
"/error"
)
@ApiOperation
(
"错误日志查询"
)
@ApiOperation
(
"错误日志查询"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getErrorLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getErrorLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
criteria
.
setLogType
(
"ERROR"
);
criteria
.
setLogType
(
"ERROR"
);
return
new
ResponseEntity
<>(
logService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
logService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -74,24 +73,24 @@ public class LogController {
...
@@ -74,24 +73,24 @@ public class LogController {
@GetMapping
(
value
=
"/error/{id}"
)
@GetMapping
(
value
=
"/error/{id}"
)
@ApiOperation
(
"日志异常详情查询"
)
@ApiOperation
(
"日志异常详情查询"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getErrorLogs
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
getErrorLogs
(
@PathVariable
Long
id
){
return
new
ResponseEntity
<>(
logService
.
findByErrDetail
(
id
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
logService
.
findByErrDetail
(
id
),
HttpStatus
.
OK
);
}
}
@DeleteMapping
(
value
=
"/del/error"
)
@DeleteMapping
(
value
=
"/del/error"
)
@Log
(
"删除所有ERROR日志"
)
@Log
(
"删除所有ERROR日志"
)
@ApiOperation
(
"删除所有ERROR日志"
)
@ApiOperation
(
"删除所有ERROR日志"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
delAllByError
(){
public
ResponseEntity
<
Object
>
delAllByError
(){
logService
.
delAllByError
();
logService
.
delAllByError
();
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
@DeleteMapping
(
value
=
"/del/info"
)
@DeleteMapping
(
value
=
"/del/info"
)
@Log
(
"删除所有INFO日志"
)
@Log
(
"删除所有INFO日志"
)
@ApiOperation
(
"删除所有INFO日志"
)
@ApiOperation
(
"删除所有INFO日志"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
delAllByInfo
(){
public
ResponseEntity
<
Object
>
delAllByInfo
(){
logService
.
delAllByInfo
();
logService
.
delAllByInfo
();
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java
View file @
900ca221
...
@@ -183,7 +183,8 @@ public class DeployServiceImpl implements DeployService {
...
@@ -183,7 +183,8 @@ public class DeployServiceImpl implements DeployService {
private
void
backupApp
(
ExecuteShellUtil
executeShellUtil
,
String
ip
,
String
fileSavePath
,
String
appName
,
String
backupPath
,
Long
id
)
{
private
void
backupApp
(
ExecuteShellUtil
executeShellUtil
,
String
ip
,
String
fileSavePath
,
String
appName
,
String
backupPath
,
Long
id
)
{
String
deployDate
=
DateUtil
.
format
(
new
Date
(),
DatePattern
.
PURE_DATETIME_PATTERN
);
String
deployDate
=
DateUtil
.
format
(
new
Date
(),
DatePattern
.
PURE_DATETIME_PATTERN
);
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
if
(!
backupPath
.
endsWith
(
FILE_SEPARATOR
)&&!
backupPath
.
endsWith
(
"\\"
))
{
String
endsWith
=
"\\"
;
if
(!
backupPath
.
endsWith
(
FILE_SEPARATOR
)&&!
backupPath
.
endsWith
(
endsWith
))
{
backupPath
+=
FILE_SEPARATOR
;
backupPath
+=
FILE_SEPARATOR
;
}
}
backupPath
+=
appName
+
FILE_SEPARATOR
+
deployDate
+
"\n"
;
backupPath
+=
appName
+
FILE_SEPARATOR
+
deployDate
+
"\n"
;
...
@@ -259,8 +260,7 @@ public class DeployServiceImpl implements DeployService {
...
@@ -259,8 +260,7 @@ public class DeployServiceImpl implements DeployService {
}
}
private
boolean
checkFile
(
ExecuteShellUtil
executeShellUtil
,
AppDto
appDTO
)
{
private
boolean
checkFile
(
ExecuteShellUtil
executeShellUtil
,
AppDto
appDTO
)
{
StringBuilder
sb
=
new
StringBuilder
(
"find "
).
append
(
appDTO
.
getDeployPath
()).
append
(
" -name "
).
append
(
appDTO
.
getName
());
String
result
=
executeShellUtil
.
executeForResult
(
"find "
+
appDTO
.
getDeployPath
()
+
" -name "
+
appDTO
.
getName
());
String
result
=
executeShellUtil
.
executeForResult
(
sb
.
toString
());
return
result
.
indexOf
(
"/tcp:"
)>
0
;
return
result
.
indexOf
(
"/tcp:"
)>
0
;
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java
View file @
900ca221
...
@@ -32,7 +32,7 @@ public class ServerController {
...
@@ -32,7 +32,7 @@ public class ServerController {
@Log
(
"查询服务监控"
)
@Log
(
"查询服务监控"
)
@ApiOperation
(
"查询服务监控"
)
@ApiOperation
(
"查询服务监控"
)
@PreAuthorize
(
"@el.check('server:list')"
)
@PreAuthorize
(
"@el.check('server:list')"
)
public
ResponseEntity
getServers
(
ServerQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getServers
(
ServerQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
serverService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
serverService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -40,7 +40,7 @@ public class ServerController {
...
@@ -40,7 +40,7 @@ public class ServerController {
@Log
(
"新增服务监控"
)
@Log
(
"新增服务监控"
)
@ApiOperation
(
"新增服务监控"
)
@ApiOperation
(
"新增服务监控"
)
@PreAuthorize
(
"@el.check('server:add')"
)
@PreAuthorize
(
"@el.check('server:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Server
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Server
resources
){
return
new
ResponseEntity
<>(
serverService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>(
serverService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
}
...
@@ -48,9 +48,9 @@ public class ServerController {
...
@@ -48,9 +48,9 @@ public class ServerController {
@Log
(
"修改服务监控"
)
@Log
(
"修改服务监控"
)
@ApiOperation
(
"修改服务监控"
)
@ApiOperation
(
"修改服务监控"
)
@PreAuthorize
(
"@el.check('server:edit')"
)
@PreAuthorize
(
"@el.check('server:edit')"
)
public
ResponseEntity
update
(
@Validated
@RequestBody
Server
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
Server
resources
){
serverService
.
update
(
resources
);
serverService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java
View file @
900ca221
...
@@ -28,20 +28,20 @@ public class VisitsController {
...
@@ -28,20 +28,20 @@ public class VisitsController {
@PostMapping
@PostMapping
@ApiOperation
(
"创建访问记录"
)
@ApiOperation
(
"创建访问记录"
)
public
ResponseEntity
create
(){
public
ResponseEntity
<
Object
>
create
(){
visitsService
.
count
(
RequestHolder
.
getHttpServletRequest
());
visitsService
.
count
(
RequestHolder
.
getHttpServletRequest
());
return
new
ResponseEntity
(
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
HttpStatus
.
CREATED
);
}
}
@GetMapping
@GetMapping
@ApiOperation
(
"查询"
)
@ApiOperation
(
"查询"
)
public
ResponseEntity
get
(){
public
ResponseEntity
<
Object
>
get
(){
return
new
ResponseEntity
<>(
visitsService
.
get
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
visitsService
.
get
(),
HttpStatus
.
OK
);
}
}
@GetMapping
(
value
=
"/chartData"
)
@GetMapping
(
value
=
"/chartData"
)
@ApiOperation
(
"查询图表数据"
)
@ApiOperation
(
"查询图表数据"
)
public
ResponseEntity
getChartData
(){
public
ResponseEntity
<
Object
>
getChartData
(){
return
new
ResponseEntity
<>(
visitsService
.
getChartData
(),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
visitsService
.
getChartData
(),
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java
View file @
900ca221
...
@@ -40,7 +40,7 @@ public class QuartzJobController {
...
@@ -40,7 +40,7 @@ public class QuartzJobController {
@ApiOperation
(
"查询定时任务"
)
@ApiOperation
(
"查询定时任务"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('timing:list')"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
public
ResponseEntity
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
quartzJobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
quartzJobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -63,7 +63,7 @@ public class QuartzJobController {
...
@@ -63,7 +63,7 @@ public class QuartzJobController {
@ApiOperation
(
"查询任务执行日志"
)
@ApiOperation
(
"查询任务执行日志"
)
@GetMapping
(
value
=
"/logs"
)
@GetMapping
(
value
=
"/logs"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
public
ResponseEntity
getJobLogs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getJobLogs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
quartzJobService
.
queryAllLog
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
quartzJobService
.
queryAllLog
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -71,7 +71,7 @@ public class QuartzJobController {
...
@@ -71,7 +71,7 @@ public class QuartzJobController {
@ApiOperation
(
"新增定时任务"
)
@ApiOperation
(
"新增定时任务"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('timing:add')"
)
@PreAuthorize
(
"@el.check('timing:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
QuartzJob
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
QuartzJob
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -82,35 +82,35 @@ public class QuartzJobController {
...
@@ -82,35 +82,35 @@ public class QuartzJobController {
@ApiOperation
(
"修改定时任务"
)
@ApiOperation
(
"修改定时任务"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('timing:edit')"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
public
ResponseEntity
update
(
@Validated
(
QuartzJob
.
Update
.
class
)
@RequestBody
QuartzJob
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
QuartzJob
.
Update
.
class
)
@RequestBody
QuartzJob
resources
){
quartzJobService
.
update
(
resources
);
quartzJobService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"更改定时任务状态"
)
@Log
(
"更改定时任务状态"
)
@ApiOperation
(
"更改定时任务状态"
)
@ApiOperation
(
"更改定时任务状态"
)
@PutMapping
(
value
=
"/{id}"
)
@PutMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
public
ResponseEntity
updateIsPause
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
updateIsPause
(
@PathVariable
Long
id
){
quartzJobService
.
updateIsPause
(
quartzJobService
.
findById
(
id
));
quartzJobService
.
updateIsPause
(
quartzJobService
.
findById
(
id
));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"执行定时任务"
)
@Log
(
"执行定时任务"
)
@ApiOperation
(
"执行定时任务"
)
@ApiOperation
(
"执行定时任务"
)
@PutMapping
(
value
=
"/exec/{id}"
)
@PutMapping
(
value
=
"/exec/{id}"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
public
ResponseEntity
execution
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
execution
(
@PathVariable
Long
id
){
quartzJobService
.
execution
(
quartzJobService
.
findById
(
id
));
quartzJobService
.
execution
(
quartzJobService
.
findById
(
id
));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除定时任务"
)
@Log
(
"删除定时任务"
)
@ApiOperation
(
"删除定时任务"
)
@ApiOperation
(
"删除定时任务"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('timing:del')"
)
@PreAuthorize
(
"@el.check('timing:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
quartzJobService
.
delete
(
quartzJobService
.
findById
(
id
));
quartzJobService
.
delete
(
quartzJobService
.
findById
(
id
));
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthController.java
View file @
900ca221
...
@@ -70,7 +70,7 @@ public class AuthController {
...
@@ -70,7 +70,7 @@ public class AuthController {
@ApiOperation
(
"登录授权"
)
@ApiOperation
(
"登录授权"
)
@AnonymousAccess
@AnonymousAccess
@PostMapping
(
value
=
"/login"
)
@PostMapping
(
value
=
"/login"
)
public
ResponseEntity
login
(
@Validated
@RequestBody
AuthUser
authUser
,
HttpServletRequest
request
){
public
ResponseEntity
<
Object
>
login
(
@Validated
@RequestBody
AuthUser
authUser
,
HttpServletRequest
request
){
// 密码解密
// 密码解密
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
String
password
=
new
String
(
rsa
.
decrypt
(
authUser
.
getPassword
(),
KeyType
.
PrivateKey
));
String
password
=
new
String
(
rsa
.
decrypt
(
authUser
.
getPassword
(),
KeyType
.
PrivateKey
));
...
@@ -108,7 +108,7 @@ public class AuthController {
...
@@ -108,7 +108,7 @@ public class AuthController {
@ApiOperation
(
"获取用户信息"
)
@ApiOperation
(
"获取用户信息"
)
@GetMapping
(
value
=
"/info"
)
@GetMapping
(
value
=
"/info"
)
public
ResponseEntity
getUserInfo
(){
public
ResponseEntity
<
Object
>
getUserInfo
(){
JwtUser
jwtUser
=
(
JwtUser
)
userDetailsService
.
loadUserByUsername
(
SecurityUtils
.
getUsername
());
JwtUser
jwtUser
=
(
JwtUser
)
userDetailsService
.
loadUserByUsername
(
SecurityUtils
.
getUsername
());
return
ResponseEntity
.
ok
(
jwtUser
);
return
ResponseEntity
.
ok
(
jwtUser
);
}
}
...
@@ -116,7 +116,7 @@ public class AuthController {
...
@@ -116,7 +116,7 @@ public class AuthController {
@AnonymousAccess
@AnonymousAccess
@ApiOperation
(
"获取验证码"
)
@ApiOperation
(
"获取验证码"
)
@GetMapping
(
value
=
"/code"
)
@GetMapping
(
value
=
"/code"
)
public
ResponseEntity
getCode
(){
public
ResponseEntity
<
Object
>
getCode
(){
// 算术类型 https://gitee.com/whvse/EasyCaptcha
// 算术类型 https://gitee.com/whvse/EasyCaptcha
ArithmeticCaptcha
captcha
=
new
ArithmeticCaptcha
(
111
,
36
);
ArithmeticCaptcha
captcha
=
new
ArithmeticCaptcha
(
111
,
36
);
// 几位数运算,默认是两位
// 几位数运算,默认是两位
...
@@ -137,8 +137,8 @@ public class AuthController {
...
@@ -137,8 +137,8 @@ public class AuthController {
@ApiOperation
(
"退出登录"
)
@ApiOperation
(
"退出登录"
)
@AnonymousAccess
@AnonymousAccess
@DeleteMapping
(
value
=
"/logout"
)
@DeleteMapping
(
value
=
"/logout"
)
public
ResponseEntity
logout
(
HttpServletRequest
request
){
public
ResponseEntity
<
Object
>
logout
(
HttpServletRequest
request
){
onlineUserService
.
logout
(
tokenProvider
.
getToken
(
request
));
onlineUserService
.
logout
(
tokenProvider
.
getToken
(
request
));
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java
View file @
900ca221
...
@@ -30,7 +30,7 @@ public class OnlineController {
...
@@ -30,7 +30,7 @@ public class OnlineController {
@ApiOperation
(
"查询在线用户"
)
@ApiOperation
(
"查询在线用户"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getAll
(
String
filter
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getAll
(
String
filter
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
onlineUserService
.
getAll
(
filter
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
onlineUserService
.
getAll
(
filter
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -45,8 +45,8 @@ public class OnlineController {
...
@@ -45,8 +45,8 @@ public class OnlineController {
@ApiOperation
(
"踢出用户"
)
@ApiOperation
(
"踢出用户"
)
@DeleteMapping
(
value
=
"/{key}"
)
@DeleteMapping
(
value
=
"/{key}"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
delete
(
@PathVariable
String
key
)
throws
Exception
{
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
String
key
)
throws
Exception
{
onlineUserService
.
kickOut
(
key
);
onlineUserService
.
kickOut
(
key
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java
View file @
900ca221
...
@@ -136,7 +136,7 @@ public class OnlineUserService {
...
@@ -136,7 +136,7 @@ public class OnlineUserService {
/**
/**
* 检测用户是否在之前已经登录,已经登录踢下线
* 检测用户是否在之前已经登录,已经登录踢下线
* @param userName
* @param userName
用户名
*/
*/
public
void
checkLoginOnUser
(
String
userName
,
String
igoreToken
){
public
void
checkLoginOnUser
(
String
userName
,
String
igoreToken
){
List
<
OnlineUser
>
onlineUsers
=
getAll
(
userName
);
List
<
OnlineUser
>
onlineUsers
=
getAll
(
userName
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java
View file @
900ca221
...
@@ -15,7 +15,6 @@ import org.springframework.http.ResponseEntity;
...
@@ -15,7 +15,6 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
...
@@ -52,7 +51,7 @@ public class DeptController {
...
@@ -52,7 +51,7 @@ public class DeptController {
@ApiOperation
(
"查询部门"
)
@ApiOperation
(
"查询部门"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('user:list','dept:list')"
)
@PreAuthorize
(
"@el.check('user:list','dept:list')"
)
public
ResponseEntity
getDepts
(
DeptQueryCriteria
criteria
){
public
ResponseEntity
<
Object
>
getDepts
(
DeptQueryCriteria
criteria
){
// 数据权限
// 数据权限
criteria
.
setIds
(
dataScope
.
getDeptIds
());
criteria
.
setIds
(
dataScope
.
getDeptIds
());
List
<
DeptDto
>
deptDtos
=
deptService
.
queryAll
(
criteria
);
List
<
DeptDto
>
deptDtos
=
deptService
.
queryAll
(
criteria
);
...
@@ -63,7 +62,7 @@ public class DeptController {
...
@@ -63,7 +62,7 @@ public class DeptController {
@ApiOperation
(
"新增部门"
)
@ApiOperation
(
"新增部门"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('dept:add')"
)
@PreAuthorize
(
"@el.check('dept:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Dept
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Dept
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -74,21 +73,21 @@ public class DeptController {
...
@@ -74,21 +73,21 @@ public class DeptController {
@ApiOperation
(
"修改部门"
)
@ApiOperation
(
"修改部门"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('dept:edit')"
)
@PreAuthorize
(
"@el.check('dept:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Dept
.
Update
.
class
)
@RequestBody
Dept
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
Dept
.
Update
.
class
)
@RequestBody
Dept
resources
){
deptService
.
update
(
resources
);
deptService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除部门"
)
@Log
(
"删除部门"
)
@ApiOperation
(
"删除部门"
)
@ApiOperation
(
"删除部门"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dept:del')"
)
@PreAuthorize
(
"@el.check('dept:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
try
{
try
{
deptService
.
delete
(
id
);
deptService
.
delete
(
id
);
}
catch
(
Throwable
e
){
}
catch
(
Throwable
e
){
ThrowableUtil
.
throwForeignKeyException
(
e
,
"该部门存在岗位或者角色关联,请取消关联后再试"
);
ThrowableUtil
.
throwForeignKeyException
(
e
,
"该部门存在岗位或者角色关联,请取消关联后再试"
);
}
}
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java
View file @
900ca221
...
@@ -46,7 +46,7 @@ public class DictController {
...
@@ -46,7 +46,7 @@ public class DictController {
@ApiOperation
(
"查询字典"
)
@ApiOperation
(
"查询字典"
)
@GetMapping
(
value
=
"/all"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('dict:list')"
)
@PreAuthorize
(
"@el.check('dict:list')"
)
public
ResponseEntity
all
(){
public
ResponseEntity
<
Object
>
all
(){
return
new
ResponseEntity
<>(
dictService
.
queryAll
(
new
DictQueryCriteria
()),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
dictService
.
queryAll
(
new
DictQueryCriteria
()),
HttpStatus
.
OK
);
}
}
...
@@ -54,7 +54,7 @@ public class DictController {
...
@@ -54,7 +54,7 @@ public class DictController {
@ApiOperation
(
"查询字典"
)
@ApiOperation
(
"查询字典"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('dict:list')"
)
@PreAuthorize
(
"@el.check('dict:list')"
)
public
ResponseEntity
getDicts
(
DictQueryCriteria
resources
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getDicts
(
DictQueryCriteria
resources
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
dictService
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
dictService
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -62,7 +62,7 @@ public class DictController {
...
@@ -62,7 +62,7 @@ public class DictController {
@ApiOperation
(
"新增字典"
)
@ApiOperation
(
"新增字典"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('dict:add')"
)
@PreAuthorize
(
"@el.check('dict:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Dict
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Dict
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -73,17 +73,17 @@ public class DictController {
...
@@ -73,17 +73,17 @@ public class DictController {
@ApiOperation
(
"修改字典"
)
@ApiOperation
(
"修改字典"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('dict:edit')"
)
@PreAuthorize
(
"@el.check('dict:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Dict
.
Update
.
class
)
@RequestBody
Dict
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
Dict
.
Update
.
class
)
@RequestBody
Dict
resources
){
dictService
.
update
(
resources
);
dictService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除字典"
)
@Log
(
"删除字典"
)
@ApiOperation
(
"删除字典"
)
@ApiOperation
(
"删除字典"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
dictService
.
delete
(
id
);
dictService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java
View file @
900ca221
...
@@ -38,7 +38,7 @@ public class DictDetailController {
...
@@ -38,7 +38,7 @@ public class DictDetailController {
@Log
(
"查询字典详情"
)
@Log
(
"查询字典详情"
)
@ApiOperation
(
"查询字典详情"
)
@ApiOperation
(
"查询字典详情"
)
@GetMapping
@GetMapping
public
ResponseEntity
getDictDetails
(
DictDetailQueryCriteria
criteria
,
public
ResponseEntity
<
Object
>
getDictDetails
(
DictDetailQueryCriteria
criteria
,
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
<>(
dictDetailService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
dictDetailService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -46,7 +46,7 @@ public class DictDetailController {
...
@@ -46,7 +46,7 @@ public class DictDetailController {
@Log
(
"查询多个字典详情"
)
@Log
(
"查询多个字典详情"
)
@ApiOperation
(
"查询多个字典详情"
)
@ApiOperation
(
"查询多个字典详情"
)
@GetMapping
(
value
=
"/map"
)
@GetMapping
(
value
=
"/map"
)
public
ResponseEntity
getDictDetailMaps
(
DictDetailQueryCriteria
criteria
,
public
ResponseEntity
<
Object
>
getDictDetailMaps
(
DictDetailQueryCriteria
criteria
,
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
String
[]
names
=
criteria
.
getDictName
().
split
(
","
);
String
[]
names
=
criteria
.
getDictName
().
split
(
","
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
names
.
length
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
names
.
length
);
...
@@ -61,7 +61,7 @@ public class DictDetailController {
...
@@ -61,7 +61,7 @@ public class DictDetailController {
@ApiOperation
(
"新增字典详情"
)
@ApiOperation
(
"新增字典详情"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('dict:add')"
)
@PreAuthorize
(
"@el.check('dict:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
DictDetail
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
DictDetail
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -72,17 +72,17 @@ public class DictDetailController {
...
@@ -72,17 +72,17 @@ public class DictDetailController {
@ApiOperation
(
"修改字典详情"
)
@ApiOperation
(
"修改字典详情"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('dict:edit')"
)
@PreAuthorize
(
"@el.check('dict:edit')"
)
public
ResponseEntity
update
(
@Validated
(
DictDetail
.
Update
.
class
)
@RequestBody
DictDetail
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
DictDetail
.
Update
.
class
)
@RequestBody
DictDetail
resources
){
dictDetailService
.
update
(
resources
);
dictDetailService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除字典详情"
)
@Log
(
"删除字典详情"
)
@ApiOperation
(
"删除字典详情"
)
@ApiOperation
(
"删除字典详情"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
dictDetailService
.
delete
(
id
);
dictDetailService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java
View file @
900ca221
...
@@ -52,7 +52,7 @@ public class JobController {
...
@@ -52,7 +52,7 @@ public class JobController {
@ApiOperation
(
"查询岗位"
)
@ApiOperation
(
"查询岗位"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('job:list','user:list')"
)
@PreAuthorize
(
"@el.check('job:list','user:list')"
)
public
ResponseEntity
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
// 数据权限
// 数据权限
criteria
.
setDeptIds
(
dataScope
.
getDeptIds
());
criteria
.
setDeptIds
(
dataScope
.
getDeptIds
());
return
new
ResponseEntity
<>(
jobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
jobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
...
@@ -62,7 +62,7 @@ public class JobController {
...
@@ -62,7 +62,7 @@ public class JobController {
@ApiOperation
(
"新增岗位"
)
@ApiOperation
(
"新增岗位"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('job:add')"
)
@PreAuthorize
(
"@el.check('job:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Job
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Job
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -73,21 +73,21 @@ public class JobController {
...
@@ -73,21 +73,21 @@ public class JobController {
@ApiOperation
(
"修改岗位"
)
@ApiOperation
(
"修改岗位"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('job:edit')"
)
@PreAuthorize
(
"@el.check('job:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Job
.
Update
.
class
)
@RequestBody
Job
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
Job
.
Update
.
class
)
@RequestBody
Job
resources
){
jobService
.
update
(
resources
);
jobService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除岗位"
)
@Log
(
"删除岗位"
)
@ApiOperation
(
"删除岗位"
)
@ApiOperation
(
"删除岗位"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('job:del')"
)
@PreAuthorize
(
"@el.check('job:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
try
{
try
{
jobService
.
delete
(
id
);
jobService
.
delete
(
id
);
}
catch
(
Throwable
e
){
}
catch
(
Throwable
e
){
ThrowableUtil
.
throwForeignKeyException
(
e
,
"该岗位存在用户关联,请取消关联后再试"
);
ThrowableUtil
.
throwForeignKeyException
(
e
,
"该岗位存在用户关联,请取消关联后再试"
);
}
}
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java
View file @
900ca221
...
@@ -58,7 +58,7 @@ public class MenuController {
...
@@ -58,7 +58,7 @@ public class MenuController {
@ApiOperation
(
"获取前端所需菜单"
)
@ApiOperation
(
"获取前端所需菜单"
)
@GetMapping
(
value
=
"/build"
)
@GetMapping
(
value
=
"/build"
)
public
ResponseEntity
buildMenus
(){
public
ResponseEntity
<
Object
>
buildMenus
(){
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
List
<
MenuDto
>
menuDtoList
=
menuService
.
findByRoles
(
roleService
.
findByUsersId
(
user
.
getId
()));
List
<
MenuDto
>
menuDtoList
=
menuService
.
findByRoles
(
roleService
.
findByUsersId
(
user
.
getId
()));
List
<
MenuDto
>
menuDtos
=
(
List
<
MenuDto
>)
menuService
.
buildTree
(
menuDtoList
).
get
(
"content"
);
List
<
MenuDto
>
menuDtos
=
(
List
<
MenuDto
>)
menuService
.
buildTree
(
menuDtoList
).
get
(
"content"
);
...
@@ -68,7 +68,7 @@ public class MenuController {
...
@@ -68,7 +68,7 @@ public class MenuController {
@ApiOperation
(
"返回全部的菜单"
)
@ApiOperation
(
"返回全部的菜单"
)
@GetMapping
(
value
=
"/tree"
)
@GetMapping
(
value
=
"/tree"
)
@PreAuthorize
(
"@el.check('menu:list','roles:list')"
)
@PreAuthorize
(
"@el.check('menu:list','roles:list')"
)
public
ResponseEntity
getMenuTree
(){
public
ResponseEntity
<
Object
>
getMenuTree
(){
return
new
ResponseEntity
<>(
menuService
.
getMenuTree
(
menuService
.
findByPid
(
0L
)),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
menuService
.
getMenuTree
(
menuService
.
findByPid
(
0L
)),
HttpStatus
.
OK
);
}
}
...
@@ -76,7 +76,7 @@ public class MenuController {
...
@@ -76,7 +76,7 @@ public class MenuController {
@ApiOperation
(
"查询菜单"
)
@ApiOperation
(
"查询菜单"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('menu:list')"
)
@PreAuthorize
(
"@el.check('menu:list')"
)
public
ResponseEntity
getMenus
(
MenuQueryCriteria
criteria
){
public
ResponseEntity
<
Object
>
getMenus
(
MenuQueryCriteria
criteria
){
List
<
MenuDto
>
menuDtoList
=
menuService
.
queryAll
(
criteria
);
List
<
MenuDto
>
menuDtoList
=
menuService
.
queryAll
(
criteria
);
return
new
ResponseEntity
<>(
menuService
.
buildTree
(
menuDtoList
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
menuService
.
buildTree
(
menuDtoList
),
HttpStatus
.
OK
);
}
}
...
@@ -85,7 +85,7 @@ public class MenuController {
...
@@ -85,7 +85,7 @@ public class MenuController {
@ApiOperation
(
"新增菜单"
)
@ApiOperation
(
"新增菜单"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('menu:add')"
)
@PreAuthorize
(
"@el.check('menu:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Menu
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Menu
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -96,21 +96,21 @@ public class MenuController {
...
@@ -96,21 +96,21 @@ public class MenuController {
@ApiOperation
(
"修改菜单"
)
@ApiOperation
(
"修改菜单"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('menu:edit')"
)
@PreAuthorize
(
"@el.check('menu:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Menu
.
Update
.
class
)
@RequestBody
Menu
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
Menu
.
Update
.
class
)
@RequestBody
Menu
resources
){
menuService
.
update
(
resources
);
menuService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除菜单"
)
@Log
(
"删除菜单"
)
@ApiOperation
(
"删除菜单"
)
@ApiOperation
(
"删除菜单"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('menu:del')"
)
@PreAuthorize
(
"@el.check('menu:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
List
<
Menu
>
menuList
=
menuService
.
findByPid
(
id
);
List
<
Menu
>
menuList
=
menuService
.
findByPid
(
id
);
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
menuSet
.
add
(
menuService
.
findOne
(
id
));
menuSet
.
add
(
menuService
.
findOne
(
id
));
menuSet
=
menuService
.
getDeleteMenus
(
menuList
,
menuSet
);
menuSet
=
menuService
.
getDeleteMenus
(
menuList
,
menuSet
);
menuService
.
delete
(
menuSet
);
menuService
.
delete
(
menuSet
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java
View file @
900ca221
...
@@ -50,7 +50,7 @@ public class RoleController {
...
@@ -50,7 +50,7 @@ public class RoleController {
@ApiOperation
(
"获取单个role"
)
@ApiOperation
(
"获取单个role"
)
@GetMapping
(
value
=
"/{id}"
)
@GetMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('roles:list')"
)
@PreAuthorize
(
"@el.check('roles:list')"
)
public
ResponseEntity
getRoles
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
getRoles
(
@PathVariable
Long
id
){
return
new
ResponseEntity
<>(
roleService
.
findById
(
id
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
roleService
.
findById
(
id
),
HttpStatus
.
OK
);
}
}
...
@@ -65,7 +65,7 @@ public class RoleController {
...
@@ -65,7 +65,7 @@ public class RoleController {
@ApiOperation
(
"返回全部的角色"
)
@ApiOperation
(
"返回全部的角色"
)
@GetMapping
(
value
=
"/all"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('roles:list','user:add','user:edit')"
)
@PreAuthorize
(
"@el.check('roles:list','user:add','user:edit')"
)
public
ResponseEntity
getAll
(
@PageableDefault
(
value
=
2000
,
sort
=
{
"level"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getAll
(
@PageableDefault
(
value
=
2000
,
sort
=
{
"level"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
<>(
roleService
.
queryAll
(
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
roleService
.
queryAll
(
pageable
),
HttpStatus
.
OK
);
}
}
...
@@ -73,13 +73,13 @@ public class RoleController {
...
@@ -73,13 +73,13 @@ public class RoleController {
@ApiOperation
(
"查询角色"
)
@ApiOperation
(
"查询角色"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('roles:list')"
)
@PreAuthorize
(
"@el.check('roles:list')"
)
public
ResponseEntity
getRoles
(
RoleQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getRoles
(
RoleQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
<>(
roleService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
roleService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
@ApiOperation
(
"获取用户级别"
)
@ApiOperation
(
"获取用户级别"
)
@GetMapping
(
value
=
"/level"
)
@GetMapping
(
value
=
"/level"
)
public
ResponseEntity
getLevel
(){
public
ResponseEntity
<
Object
>
getLevel
(){
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
List
<
Integer
>
levels
=
roleService
.
findByUsersId
(
user
.
getId
()).
stream
().
map
(
RoleSmallDto:
:
getLevel
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
levels
=
roleService
.
findByUsersId
(
user
.
getId
()).
stream
().
map
(
RoleSmallDto:
:
getLevel
).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
Dict
.
create
().
set
(
"level"
,
Collections
.
min
(
levels
)),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
Dict
.
create
().
set
(
"level"
,
Collections
.
min
(
levels
)),
HttpStatus
.
OK
);
...
@@ -89,7 +89,7 @@ public class RoleController {
...
@@ -89,7 +89,7 @@ public class RoleController {
@ApiOperation
(
"新增角色"
)
@ApiOperation
(
"新增角色"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('roles:add')"
)
@PreAuthorize
(
"@el.check('roles:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Role
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Role
resources
){
if
(
resources
.
getId
()
!=
null
)
{
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
}
...
@@ -100,30 +100,30 @@ public class RoleController {
...
@@ -100,30 +100,30 @@ public class RoleController {
@ApiOperation
(
"修改角色"
)
@ApiOperation
(
"修改角色"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('roles:edit')"
)
@PreAuthorize
(
"@el.check('roles:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Role
.
Update
.
class
)
@RequestBody
Role
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
Role
.
Update
.
class
)
@RequestBody
Role
resources
){
roleService
.
update
(
resources
);
roleService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"修改角色菜单"
)
@Log
(
"修改角色菜单"
)
@ApiOperation
(
"修改角色菜单"
)
@ApiOperation
(
"修改角色菜单"
)
@PutMapping
(
value
=
"/menu"
)
@PutMapping
(
value
=
"/menu"
)
@PreAuthorize
(
"@el.check('roles:edit')"
)
@PreAuthorize
(
"@el.check('roles:edit')"
)
public
ResponseEntity
updateMenu
(
@RequestBody
Role
resources
){
public
ResponseEntity
<
Object
>
updateMenu
(
@RequestBody
Role
resources
){
roleService
.
updateMenu
(
resources
,
roleService
.
findById
(
resources
.
getId
()));
roleService
.
updateMenu
(
resources
,
roleService
.
findById
(
resources
.
getId
()));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除角色"
)
@Log
(
"删除角色"
)
@ApiOperation
(
"删除角色"
)
@ApiOperation
(
"删除角色"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('roles:del')"
)
@PreAuthorize
(
"@el.check('roles:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
try
{
try
{
roleService
.
delete
(
id
);
roleService
.
delete
(
id
);
}
catch
(
Throwable
e
){
}
catch
(
Throwable
e
){
ThrowableUtil
.
throwForeignKeyException
(
e
,
"该角色存在用户关联,请取消关联后再试"
);
ThrowableUtil
.
throwForeignKeyException
(
e
,
"该角色存在用户关联,请取消关联后再试"
);
}
}
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
900ca221
...
@@ -73,7 +73,7 @@ public class UserController {
...
@@ -73,7 +73,7 @@ public class UserController {
@ApiOperation
(
"查询用户"
)
@ApiOperation
(
"查询用户"
)
@GetMapping
@GetMapping
@PreAuthorize
(
"@el.check('user:list')"
)
@PreAuthorize
(
"@el.check('user:list')"
)
public
ResponseEntity
getUsers
(
UserQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getUsers
(
UserQueryCriteria
criteria
,
Pageable
pageable
){
Set
<
Long
>
deptSet
=
new
HashSet
<>();
Set
<
Long
>
deptSet
=
new
HashSet
<>();
Set
<
Long
>
result
=
new
HashSet
<>();
Set
<
Long
>
result
=
new
HashSet
<>();
if
(!
ObjectUtils
.
isEmpty
(
criteria
.
getDeptId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
criteria
.
getDeptId
()))
{
...
@@ -107,7 +107,7 @@ public class UserController {
...
@@ -107,7 +107,7 @@ public class UserController {
@ApiOperation
(
"新增用户"
)
@ApiOperation
(
"新增用户"
)
@PostMapping
@PostMapping
@PreAuthorize
(
"@el.check('user:add')"
)
@PreAuthorize
(
"@el.check('user:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
User
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
User
resources
){
checkLevel
(
resources
);
checkLevel
(
resources
);
// 默认密码 123456
// 默认密码 123456
resources
.
setPassword
(
passwordEncoder
.
encode
(
"123456"
));
resources
.
setPassword
(
passwordEncoder
.
encode
(
"123456"
));
...
@@ -118,29 +118,29 @@ public class UserController {
...
@@ -118,29 +118,29 @@ public class UserController {
@ApiOperation
(
"修改用户"
)
@ApiOperation
(
"修改用户"
)
@PutMapping
@PutMapping
@PreAuthorize
(
"@el.check('user:edit')"
)
@PreAuthorize
(
"@el.check('user:edit')"
)
public
ResponseEntity
update
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
checkLevel
(
resources
);
checkLevel
(
resources
);
userService
.
update
(
resources
);
userService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"修改用户:个人中心"
)
@Log
(
"修改用户:个人中心"
)
@ApiOperation
(
"修改用户:个人中心"
)
@ApiOperation
(
"修改用户:个人中心"
)
@PutMapping
(
value
=
"center"
)
@PutMapping
(
value
=
"center"
)
public
ResponseEntity
center
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
public
ResponseEntity
<
Object
>
center
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
UserDto
userDto
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
UserDto
userDto
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
if
(!
resources
.
getId
().
equals
(
userDto
.
getId
())){
if
(!
resources
.
getId
().
equals
(
userDto
.
getId
())){
throw
new
BadRequestException
(
"不能修改他人资料"
);
throw
new
BadRequestException
(
"不能修改他人资料"
);
}
}
userService
.
updateCenter
(
resources
);
userService
.
updateCenter
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
}
@Log
(
"删除用户"
)
@Log
(
"删除用户"
)
@ApiOperation
(
"删除用户"
)
@ApiOperation
(
"删除用户"
)
@DeleteMapping
(
value
=
"/{id}"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('user:del')"
)
@PreAuthorize
(
"@el.check('user:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
Integer
currentLevel
=
Collections
.
min
(
roleService
.
findByUsersId
(
user
.
getId
()).
stream
().
map
(
RoleSmallDto:
:
getLevel
).
collect
(
Collectors
.
toList
()));
Integer
currentLevel
=
Collections
.
min
(
roleService
.
findByUsersId
(
user
.
getId
()).
stream
().
map
(
RoleSmallDto:
:
getLevel
).
collect
(
Collectors
.
toList
()));
Integer
optLevel
=
Collections
.
min
(
roleService
.
findByUsersId
(
id
).
stream
().
map
(
RoleSmallDto:
:
getLevel
).
collect
(
Collectors
.
toList
()));
Integer
optLevel
=
Collections
.
min
(
roleService
.
findByUsersId
(
id
).
stream
().
map
(
RoleSmallDto:
:
getLevel
).
collect
(
Collectors
.
toList
()));
...
@@ -149,12 +149,12 @@ public class UserController {
...
@@ -149,12 +149,12 @@ public class UserController {
throw
new
BadRequestException
(
"角色权限不足"
);
throw
new
BadRequestException
(
"角色权限不足"
);
}
}
userService
.
delete
(
id
);
userService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
@ApiOperation
(
"修改密码"
)
@ApiOperation
(
"修改密码"
)
@PostMapping
(
value
=
"/updatePass"
)
@PostMapping
(
value
=
"/updatePass"
)
public
ResponseEntity
updatePass
(
@RequestBody
UserPassVo
passVo
){
public
ResponseEntity
<
Object
>
updatePass
(
@RequestBody
UserPassVo
passVo
){
// 密码解密
// 密码解密
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
String
oldPass
=
new
String
(
rsa
.
decrypt
(
passVo
.
getOldPass
(),
KeyType
.
PrivateKey
));
String
oldPass
=
new
String
(
rsa
.
decrypt
(
passVo
.
getOldPass
(),
KeyType
.
PrivateKey
));
...
@@ -167,20 +167,20 @@ public class UserController {
...
@@ -167,20 +167,20 @@ public class UserController {
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
}
}
userService
.
updatePass
(
user
.
getUsername
(),
passwordEncoder
.
encode
(
newPass
));
userService
.
updatePass
(
user
.
getUsername
(),
passwordEncoder
.
encode
(
newPass
));
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
@ApiOperation
(
"修改头像"
)
@ApiOperation
(
"修改头像"
)
@PostMapping
(
value
=
"/updateAvatar"
)
@PostMapping
(
value
=
"/updateAvatar"
)
public
ResponseEntity
updateAvatar
(
@RequestParam
MultipartFile
file
){
public
ResponseEntity
<
Object
>
updateAvatar
(
@RequestParam
MultipartFile
file
){
userService
.
updateAvatar
(
file
);
userService
.
updateAvatar
(
file
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
@Log
(
"修改邮箱"
)
@Log
(
"修改邮箱"
)
@ApiOperation
(
"修改邮箱"
)
@ApiOperation
(
"修改邮箱"
)
@PostMapping
(
value
=
"/updateEmail/{code}"
)
@PostMapping
(
value
=
"/updateEmail/{code}"
)
public
ResponseEntity
updateEmail
(
@PathVariable
String
code
,
@RequestBody
User
user
){
public
ResponseEntity
<
Object
>
updateEmail
(
@PathVariable
String
code
,
@RequestBody
User
user
){
// 密码解密
// 密码解密
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
String
password
=
new
String
(
rsa
.
decrypt
(
user
.
getPassword
(),
KeyType
.
PrivateKey
));
String
password
=
new
String
(
rsa
.
decrypt
(
user
.
getPassword
(),
KeyType
.
PrivateKey
));
...
@@ -191,7 +191,7 @@ public class UserController {
...
@@ -191,7 +191,7 @@ public class UserController {
VerificationCode
verificationCode
=
new
VerificationCode
(
code
,
ElAdminConstant
.
RESET_MAIL
,
"email"
,
user
.
getEmail
());
VerificationCode
verificationCode
=
new
VerificationCode
(
code
,
ElAdminConstant
.
RESET_MAIL
,
"email"
,
user
.
getEmail
());
verificationCodeService
.
validated
(
verificationCode
);
verificationCodeService
.
validated
(
verificationCode
);
userService
.
updateEmail
(
userDto
.
getUsername
(),
user
.
getEmail
());
userService
.
updateEmail
(
userDto
.
getUsername
(),
user
.
getEmail
());
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
}
/**
/**
...
...
eladmin-system/src/main/resources/template/generator/admin/Controller.ftl
View file @
900ca221
...
@@ -41,7 +41,7 @@ public class ${className}Controller {
...
@@ -41,7 +41,7 @@ public class ${className}Controller {
@
L
og
(
"查询${apiAlias}"
)
@
L
og
(
"查询${apiAlias}"
)
@
A
piOperation
(
"查询${apiAlias}"
)
@
A
piOperation
(
"查询${apiAlias}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list')"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list')"
)
public
R
esponseEntity
get
$
{
className
}
s
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
public
R
esponseEntity
<
O
bject
>
get
$
{
className
}
s
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
,
pageable
),
H
ttpStatus
.OK
)
;
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
,
pageable
),
H
ttpStatus
.OK
)
;
}
}
...
@@ -49,7 +49,7 @@ public class ${className}Controller {
...
@@ -49,7 +49,7 @@ public class ${className}Controller {
@
L
og
(
"新增${apiAlias}"
)
@
L
og
(
"新增${apiAlias}"
)
@
A
piOperation
(
"新增${apiAlias}"
)
@
A
piOperation
(
"新增${apiAlias}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:add')"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:add')"
)
public
R
esponseEntity
create
(
@
V
alidated
@
R
equestBody
$
{
className
}
resources
){
public
R
esponseEntity
<
O
bject
>
create
(
@
V
alidated
@
R
equestBody
$
{
className
}
resources
){
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.create
(
resources
),
H
ttpStatus
.CREATED
)
;
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.create
(
resources
),
H
ttpStatus
.CREATED
)
;
}
}
...
@@ -57,26 +57,26 @@ public class ${className}Controller {
...
@@ -57,26 +57,26 @@ public class ${className}Controller {
@
L
og
(
"修改${apiAlias}"
)
@
L
og
(
"修改${apiAlias}"
)
@
A
piOperation
(
"修改${apiAlias}"
)
@
A
piOperation
(
"修改${apiAlias}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:edit')"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:edit')"
)
public
R
esponseEntity
update
(
@
V
alidated
@
R
equestBody
$
{
className
}
resources
){
public
R
esponseEntity
<
O
bject
>
update
(
@
V
alidated
@
R
equestBody
$
{
className
}
resources
){
$
{
changeClassName
}
S
ervice
.update
(
resources
)
;
$
{
changeClassName
}
S
ervice
.update
(
resources
)
;
return
new
R
esponseEntity
(
H
ttpStatus
.NO_CONTENT
)
;
return
new
R
esponseEntity
<>
(
H
ttpStatus
.NO_CONTENT
)
;
}
}
@
D
eleteMapping
(
value
=
"/{${pkChangeColName}}"
)
@
D
eleteMapping
(
value
=
"/{${pkChangeColName}}"
)
@
L
og
(
"删除${apiAlias}"
)
@
L
og
(
"删除${apiAlias}"
)
@
A
piOperation
(
"删除${apiAlias}"
)
@
A
piOperation
(
"删除${apiAlias}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:del')"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:del')"
)
public
R
esponseEntity
delete
(
@
P
athVariable
$
{
pkColumnType
}
$
{
pkChangeColName
}){
public
R
esponseEntity
<
O
bject
>
delete
(
@
P
athVariable
$
{
pkColumnType
}
$
{
pkChangeColName
}){
$
{
changeClassName
}
S
ervice
.delete
(
$
{
pkChangeColName
})
;
$
{
changeClassName
}
S
ervice
.delete
(
$
{
pkChangeColName
})
;
return
new
R
esponseEntity
(
H
ttpStatus
.OK
)
;
return
new
R
esponseEntity
<>
(
H
ttpStatus
.OK
)
;
}
}
@
L
og
(
"多选删除${apiAlias}"
)
@
L
og
(
"多选删除${apiAlias}"
)
@
A
piOperation
(
"多选删除${apiAlias}"
)
@
A
piOperation
(
"多选删除${apiAlias}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:del')"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:del')"
)
@
D
eleteMapping
@
D
eleteMapping
public
R
esponseEntity
deleteAll
(
@
R
equestBody
$
{
pkColumnType
}
[]
ids
)
{
public
R
esponseEntity
<
O
bject
>
deleteAll
(
@
R
equestBody
$
{
pkColumnType
}
[]
ids
)
{
$
{
changeClassName
}
S
ervice
.deleteAll
(
ids
)
;
$
{
changeClassName
}
S
ervice
.deleteAll
(
ids
)
;
return
new
R
esponseEntity
(
H
ttpStatus
.OK
)
;
return
new
R
esponseEntity
<>
(
H
ttpStatus
.OK
)
;
}
}
}
}
\ No newline at end of file
Prev
1
2
Next
Write
Preview
Supports
Markdown
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