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
"vscode:/vscode.git/clone" did not exist on "c53226a0179a06c285ebd994daab03342f72a8cf"
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 {
@ApiOperation
(
"查询"
)
@GetMapping
(
value
=
"/{tableName}"
)
public
ResponseEntity
get
(
@PathVariable
String
tableName
){
public
ResponseEntity
<
Object
>
get
(
@PathVariable
String
tableName
){
return
new
ResponseEntity
<>(
genConfigService
.
find
(
tableName
),
HttpStatus
.
OK
);
}
@ApiOperation
(
"修改"
)
@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
);
}
}
eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java
View file @
900ca221
...
...
@@ -38,13 +38,13 @@ public class GeneratorController {
@ApiOperation
(
"查询数据库数据"
)
@GetMapping
(
value
=
"/tables/all"
)
public
ResponseEntity
getTables
(){
public
ResponseEntity
<
Object
>
getTables
(){
return
new
ResponseEntity
<>(
generatorService
.
getTables
(),
HttpStatus
.
OK
);
}
@ApiOperation
(
"查询数据库数据"
)
@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
=
"10"
)
Integer
size
){
int
[]
startEnd
=
PageUtil
.
transToStartEnd
(
page
+
1
,
size
);
...
...
@@ -53,7 +53,7 @@ public class GeneratorController {
@ApiOperation
(
"查询字段数据"
)
@GetMapping
(
value
=
"/columns"
)
public
ResponseEntity
getTables
(
@RequestParam
String
tableName
){
public
ResponseEntity
<
Object
>
getTables
(
@RequestParam
String
tableName
){
List
<
ColumnInfo
>
columnInfos
=
generatorService
.
getColumns
(
tableName
);
// 异步同步表信息
generatorService
.
sync
(
columnInfos
);
...
...
@@ -62,14 +62,14 @@ public class GeneratorController {
@ApiOperation
(
"保存字段数据"
)
@PutMapping
public
ResponseEntity
save
(
@RequestBody
List
<
ColumnInfo
>
columnInfos
){
public
ResponseEntity
<
HttpStatus
>
save
(
@RequestBody
List
<
ColumnInfo
>
columnInfos
){
generatorService
.
save
(
columnInfos
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
@ApiOperation
(
"生成代码"
)
@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
){
throw
new
BadRequestException
(
"此环境不允许生成代码,请选择预览或者下载查看!"
);
}
...
...
@@ -84,6 +84,6 @@ public class GeneratorController {
break
;
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 {
* @param columns 字段信息
* @return /
*/
ResponseEntity
preview
(
GenConfig
genConfig
,
List
<
ColumnInfo
>
columns
);
ResponseEntity
<
Object
>
preview
(
GenConfig
genConfig
,
List
<
ColumnInfo
>
columns
);
/**
* 打包下载
* @param genConfig 配置信息
* @param columns 字段信息
* @param request
* @param response
* @param request
/
* @param 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
/**
* 根据日志类型删除信息
* @param logType
* @param logType
日志类型
*/
@Query
(
nativeQuery
=
true
,
value
=
"delete from log where log_type = ?1"
)
@Modifying
@Transactional
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;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
...
...
@@ -50,14 +49,14 @@ public class LogController {
@GetMapping
@ApiOperation
(
"日志查询"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
criteria
.
setLogType
(
"INFO"
);
return
new
ResponseEntity
<>(
logService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/user"
)
@ApiOperation
(
"用户日志查询"
)
public
ResponseEntity
getUserLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getUserLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
criteria
.
setLogType
(
"INFO"
);
criteria
.
setBlurry
(
SecurityUtils
.
getUsername
());
return
new
ResponseEntity
<>(
logService
.
queryAllByUser
(
criteria
,
pageable
),
HttpStatus
.
OK
);
...
...
@@ -66,7 +65,7 @@ public class LogController {
@GetMapping
(
value
=
"/error"
)
@ApiOperation
(
"错误日志查询"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getErrorLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
public
ResponseEntity
<
Object
>
getErrorLogs
(
LogQueryCriteria
criteria
,
Pageable
pageable
){
criteria
.
setLogType
(
"ERROR"
);
return
new
ResponseEntity
<>(
logService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
...
...
@@ -74,24 +73,24 @@ public class LogController {
@GetMapping
(
value
=
"/error/{id}"
)
@ApiOperation
(
"日志异常详情查询"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
getErrorLogs
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
getErrorLogs
(
@PathVariable
Long
id
){
return
new
ResponseEntity
<>(
logService
.
findByErrDetail
(
id
),
HttpStatus
.
OK
);
}
@DeleteMapping
(
value
=
"/del/error"
)
@Log
(
"删除所有ERROR日志"
)
@ApiOperation
(
"删除所有ERROR日志"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
delAllByError
(){
public
ResponseEntity
<
Object
>
delAllByError
(){
logService
.
delAllByError
();
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
@DeleteMapping
(
value
=
"/del/info"
)
@Log
(
"删除所有INFO日志"
)
@ApiOperation
(
"删除所有INFO日志"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
delAllByInfo
(){
public
ResponseEntity
<
Object
>
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 {
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
);
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
+=
appName
+
FILE_SEPARATOR
+
deployDate
+
"\n"
;
...
...
@@ -259,8 +260,7 @@ public class DeployServiceImpl implements DeployService {
}
private
boolean
checkFile
(
ExecuteShellUtil
executeShellUtil
,
AppDto
appDTO
)
{
StringBuilder
sb
=
new
StringBuilder
(
"find "
).
append
(
appDTO
.
getDeployPath
()).
append
(
" -name "
).
append
(
appDTO
.
getName
());
String
result
=
executeShellUtil
.
executeForResult
(
sb
.
toString
());
String
result
=
executeShellUtil
.
executeForResult
(
"find "
+
appDTO
.
getDeployPath
()
+
" -name "
+
appDTO
.
getName
());
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 {
@Log
(
"查询服务监控"
)
@ApiOperation
(
"查询服务监控"
)
@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
);
}
...
...
@@ -40,7 +40,7 @@ public class ServerController {
@Log
(
"新增服务监控"
)
@ApiOperation
(
"新增服务监控"
)
@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
);
}
...
...
@@ -48,9 +48,9 @@ public class ServerController {
@Log
(
"修改服务监控"
)
@ApiOperation
(
"修改服务监控"
)
@PreAuthorize
(
"@el.check('server:edit')"
)
public
ResponseEntity
update
(
@Validated
@RequestBody
Server
resources
){
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
Server
resources
){
serverService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@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 {
@PostMapping
@ApiOperation
(
"创建访问记录"
)
public
ResponseEntity
create
(){
public
ResponseEntity
<
Object
>
create
(){
visitsService
.
count
(
RequestHolder
.
getHttpServletRequest
());
return
new
ResponseEntity
(
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
HttpStatus
.
CREATED
);
}
@GetMapping
@ApiOperation
(
"查询"
)
public
ResponseEntity
get
(){
public
ResponseEntity
<
Object
>
get
(){
return
new
ResponseEntity
<>(
visitsService
.
get
(),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/chartData"
)
@ApiOperation
(
"查询图表数据"
)
public
ResponseEntity
getChartData
(){
public
ResponseEntity
<
Object
>
getChartData
(){
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 {
@ApiOperation
(
"查询定时任务"
)
@GetMapping
@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
);
}
...
...
@@ -63,7 +63,7 @@ public class QuartzJobController {
@ApiOperation
(
"查询任务执行日志"
)
@GetMapping
(
value
=
"/logs"
)
@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
);
}
...
...
@@ -71,7 +71,7 @@ public class QuartzJobController {
@ApiOperation
(
"新增定时任务"
)
@PostMapping
@PreAuthorize
(
"@el.check('timing:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
QuartzJob
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
QuartzJob
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -82,35 +82,35 @@ public class QuartzJobController {
@ApiOperation
(
"修改定时任务"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"更改定时任务状态"
)
@ApiOperation
(
"更改定时任务状态"
)
@PutMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
public
ResponseEntity
updateIsPause
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
updateIsPause
(
@PathVariable
Long
id
){
quartzJobService
.
updateIsPause
(
quartzJobService
.
findById
(
id
));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"执行定时任务"
)
@ApiOperation
(
"执行定时任务"
)
@PutMapping
(
value
=
"/exec/{id}"
)
@PreAuthorize
(
"@el.check('timing:edit')"
)
public
ResponseEntity
execution
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
execution
(
@PathVariable
Long
id
){
quartzJobService
.
execution
(
quartzJobService
.
findById
(
id
));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除定时任务"
)
@ApiOperation
(
"删除定时任务"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('timing:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
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 {
@ApiOperation
(
"登录授权"
)
@AnonymousAccess
@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
);
String
password
=
new
String
(
rsa
.
decrypt
(
authUser
.
getPassword
(),
KeyType
.
PrivateKey
));
...
...
@@ -108,7 +108,7 @@ public class AuthController {
@ApiOperation
(
"获取用户信息"
)
@GetMapping
(
value
=
"/info"
)
public
ResponseEntity
getUserInfo
(){
public
ResponseEntity
<
Object
>
getUserInfo
(){
JwtUser
jwtUser
=
(
JwtUser
)
userDetailsService
.
loadUserByUsername
(
SecurityUtils
.
getUsername
());
return
ResponseEntity
.
ok
(
jwtUser
);
}
...
...
@@ -116,7 +116,7 @@ public class AuthController {
@AnonymousAccess
@ApiOperation
(
"获取验证码"
)
@GetMapping
(
value
=
"/code"
)
public
ResponseEntity
getCode
(){
public
ResponseEntity
<
Object
>
getCode
(){
// 算术类型 https://gitee.com/whvse/EasyCaptcha
ArithmeticCaptcha
captcha
=
new
ArithmeticCaptcha
(
111
,
36
);
// 几位数运算,默认是两位
...
...
@@ -137,8 +137,8 @@ public class AuthController {
@ApiOperation
(
"退出登录"
)
@AnonymousAccess
@DeleteMapping
(
value
=
"/logout"
)
public
ResponseEntity
logout
(
HttpServletRequest
request
){
public
ResponseEntity
<
Object
>
logout
(
HttpServletRequest
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 {
@ApiOperation
(
"查询在线用户"
)
@GetMapping
@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
);
}
...
...
@@ -45,8 +45,8 @@ public class OnlineController {
@ApiOperation
(
"踢出用户"
)
@DeleteMapping
(
value
=
"/{key}"
)
@PreAuthorize
(
"@el.check()"
)
public
ResponseEntity
delete
(
@PathVariable
String
key
)
throws
Exception
{
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
String
key
)
throws
Exception
{
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 {
/**
* 检测用户是否在之前已经登录,已经登录踢下线
* @param userName
* @param userName
用户名
*/
public
void
checkLoginOnUser
(
String
userName
,
String
igoreToken
){
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;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
...
...
@@ -52,7 +51,7 @@ public class DeptController {
@ApiOperation
(
"查询部门"
)
@GetMapping
@PreAuthorize
(
"@el.check('user:list','dept:list')"
)
public
ResponseEntity
getDepts
(
DeptQueryCriteria
criteria
){
public
ResponseEntity
<
Object
>
getDepts
(
DeptQueryCriteria
criteria
){
// 数据权限
criteria
.
setIds
(
dataScope
.
getDeptIds
());
List
<
DeptDto
>
deptDtos
=
deptService
.
queryAll
(
criteria
);
...
...
@@ -63,7 +62,7 @@ public class DeptController {
@ApiOperation
(
"新增部门"
)
@PostMapping
@PreAuthorize
(
"@el.check('dept:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Dept
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Dept
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -74,21 +73,21 @@ public class DeptController {
@ApiOperation
(
"修改部门"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除部门"
)
@ApiOperation
(
"删除部门"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dept:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
try
{
deptService
.
delete
(
id
);
}
catch
(
Throwable
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 {
@ApiOperation
(
"查询字典"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('dict:list')"
)
public
ResponseEntity
all
(){
public
ResponseEntity
<
Object
>
all
(){
return
new
ResponseEntity
<>(
dictService
.
queryAll
(
new
DictQueryCriteria
()),
HttpStatus
.
OK
);
}
...
...
@@ -54,7 +54,7 @@ public class DictController {
@ApiOperation
(
"查询字典"
)
@GetMapping
@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
);
}
...
...
@@ -62,7 +62,7 @@ public class DictController {
@ApiOperation
(
"新增字典"
)
@PostMapping
@PreAuthorize
(
"@el.check('dict:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Dict
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Dict
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -73,17 +73,17 @@ public class DictController {
@ApiOperation
(
"修改字典"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除字典"
)
@ApiOperation
(
"删除字典"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
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 {
@Log
(
"查询字典详情"
)
@ApiOperation
(
"查询字典详情"
)
@GetMapping
public
ResponseEntity
getDictDetails
(
DictDetailQueryCriteria
criteria
,
public
ResponseEntity
<
Object
>
getDictDetails
(
DictDetailQueryCriteria
criteria
,
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
<>(
dictDetailService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
...
...
@@ -46,7 +46,7 @@ public class DictDetailController {
@Log
(
"查询多个字典详情"
)
@ApiOperation
(
"查询多个字典详情"
)
@GetMapping
(
value
=
"/map"
)
public
ResponseEntity
getDictDetailMaps
(
DictDetailQueryCriteria
criteria
,
public
ResponseEntity
<
Object
>
getDictDetailMaps
(
DictDetailQueryCriteria
criteria
,
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
String
[]
names
=
criteria
.
getDictName
().
split
(
","
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
names
.
length
);
...
...
@@ -61,7 +61,7 @@ public class DictDetailController {
@ApiOperation
(
"新增字典详情"
)
@PostMapping
@PreAuthorize
(
"@el.check('dict:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
DictDetail
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
DictDetail
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -72,17 +72,17 @@ public class DictDetailController {
@ApiOperation
(
"修改字典详情"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除字典详情"
)
@ApiOperation
(
"删除字典详情"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
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 {
@ApiOperation
(
"查询岗位"
)
@GetMapping
@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
());
return
new
ResponseEntity
<>(
jobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
...
...
@@ -62,7 +62,7 @@ public class JobController {
@ApiOperation
(
"新增岗位"
)
@PostMapping
@PreAuthorize
(
"@el.check('job:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Job
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Job
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -73,21 +73,21 @@ public class JobController {
@ApiOperation
(
"修改岗位"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除岗位"
)
@ApiOperation
(
"删除岗位"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('job:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
try
{
jobService
.
delete
(
id
);
}
catch
(
Throwable
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 {
@ApiOperation
(
"获取前端所需菜单"
)
@GetMapping
(
value
=
"/build"
)
public
ResponseEntity
buildMenus
(){
public
ResponseEntity
<
Object
>
buildMenus
(){
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
List
<
MenuDto
>
menuDtoList
=
menuService
.
findByRoles
(
roleService
.
findByUsersId
(
user
.
getId
()));
List
<
MenuDto
>
menuDtos
=
(
List
<
MenuDto
>)
menuService
.
buildTree
(
menuDtoList
).
get
(
"content"
);
...
...
@@ -68,7 +68,7 @@ public class MenuController {
@ApiOperation
(
"返回全部的菜单"
)
@GetMapping
(
value
=
"/tree"
)
@PreAuthorize
(
"@el.check('menu:list','roles:list')"
)
public
ResponseEntity
getMenuTree
(){
public
ResponseEntity
<
Object
>
getMenuTree
(){
return
new
ResponseEntity
<>(
menuService
.
getMenuTree
(
menuService
.
findByPid
(
0L
)),
HttpStatus
.
OK
);
}
...
...
@@ -76,7 +76,7 @@ public class MenuController {
@ApiOperation
(
"查询菜单"
)
@GetMapping
@PreAuthorize
(
"@el.check('menu:list')"
)
public
ResponseEntity
getMenus
(
MenuQueryCriteria
criteria
){
public
ResponseEntity
<
Object
>
getMenus
(
MenuQueryCriteria
criteria
){
List
<
MenuDto
>
menuDtoList
=
menuService
.
queryAll
(
criteria
);
return
new
ResponseEntity
<>(
menuService
.
buildTree
(
menuDtoList
),
HttpStatus
.
OK
);
}
...
...
@@ -85,7 +85,7 @@ public class MenuController {
@ApiOperation
(
"新增菜单"
)
@PostMapping
@PreAuthorize
(
"@el.check('menu:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Menu
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Menu
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -96,21 +96,21 @@ public class MenuController {
@ApiOperation
(
"修改菜单"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除菜单"
)
@ApiOperation
(
"删除菜单"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('menu:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
List
<
Menu
>
menuList
=
menuService
.
findByPid
(
id
);
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
menuSet
.
add
(
menuService
.
findOne
(
id
));
menuSet
=
menuService
.
getDeleteMenus
(
menuList
,
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 {
@ApiOperation
(
"获取单个role"
)
@GetMapping
(
value
=
"/{id}"
)
@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
);
}
...
...
@@ -65,7 +65,7 @@ public class RoleController {
@ApiOperation
(
"返回全部的角色"
)
@GetMapping
(
value
=
"/all"
)
@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
);
}
...
...
@@ -73,13 +73,13 @@ public class RoleController {
@ApiOperation
(
"查询角色"
)
@GetMapping
@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
);
}
@ApiOperation
(
"获取用户级别"
)
@GetMapping
(
value
=
"/level"
)
public
ResponseEntity
getLevel
(){
public
ResponseEntity
<
Object
>
getLevel
(){
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
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
);
...
...
@@ -89,7 +89,7 @@ public class RoleController {
@ApiOperation
(
"新增角色"
)
@PostMapping
@PreAuthorize
(
"@el.check('roles:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Role
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
Role
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
...
...
@@ -100,30 +100,30 @@ public class RoleController {
@ApiOperation
(
"修改角色"
)
@PutMapping
@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
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"修改角色菜单"
)
@ApiOperation
(
"修改角色菜单"
)
@PutMapping
(
value
=
"/menu"
)
@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
()));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除角色"
)
@ApiOperation
(
"删除角色"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('roles:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
try
{
roleService
.
delete
(
id
);
}
catch
(
Throwable
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 {
@ApiOperation
(
"查询用户"
)
@GetMapping
@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
>
result
=
new
HashSet
<>();
if
(!
ObjectUtils
.
isEmpty
(
criteria
.
getDeptId
()))
{
...
...
@@ -107,7 +107,7 @@ public class UserController {
@ApiOperation
(
"新增用户"
)
@PostMapping
@PreAuthorize
(
"@el.check('user:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
User
resources
){
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
User
resources
){
checkLevel
(
resources
);
// 默认密码 123456
resources
.
setPassword
(
passwordEncoder
.
encode
(
"123456"
));
...
...
@@ -118,29 +118,29 @@ public class UserController {
@ApiOperation
(
"修改用户"
)
@PutMapping
@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
);
userService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"修改用户:个人中心"
)
@ApiOperation
(
"修改用户:个人中心"
)
@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
());
if
(!
resources
.
getId
().
equals
(
userDto
.
getId
())){
throw
new
BadRequestException
(
"不能修改他人资料"
);
}
userService
.
updateCenter
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
return
new
ResponseEntity
<>
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除用户"
)
@ApiOperation
(
"删除用户"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('user:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
public
ResponseEntity
<
Object
>
delete
(
@PathVariable
Long
id
){
UserDto
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
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
()));
...
...
@@ -149,12 +149,12 @@ public class UserController {
throw
new
BadRequestException
(
"角色权限不足"
);
}
userService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
@ApiOperation
(
"修改密码"
)
@PostMapping
(
value
=
"/updatePass"
)
public
ResponseEntity
updatePass
(
@RequestBody
UserPassVo
passVo
){
public
ResponseEntity
<
Object
>
updatePass
(
@RequestBody
UserPassVo
passVo
){
// 密码解密
RSA
rsa
=
new
RSA
(
privateKey
,
null
);
String
oldPass
=
new
String
(
rsa
.
decrypt
(
passVo
.
getOldPass
(),
KeyType
.
PrivateKey
));
...
...
@@ -167,20 +167,20 @@ public class UserController {
throw
new
BadRequestException
(
"新密码不能与旧密码相同"
);
}
userService
.
updatePass
(
user
.
getUsername
(),
passwordEncoder
.
encode
(
newPass
));
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
@ApiOperation
(
"修改头像"
)
@PostMapping
(
value
=
"/updateAvatar"
)
public
ResponseEntity
updateAvatar
(
@RequestParam
MultipartFile
file
){
public
ResponseEntity
<
Object
>
updateAvatar
(
@RequestParam
MultipartFile
file
){
userService
.
updateAvatar
(
file
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
HttpStatus
.
OK
);
}
@Log
(
"修改邮箱"
)
@ApiOperation
(
"修改邮箱"
)
@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
);
String
password
=
new
String
(
rsa
.
decrypt
(
user
.
getPassword
(),
KeyType
.
PrivateKey
));
...
...
@@ -191,7 +191,7 @@ public class UserController {
VerificationCode
verificationCode
=
new
VerificationCode
(
code
,
ElAdminConstant
.
RESET_MAIL
,
"email"
,
user
.
getEmail
());
verificationCodeService
.
validated
(
verificationCode
);
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 {
@
L
og
(
"查询${apiAlias}"
)
@
A
piOperation
(
"查询${apiAlias}"
)
@
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
)
;
}
...
...
@@ -49,7 +49,7 @@ public class ${className}Controller {
@
L
og
(
"新增${apiAlias}"
)
@
A
piOperation
(
"新增${apiAlias}"
)
@
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
)
;
}
...
...
@@ -57,26 +57,26 @@ public class ${className}Controller {
@
L
og
(
"修改${apiAlias}"
)
@
A
piOperation
(
"修改${apiAlias}"
)
@
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
)
;
return
new
R
esponseEntity
(
H
ttpStatus
.NO_CONTENT
)
;
return
new
R
esponseEntity
<>
(
H
ttpStatus
.NO_CONTENT
)
;
}
@
D
eleteMapping
(
value
=
"/{${pkChangeColName}}"
)
@
L
og
(
"删除${apiAlias}"
)
@
A
piOperation
(
"删除${apiAlias}"
)
@
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
})
;
return
new
R
esponseEntity
(
H
ttpStatus
.OK
)
;
return
new
R
esponseEntity
<>
(
H
ttpStatus
.OK
)
;
}
@
L
og
(
"多选删除${apiAlias}"
)
@
A
piOperation
(
"多选删除${apiAlias}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:del')"
)
@
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
)
;
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