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
f63407fd
Commit
f63407fd
authored
Jan 21, 2019
by
郑杰
Browse files
v1.5 正式版发布 ,详情查看发行版说明
parent
40c2c880
Changes
10
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/swagger2/SwaggerDataConfig.java
0 → 100644
View file @
f63407fd
package
me.zhengjie.swagger2
;
import
com.fasterxml.classmate.TypeResolver
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.Ordered
;
import
org.springframework.data.domain.Pageable
;
import
springfox.documentation.schema.AlternateTypeRule
;
import
springfox.documentation.schema.AlternateTypeRuleConvention
;
import
java.util.List
;
import
static
com
.
google
.
common
.
collect
.
Lists
.
newArrayList
;
import
static
springfox
.
documentation
.
schema
.
AlternateTypeRules
.
newRule
;
/** * 将Pageable转换展示在swagger中 */
@Configuration
public
class
SwaggerDataConfig
{
@Bean
public
AlternateTypeRuleConvention
pageableConvention
(
final
TypeResolver
resolver
)
{
return
new
AlternateTypeRuleConvention
()
{
@Override
public
int
getOrder
()
{
return
Ordered
.
HIGHEST_PRECEDENCE
;
}
@Override
public
List
<
AlternateTypeRule
>
rules
()
{
return
newArrayList
(
newRule
(
resolver
.
resolve
(
Pageable
.
class
),
resolver
.
resolve
(
Page
.
class
)));
}
};
}
@ApiModel
static
class
Page
{
@ApiModelProperty
(
"页码 (0..N)"
)
private
Integer
page
;
@ApiModelProperty
(
"每页显示的数目"
)
private
Integer
size
;
@ApiModelProperty
(
"以下列格式排序标准:property[,asc | desc]。 默认排序顺序为升序。 支持多种排序条件:如:id,asc"
)
private
List
<
String
>
sort
;
public
Integer
getPage
()
{
return
page
;
}
public
void
setPage
(
Integer
page
)
{
this
.
page
=
page
;
}
public
Integer
getSize
()
{
return
size
;
}
public
void
setSize
(
Integer
size
)
{
this
.
size
=
size
;
}
public
List
<
String
>
getSort
()
{
return
sort
;
}
public
void
setSort
(
List
<
String
>
sort
)
{
this
.
sort
=
sort
;
}
}
}
\ No newline at end of file
eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java
View file @
f63407fd
...
...
@@ -79,7 +79,8 @@ public class GenUtil {
map
.
put
(
"hasBigDecimal"
,
false
);
map
.
put
(
"hasQuery"
,
false
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
columns
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
queryColumns
=
new
ArrayList
<>();
for
(
ColumnInfo
column
:
columnInfos
)
{
Map
<
String
,
Object
>
listMap
=
new
HashMap
();
listMap
.
put
(
"columnComment"
,
column
.
getColumnComment
());
...
...
@@ -98,17 +99,19 @@ public class GenUtil {
listMap
.
put
(
"columnType"
,
colType
);
listMap
.
put
(
"columnName"
,
column
.
getColumnName
());
listMap
.
put
(
"isNullable"
,
column
.
getIsNullable
());
listMap
.
put
(
"columnQuery"
,
column
.
getColumnQuery
());
if
(!
ObjectUtils
.
isEmpty
(
column
.
getColumnQuery
())){
map
.
put
(
"hasQuery"
,
true
);
}
listMap
.
put
(
"columnShow"
,
column
.
getColumnShow
());
listMap
.
put
(
"changeColumnName"
,
StringUtils
.
toCamelCase
(
column
.
getColumnName
().
toString
()));
listMap
.
put
(
"capitalColumnName"
,
StringUtils
.
toCapitalizeCamelCase
(
column
.
getColumnName
().
toString
()));
list
.
add
(
listMap
);
if
(!
StringUtils
.
isBlank
(
column
.
getColumnQuery
())){
listMap
.
put
(
"columnQuery"
,
column
.
getColumnQuery
());
map
.
put
(
"hasQuery"
,
true
);
queryColumns
.
add
(
listMap
);
}
columns
.
add
(
listMap
);
}
map
.
put
(
"columns"
,
list
);
map
.
put
(
"columns"
,
columns
);
map
.
put
(
"queryColumns"
,
queryColumns
);
TemplateEngine
engine
=
TemplateUtil
.
createEngine
(
new
TemplateConfig
(
"template"
,
TemplateConfig
.
ResourceMode
.
CLASSPATH
));
// 生成后端代码
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java
View file @
f63407fd
...
...
@@ -15,6 +15,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.authentication.AccountExpiredException
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
...
...
@@ -44,7 +45,7 @@ public class AuthenticationController {
*/
@Log
(
"用户登录"
)
@PostMapping
(
value
=
"${jwt.auth.path}"
)
public
ResponseEntity
<?>
login
(
@RequestBody
AuthorizationUser
authorizationUser
){
public
ResponseEntity
login
(
@Validated
@RequestBody
AuthorizationUser
authorizationUser
){
final
UserDetails
userDetails
=
userDetailsService
.
loadUserByUsername
(
authorizationUser
.
getUsername
());
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java
View file @
f63407fd
...
...
@@ -49,8 +49,8 @@ public class RoleController {
@Log
(
"查询角色"
)
@GetMapping
(
value
=
"/roles"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')"
)
public
ResponseEntity
getRoles
(
RoleDTO
resources
,
Pageable
pageable
){
return
new
ResponseEntity
(
roleQueryService
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
public
ResponseEntity
getRoles
(
@RequestParam
(
required
=
false
)
String
name
,
Pageable
pageable
){
return
new
ResponseEntity
(
roleQueryService
.
queryAll
(
name
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增角色"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDTO.java
View file @
f63407fd
package
me.zhengjie.modules.system.service.dto
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Set
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDTO.java
View file @
f63407fd
package
me.zhengjie.modules.system.service.dto
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Date
;
...
...
@@ -15,6 +15,7 @@ import java.util.Set;
@Data
public
class
UserDTO
implements
Serializable
{
@ApiModelProperty
(
hidden
=
true
)
private
Long
id
;
private
String
username
;
...
...
@@ -32,5 +33,6 @@ public class UserDTO implements Serializable {
private
Date
lastPasswordResetTime
;
@ApiModelProperty
(
hidden
=
true
)
private
Set
<
RoleDTO
>
roles
;
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/query/RoleQueryService.java
View file @
f63407fd
...
...
@@ -2,7 +2,6 @@ package me.zhengjie.modules.system.service.query;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.repository.RoleRepository
;
import
me.zhengjie.modules.system.service.dto.RoleDTO
;
import
me.zhengjie.modules.system.service.mapper.RoleMapper
;
import
me.zhengjie.utils.PageUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -41,25 +40,17 @@ public class RoleQueryService {
* 分页
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
public
Object
queryAll
(
RoleDTO
rol
e
,
Pageable
pageable
){
Page
<
Role
>
page
=
roleRepository
.
findAll
(
new
Spec
(
rol
e
),
pageable
);
public
Object
queryAll
(
String
nam
e
,
Pageable
pageable
){
Page
<
Role
>
page
=
roleRepository
.
findAll
(
new
Spec
(
nam
e
),
pageable
);
return
PageUtil
.
toPage
(
page
.
map
(
roleMapper:
:
toDto
));
}
/**
* 不分页
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
public
Object
queryAll
(
RoleDTO
role
){
return
roleMapper
.
toDto
(
roleRepository
.
findAll
(
new
Spec
(
role
)));
}
class
Spec
implements
Specification
<
Role
>
{
private
RoleDTO
rol
e
;
private
String
nam
e
;
public
Spec
(
RoleDTO
rol
e
){
this
.
rol
e
=
rol
e
;
public
Spec
(
String
nam
e
){
this
.
nam
e
=
nam
e
;
}
@Override
...
...
@@ -67,11 +58,11 @@ public class RoleQueryService {
List
<
Predicate
>
list
=
new
ArrayList
<
Predicate
>();
if
(!
ObjectUtils
.
isEmpty
(
role
.
getN
ame
()
)){
if
(!
ObjectUtils
.
isEmpty
(
n
ame
)){
/**
* 模糊
*/
list
.
add
(
cb
.
like
(
root
.
get
(
"name"
).
as
(
String
.
class
),
"%"
+
role
.
getN
ame
()
+
"%"
));
list
.
add
(
cb
.
like
(
root
.
get
(
"name"
).
as
(
String
.
class
),
"%"
+
n
ame
+
"%"
));
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
...
...
eladmin-system/src/main/resources/template/generator/admin/QueryService.ftl
View file @
f63407fd
...
...
@@ -67,9 +67,8 @@ public class ${className}QueryService {
L
ist
<
P
redicate
>
list
=
new
A
rrayList
<
P
redicate
>
()
;
<#
if
columns
??>
<#
list
columns
as
column
>
<#
if
column
.columnQuery
??>
<#
if
queryColumns
??>
<#
list
queryColumns
as
column
>
if
(
!
O
bjectUtils
.isEmpty
(
$
{
changeClassName
}
.get
$
{
column
.capitalColumnName
}())){
<#
if
column
.columnQuery
=
'
1
'>
/
**
...
...
@@ -84,7 +83,6 @@ public class ${className}QueryService {
list
.add
(
cb
.equal
(
root
.get
(
"${column.columnName}"
)
.as
(
$
{
column
.columnType
}
.class
),
$
{
changeClassName
}
.get
$
{
column
.capitalColumnName
}()))
;
</#
if
>
}
</#
if
>
</#
list
>
</#
if
>
P
redicate
[]
p
=
new
P
redicate
[
list
.size
()
];
...
...
eladmin-system/src/main/resources/template/generator/front/header.ftl
View file @
f63407fd
...
...
@@ -35,13 +35,11 @@ export default {
},
data
()
{
return
{
downloadLoading
:
false
<#
if
hasQuery
>
,
<#
if
hasQuery
>
queryTypeOptions
:
[
<#
if
columns
??>
<#
list
columns
as
column
>
<#
if
column
.columnQuery
??>
<#
if
queryColumns
??>
<#
list
queryColumns
as
column
>
{
key
:
'$
{
column
.changeColumnName
}
'
,
display_name
:
'<#
if
column
.columnComment
!=
''>$
{
column
.columnComment
}
<#
else
>$
{
column
.changeColumnName
}
</#
if
>'
}
<#
if
column_has_next
>
,
</#
if
>
</#
if
>
</#
list
>
</#
if
>
]
...
...
pom.xml
View file @
f63407fd
...
...
@@ -109,12 +109,32 @@
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
${swagger.version}
</version>
<exclusions>
<exclusion>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
</exclusion>
<exclusion>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-models
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
${swagger.version}
</version>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
1.5.21
</version>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-models
</artifactId>
<version>
1.5.21
</version>
</dependency>
<!--Mysql依赖包-->
<dependency>
...
...
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