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
Springboot Plus
Commits
18144407
Commit
18144407
authored
Sep 04, 2019
by
trumansdo
Browse files
应用codestyle
千万千万要用vscode打开前端项目,或者关闭eslint,移除它 Signed-off-by:
trumansdo
<
1012243881@qq.com
>
parent
9b3d96a6
Changes
178
Show whitespace changes
Inline
Side-by-side
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/web/query/UserRoleQuery.java
View file @
18144407
...
@@ -3,17 +3,17 @@ package com.ibeetl.admin.console.web.query;
...
@@ -3,17 +3,17 @@ package com.ibeetl.admin.console.web.query;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.web.query.PageParam
;
import
com.ibeetl.admin.core.web.query.PageParam
;
/**
/** */
*/
public
class
UserRoleQuery
extends
PageParam
{
public
class
UserRoleQuery
extends
PageParam
{
@Query
(
name
=
"角色"
,
display
=
true
,
type
=
Query
.
TYPE_CONTROL
,
control
=
"role"
)
@Query
(
name
=
"角色"
,
display
=
true
,
type
=
Query
.
TYPE_CONTROL
,
control
=
"role"
)
private
Long
roleId
;
private
Long
roleId
;
@Query
(
name
=
"部门"
,
display
=
true
,
type
=
Query
.
TYPE_CONTROL
,
control
=
"org"
)
@Query
(
name
=
"部门"
,
display
=
true
,
type
=
Query
.
TYPE_CONTROL
,
control
=
"org"
)
private
Long
orgId
;
private
Long
orgId
;
private
Long
userId
;
private
Long
userId
;
public
Long
getUserId
()
{
public
Long
getUserId
()
{
return
userId
;
return
userId
;
}
}
...
...
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/web/query/WorkflowQuery.java
View file @
18144407
...
@@ -5,40 +5,39 @@ import java.util.Date;
...
@@ -5,40 +5,39 @@ import java.util.Date;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.web.query.PageParam
;
import
com.ibeetl.admin.core.web.query.PageParam
;
/**
/** 字典表单查询条件 */
* 字典表单查询条件
*/
public
class
WorkflowQuery
extends
PageParam
{
public
class
WorkflowQuery
extends
PageParam
{
@Query
(
name
=
"用户列表"
,
display
=
true
,
fuzzy
=
true
)
@Query
(
name
=
"用户列表"
,
display
=
true
,
fuzzy
=
true
)
private
String
userIds
;
private
String
userIds
;
@Query
(
name
=
"角色列表"
,
display
=
true
,
fuzzy
=
true
)
@Query
(
name
=
"角色列表"
,
display
=
true
,
fuzzy
=
true
)
private
String
roleIds
;
private
String
roleIds
;
@Query
(
name
=
"机构列表"
,
display
=
true
,
fuzzy
=
true
)
@Query
(
name
=
"机构列表"
,
display
=
true
,
fuzzy
=
true
)
private
String
orgIds
;
private
String
orgIds
;
public
String
getUserIds
()
{
public
String
getUserIds
()
{
return
userIds
;
return
userIds
;
}
}
public
void
setUserIds
(
String
userIds
)
{
public
void
setUserIds
(
String
userIds
)
{
this
.
userIds
=
userIds
;
this
.
userIds
=
userIds
;
}
}
public
String
getRoleIds
()
{
public
String
getRoleIds
()
{
return
roleIds
;
return
roleIds
;
}
}
public
void
setRoleIds
(
String
roleIds
)
{
public
void
setRoleIds
(
String
roleIds
)
{
this
.
roleIds
=
roleIds
;
this
.
roleIds
=
roleIds
;
}
}
public
String
getOrgIds
()
{
public
String
getOrgIds
()
{
return
orgIds
;
return
orgIds
;
}
}
public
void
setOrgIds
(
String
orgIds
)
{
public
void
setOrgIds
(
String
orgIds
)
{
this
.
orgIds
=
orgIds
;
this
.
orgIds
=
orgIds
;
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/annotation/Dict.java
View file @
18144407
...
@@ -10,7 +10,6 @@ import com.ibeetl.admin.core.util.enums.CoreDictType;
...
@@ -10,7 +10,6 @@ import com.ibeetl.admin.core.util.enums.CoreDictType;
/**
/**
* 描述: 用来标注词典字段
* 描述: 用来标注词典字段
*
*
*
* @author : lijiazhi
* @author : lijiazhi
*/
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/annotation/Function.java
View file @
18144407
...
@@ -5,6 +5,7 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -5,6 +5,7 @@ import java.lang.annotation.RetentionPolicy;
/**
/**
* 用来标注功能id
* 用来标注功能id
*
* <pre>
* <pre>
* @Function("user.add")
* @Function("user.add")
* public String addUser(){
* public String addUser(){
...
@@ -12,11 +13,12 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -12,11 +13,12 @@ import java.lang.annotation.RetentionPolicy;
* </pre>
* </pre>
*
*
* 只有拥有此项功能的角色才能操作,否则,权限不足
* 只有拥有此项功能的角色才能操作,否则,权限不足
* @author lijiazhi
*
*
* @author lijiazhi
*/
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Function
{
public
@interface
Function
{
public
String
value
();
public
String
value
();
public
String
name
()
default
""
;
public
String
name
()
default
""
;
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/annotation/Query.java
View file @
18144407
...
@@ -5,47 +5,51 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -5,47 +5,51 @@ import java.lang.annotation.RetentionPolicy;
/**
/**
* 用来标准一个查询类
* 用来标准一个查询类
* @author lijiazhi
*
*
* @author lijiazhi
*/
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Query
{
public
@interface
Query
{
public
static
final
int
TYPE_GENERAL
=
1
;
public
static
final
int
TYPE_GENERAL
=
1
;
public
static
final
int
TYPE_DATE_BETWEEN
=
2
;
public
static
final
int
TYPE_DATE_BETWEEN
=
2
;
//未实现
//
未实现
public
static
final
int
TYPE_DATETIME_BETWEEN
=
3
;
public
static
final
int
TYPE_DATETIME_BETWEEN
=
3
;
public
static
final
int
TYPE_VALUE_BETWEEN
=
4
;
public
static
final
int
TYPE_VALUE_BETWEEN
=
4
;
public
static
final
int
TYPE_DICT
=
5
;
public
static
final
int
TYPE_DICT
=
5
;
//用户自己定义
//
用户自己定义
public
static
final
int
TYPE_CONTROL
=
6
;
public
static
final
int
TYPE_CONTROL
=
6
;
/**
/**
* 中文名字
* 中文名字
*
* @return
* @return
*/
*/
public
String
name
();
public
String
name
();
/**
/**
* 查询类型,常规,范围,字典,前端自定义
* 查询类型,常规,范围,字典,前端自定义
*
* @return
* @return
*/
*/
public
int
type
()
default
TYPE_GENERAL
;
public
int
type
()
default
TYPE_GENERAL
;
/**
/**
* 是否显示在查询界面上
* 是否显示在查询界面上
*
* @return
* @return
*/
*/
public
boolean
display
()
default
false
;
public
boolean
display
()
default
false
;
/**
/**
* 模糊查询,仅仅针对TYPE_GENERAL
* 模糊查询,仅仅针对TYPE_GENERAL
*
* @return
* @return
*/
*/
public
boolean
fuzzy
()
default
false
;
public
boolean
fuzzy
()
default
false
;
/**
/**
* 字典的主键,比如,"user_state"
* 字典的主键,比如,"user_state"
*
* @return
* @return
*/
*/
public
String
dict
()
default
""
;
public
String
dict
()
default
""
;
...
@@ -55,12 +59,14 @@ public @interface Query {
...
@@ -55,12 +59,14 @@ public @interface Query {
/**
/**
* 控件名字,如组织机构面板
* 控件名字,如组织机构面板
*
* @return
* @return
*/
*/
public
String
control
()
default
""
;
public
String
control
()
default
""
;
/**
/**
* 顺序,值越小,排在前面
* 顺序,值越小,排在前面
*
* @return
* @return
*/
*/
public
int
order
()
default
0
;
public
int
order
()
default
0
;
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/BeetlConf.java
View file @
18144407
...
@@ -40,44 +40,29 @@ import com.ibeetl.starter.ObjectMapperJsonUtil;
...
@@ -40,44 +40,29 @@ import com.ibeetl.starter.ObjectMapperJsonUtil;
@Configuration
@Configuration
@AutoConfigureAfter
(
JasonConfig
.
class
)
@AutoConfigureAfter
(
JasonConfig
.
class
)
public
class
BeetlConf
{
public
class
BeetlConf
{
@Autowired
@Autowired
Environment
env
;
Environment
env
;
@Autowired
CorePlatformService
platFormService
;
@Autowired
CorePlatformService
platFormService
;
@Autowired
@Autowired
OrgFunction
orgFunction
;
OrgFunction
orgFunction
;
@Autowired
@Autowired
SysFunctionTreeFunction
sysFunctionTreeFunction
;
SysFunctionTreeFunction
sysFunctionTreeFunction
;
@Autowired
@Autowired
DictQueryFunction
dictDownQueryFunction
;
DictQueryFunction
dictDownQueryFunction
;
@Autowired
RoleFunction
roleFunction
;
@Autowired
FileFunction
fileFunction
;
@Autowired
SearchCondtionFunction
searchCondtionFunction
;
@Autowired
@Autowired
DataAccessFactory
dataAccessFactory
;
RoleFunction
roleFunction
;
@Autowired
FileFunction
fileFunction
;
@Autowired
@Autowired
ApplicationContext
applicationContext
;
SearchCondtionFunction
searchCondtionFunction
;
@Autowired
@Autowired
FunFunction
funFunction
;
DataAccessFactory
dataAccessFactory
;
@Autowired
@Autowired
FunAccessUrlFunction
funAccessUrlFunction
;
ApplicationContext
applicationContext
;
@Autowired
@Autowired
MenuFunction
menuFunction
;
FunFunction
funFunction
;
@Autowired
FunAccessUrlFunction
funAccessUrlFunction
;
@Autowired
MenuFunction
menuFunction
;
@Bean
@Bean
public
WebSimulate
getWebSimulate
(
GroupTemplate
gt
,
ObjectMapper
objectMapper
)
{
public
WebSimulate
getWebSimulate
(
GroupTemplate
gt
,
ObjectMapper
objectMapper
)
{
...
@@ -106,7 +91,9 @@ public class BeetlConf {
...
@@ -106,7 +91,9 @@ public class BeetlConf {
groupTemplate
.
registerFunction
(
"uuid"
,
new
UUIDFunction
());
groupTemplate
.
registerFunction
(
"uuid"
,
new
UUIDFunction
());
groupTemplate
.
registerFunctionPackage
(
"dict"
,
dictDownQueryFunction
);
groupTemplate
.
registerFunctionPackage
(
"dict"
,
dictDownQueryFunction
);
// 模板页面判断是否有按钮权限,比如canAccess
// 模板页面判断是否有按钮权限,比如canAccess
groupTemplate
.
registerFunction
(
"canAccess"
,
new
Function
()
{
groupTemplate
.
registerFunction
(
"canAccess"
,
new
Function
()
{
@Override
@Override
public
Boolean
call
(
Object
[]
paras
,
Context
ctx
)
{
public
Boolean
call
(
Object
[]
paras
,
Context
ctx
)
{
...
@@ -115,52 +102,53 @@ public class BeetlConf {
...
@@ -115,52 +102,53 @@ public class BeetlConf {
String
functionCode
=
(
String
)
paras
[
0
];
String
functionCode
=
(
String
)
paras
[
0
];
return
platFormService
.
canAcessFunction
(
userId
,
orgId
,
functionCode
);
return
platFormService
.
canAcessFunction
(
userId
,
orgId
,
functionCode
);
}
}
});
});
groupTemplate
.
registerFunction
(
"abcd"
,
new
Function
()
{
groupTemplate
.
registerFunction
(
"abcd"
,
new
Function
()
{
@Override
@Override
public
Boolean
call
(
Object
[]
paras
,
Context
ctx
)
{
public
Boolean
call
(
Object
[]
paras
,
Context
ctx
)
{
return
true
;
return
true
;
}
}
});
});
groupTemplate
.
registerFunction
(
"env"
,
new
Function
()
{
groupTemplate
.
registerFunction
(
"env"
,
new
Function
()
{
@Override
@Override
public
String
call
(
Object
[]
paras
,
Context
ctx
)
{
public
String
call
(
Object
[]
paras
,
Context
ctx
)
{
String
key
=
(
String
)
paras
[
0
];
String
key
=
(
String
)
paras
[
0
];
String
value
=
env
.
getProperty
(
key
);
String
value
=
env
.
getProperty
(
key
);
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
return
getStr
(
value
);
return
getStr
(
value
);
}
}
if
(
paras
.
length
==
2
)
{
if
(
paras
.
length
==
2
)
{
return
(
String
)
paras
[
1
];
return
(
String
)
paras
[
1
];
}
}
return
null
;
return
null
;
}
}
protected
String
getStr
(
String
str
)
{
protected
String
getStr
(
String
str
)
{
try
{
try
{
return
new
String
(
str
.
getBytes
(
"iso8859-1"
),
"UTF-8"
);
return
new
String
(
str
.
getBytes
(
"iso8859-1"
),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
}
});
});
groupTemplate
.
registerFunction
(
"dataAccessList"
,
new
Function
()
{
groupTemplate
.
registerFunction
(
"dataAccessList"
,
new
Function
()
{
@Override
@Override
public
List
<
DataAccess
>
call
(
Object
[]
paras
,
Context
ctx
)
{
public
List
<
DataAccess
>
call
(
Object
[]
paras
,
Context
ctx
)
{
return
dataAccessFactory
.
all
();
return
dataAccessFactory
.
all
();
}
}
});
});
}
}
};
};
}
}
...
@@ -178,5 +166,4 @@ public class BeetlConf {
...
@@ -178,5 +166,4 @@ public class BeetlConf {
return
;
return
;
}
}
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/CacheConfig.java
View file @
18144407
...
@@ -27,11 +27,10 @@ import org.springframework.data.redis.serializer.RedisSerializationContext.Seria
...
@@ -27,11 +27,10 @@ import org.springframework.data.redis.serializer.RedisSerializationContext.Seria
* 支持一二级缓存,使得性能逆天快.默认不开启
* 支持一二级缓存,使得性能逆天快.默认不开启
*
*
* @author xiandafu
* @author xiandafu
*
*/
*/
//@Configuration
//
@Configuration
//@ConditionalOnProperty(name="springext.cache.enabled", havingValue="true" ,matchIfMissing=false)
//
@ConditionalOnProperty(name="springext.cache.enabled", havingValue="true" ,matchIfMissing=false)
public
class
CacheConfig
{
public
class
CacheConfig
{
// 定义一个redis 的频道,默认叫cache,用于pub/sub
// 定义一个redis 的频道,默认叫cache,用于pub/sub
...
@@ -41,10 +40,13 @@ public class CacheConfig {
...
@@ -41,10 +40,13 @@ public class CacheConfig {
@Bean
@Bean
public
TowLevelCacheManager
cacheManager
(
RedisTemplate
redisTemplate
)
{
public
TowLevelCacheManager
cacheManager
(
RedisTemplate
redisTemplate
)
{
RedisCacheWriter
writer
=
RedisCacheWriter
.
lockingRedisCacheWriter
(
redisTemplate
.
getConnectionFactory
());
RedisCacheWriter
writer
=
SerializationPair
pair
=
SerializationPair
RedisCacheWriter
.
lockingRedisCacheWriter
(
redisTemplate
.
getConnectionFactory
());
.
fromSerializer
(
new
JdkSerializationRedisSerializer
(
this
.
getClass
().
getClassLoader
()));
SerializationPair
pair
=
RedisCacheConfiguration
config
=
RedisCacheConfiguration
.
defaultCacheConfig
().
serializeValuesWith
(
pair
);
SerializationPair
.
fromSerializer
(
new
JdkSerializationRedisSerializer
(
this
.
getClass
().
getClassLoader
()));
RedisCacheConfiguration
config
=
RedisCacheConfiguration
.
defaultCacheConfig
().
serializeValuesWith
(
pair
);
TowLevelCacheManager
cacheManager
=
new
TowLevelCacheManager
(
redisTemplate
,
writer
,
config
);
TowLevelCacheManager
cacheManager
=
new
TowLevelCacheManager
(
redisTemplate
,
writer
,
config
);
...
@@ -52,8 +54,8 @@ public class CacheConfig {
...
@@ -52,8 +54,8 @@ public class CacheConfig {
}
}
@Bean
@Bean
RedisMessageListenerContainer
container
(
RedisConnectionFactory
connectionFactory
,
RedisMessageListenerContainer
container
(
MessageListenerAdapter
listenerAdapter
)
{
RedisConnectionFactory
connectionFactory
,
MessageListenerAdapter
listenerAdapter
)
{
RedisMessageListenerContainer
container
=
new
RedisMessageListenerContainer
();
RedisMessageListenerContainer
container
=
new
RedisMessageListenerContainer
();
container
.
setConnectionFactory
(
connectionFactory
);
container
.
setConnectionFactory
(
connectionFactory
);
...
@@ -63,7 +65,8 @@ public class CacheConfig {
...
@@ -63,7 +65,8 @@ public class CacheConfig {
@Bean
@Bean
MessageListenerAdapter
listenerAdapter
(
final
TowLevelCacheManager
cacheManager
)
{
MessageListenerAdapter
listenerAdapter
(
final
TowLevelCacheManager
cacheManager
)
{
return
new
MessageListenerAdapter
(
new
MessageListener
()
{
return
new
MessageListenerAdapter
(
new
MessageListener
()
{
public
void
onMessage
(
Message
message
,
byte
[]
pattern
)
{
public
void
onMessage
(
Message
message
,
byte
[]
pattern
)
{
byte
[]
bs
=
message
.
getChannel
();
byte
[]
bs
=
message
.
getChannel
();
...
@@ -75,16 +78,16 @@ public class CacheConfig {
...
@@ -75,16 +78,16 @@ public class CacheConfig {
e
.
printStackTrace
();
e
.
printStackTrace
();
// 不可能出错,忽略
// 不可能出错,忽略
}
}
}
}
});
});
}
}
class
TowLevelCacheManager
extends
RedisCacheManager
{
class
TowLevelCacheManager
extends
RedisCacheManager
{
RedisTemplate
redisTemplate
;
RedisTemplate
redisTemplate
;
public
TowLevelCacheManager
(
RedisTemplate
redisTemplate
,
RedisCacheWriter
cacheWriter
,
public
TowLevelCacheManager
(
RedisTemplate
redisTemplate
,
RedisCacheWriter
cacheWriter
,
RedisCacheConfiguration
defaultCacheConfiguration
)
{
RedisCacheConfiguration
defaultCacheConfiguration
)
{
super
(
cacheWriter
,
defaultCacheConfiguration
);
super
(
cacheWriter
,
defaultCacheConfiguration
);
this
.
redisTemplate
=
redisTemplate
;
this
.
redisTemplate
=
redisTemplate
;
...
@@ -108,7 +111,6 @@ public class CacheConfig {
...
@@ -108,7 +111,6 @@ public class CacheConfig {
cache
.
clearLocal
();
cache
.
clearLocal
();
}
}
}
}
}
}
class
RedisAndLocalCache
implements
Cache
{
class
RedisAndLocalCache
implements
Cache
{
...
@@ -146,7 +148,6 @@ public class CacheConfig {
...
@@ -146,7 +148,6 @@ public class CacheConfig {
return
wrapper
;
return
wrapper
;
}
}
}
}
@Override
@Override
...
@@ -165,7 +166,6 @@ public class CacheConfig {
...
@@ -165,7 +166,6 @@ public class CacheConfig {
System
.
out
.
println
(
value
.
getClass
().
getClassLoader
());
System
.
out
.
println
(
value
.
getClass
().
getClassLoader
());
redisCache
.
put
(
key
,
value
);
redisCache
.
put
(
key
,
value
);
clearOtherJVM
();
clearOtherJVM
();
}
}
@Override
@Override
...
@@ -173,20 +173,17 @@ public class CacheConfig {
...
@@ -173,20 +173,17 @@ public class CacheConfig {
ValueWrapper
v
=
redisCache
.
putIfAbsent
(
key
,
value
);
ValueWrapper
v
=
redisCache
.
putIfAbsent
(
key
,
value
);
clearOtherJVM
();
clearOtherJVM
();
return
v
;
return
v
;
}
}
@Override
@Override
public
void
evict
(
Object
key
)
{
public
void
evict
(
Object
key
)
{
redisCache
.
evict
(
key
);
redisCache
.
evict
(
key
);
clearOtherJVM
();
clearOtherJVM
();
}
}
@Override
@Override
public
void
clear
()
{
public
void
clear
()
{
redisCache
.
clear
();
redisCache
.
clear
();
}
}
public
void
clearLocal
()
{
public
void
clearLocal
()
{
...
@@ -196,7 +193,5 @@ public class CacheConfig {
...
@@ -196,7 +193,5 @@ public class CacheConfig {
protected
void
clearOtherJVM
()
{
protected
void
clearOtherJVM
()
{
cacheManager
.
publishMessage
(
redisCache
.
getName
());
cacheManager
.
publishMessage
(
redisCache
.
getName
());
}
}
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/CustomErrorController.java
View file @
18144407
package
com.ibeetl.admin.core.conf
;
package
com.ibeetl.admin.core.conf
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -40,8 +38,7 @@ public class CustomErrorController extends AbstractErrorController {
...
@@ -40,8 +38,7 @@ public class CustomErrorController extends AbstractErrorController {
private
static
final
String
ERROR_PATH
=
"/error"
;
private
static
final
String
ERROR_PATH
=
"/error"
;
Log
log
=
LogFactory
.
getLog
(
ErrorController
.
class
);
Log
log
=
LogFactory
.
getLog
(
ErrorController
.
class
);
@Autowired
@Autowired
ObjectMapper
objectMapper
;
ObjectMapper
objectMapper
;
public
CustomErrorController
()
{
public
CustomErrorController
()
{
super
(
new
DefaultErrorAttributes
());
super
(
new
DefaultErrorAttributes
());
...
@@ -49,27 +46,23 @@ public class CustomErrorController extends AbstractErrorController {
...
@@ -49,27 +46,23 @@ public class CustomErrorController extends AbstractErrorController {
@RequestMapping
(
ERROR_PATH
)
@RequestMapping
(
ERROR_PATH
)
public
ModelAndView
getErrorPath
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
ModelAndView
getErrorPath
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
Map
<
String
,
Object
>
model
=
Collections
.
unmodifiableMap
(
getErrorAttributes
(
Map
<
String
,
Object
>
model
=
Collections
.
unmodifiableMap
(
getErrorAttributes
(
request
,
false
));
request
,
false
));
Throwable
cause
=
getCause
(
request
);
Throwable
cause
=
getCause
(
request
);
int
status
=
(
Integer
)
model
.
get
(
"status"
);
int
status
=
(
Integer
)
model
.
get
(
"status"
);
// 错误信息
//错误信息
String
message
=
(
String
)
model
.
get
(
"message"
);
String
message
=
(
String
)
model
.
get
(
"message"
);
// 友好提示
//友好提示
String
errorMessage
=
getErrorMessage
(
cause
);
String
errorMessage
=
getErrorMessage
(
cause
);
String
requestPath
=
(
String
)
model
.
get
(
"path"
);
String
requestPath
=
(
String
)
model
.
get
(
"path"
);
List
<
FieldError
>
filedErrors
=
this
.
getFieldError
(
model
,
cause
);
List
<
FieldError
>
filedErrors
=
this
.
getFieldError
(
model
,
cause
);
// 后台打印日志信息方方便查错
log
.
error
(
status
+
":"
+
message
+
filedErrors
,
cause
);
//后台打印日志信息方方便查错
log
.
error
(
"requestPath"
+
":"
+
requestPath
);
log
.
error
(
status
+
":"
+
message
+
filedErrors
,
cause
);
log
.
error
(
"requestPath"
+
":"
+
requestPath
);
response
.
setStatus
(
status
);
response
.
setStatus
(
status
);
if
(!
isJsonRequest
(
request
)){
if
(!
isJsonRequest
(
request
))
{
ModelAndView
view
=
new
ModelAndView
(
"/error.html"
);
ModelAndView
view
=
new
ModelAndView
(
"/error.html"
);
view
.
addAllObjects
(
model
);
view
.
addAllObjects
(
model
);
view
.
addObject
(
"errorMessage"
,
errorMessage
);
view
.
addObject
(
"errorMessage"
,
errorMessage
);
...
@@ -79,44 +72,39 @@ public class CustomErrorController extends AbstractErrorController {
...
@@ -79,44 +72,39 @@ public class CustomErrorController extends AbstractErrorController {
return
view
;
return
view
;
}
else
{
}
else
{
if
(
filedErrors
==
null
){
if
(
filedErrors
==
null
)
{
if
(
status
==
404
){
if
(
status
==
404
)
{
writeJson
(
response
,
JsonResult
.
http404
(
requestPath
));
writeJson
(
response
,
JsonResult
.
http404
(
requestPath
));
}
else
{
}
else
{
writeJson
(
response
,
JsonResult
.
failMessage
(
getErrorMessage
(
cause
)));
writeJson
(
response
,
JsonResult
.
failMessage
(
getErrorMessage
(
cause
)));
}
}
}
else
{
}
else
{
writeJson
(
response
,
JsonResult
.
fail
(
this
.
wrapFieldErrors
(
filedErrors
)));
writeJson
(
response
,
JsonResult
.
fail
(
this
.
wrapFieldErrors
(
filedErrors
)));
}
}
return
null
;
return
null
;
}
}
}
}
protected
List
<
FieldError
>
getFieldError
(
Map
<
String
,
Object
>
model
,
Throwable
cause
){
protected
List
<
FieldError
>
getFieldError
(
Map
<
String
,
Object
>
model
,
Throwable
cause
)
{
List
<
FieldError
>
filedErrors
=
(
List
<
FieldError
>)
model
.
get
(
"errors"
);
List
<
FieldError
>
filedErrors
=
(
List
<
FieldError
>)
model
.
get
(
"errors"
);
if
(
filedErrors
!=
null
){
if
(
filedErrors
!=
null
)
{
return
filedErrors
;
return
filedErrors
;
}
}
if
(
cause
instanceof
FormFieldException
){
if
(
cause
instanceof
FormFieldException
)
{
FormFieldException
fe
=
(
FormFieldException
)
cause
;
FormFieldException
fe
=
(
FormFieldException
)
cause
;
return
fe
.
getErrors
();
return
fe
.
getErrors
();
}
}
return
null
;
return
null
;
}
}
protected
List
<
Map
<
String
,
String
>>
wrapFieldErrors
(
List
<
FieldError
>
errors
){
protected
List
<
Map
<
String
,
String
>>
wrapFieldErrors
(
List
<
FieldError
>
errors
)
{
List
<
Map
<
String
,
String
>>
list
=
new
ArrayList
<
Map
<
String
,
String
>>();
List
<
Map
<
String
,
String
>>
list
=
new
ArrayList
<
Map
<
String
,
String
>>();
for
(
FieldError
e
:
errors
){
for
(
FieldError
e
:
errors
)
{
Map
<
String
,
String
>
error
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
error
=
new
HashMap
<
String
,
String
>();
error
.
put
(
"field"
,
e
.
getField
());
error
.
put
(
"field"
,
e
.
getField
());
error
.
put
(
"message"
,
e
.
getDefaultMessage
());
error
.
put
(
"message"
,
e
.
getDefaultMessage
());
list
.
add
(
error
);
list
.
add
(
error
);
...
@@ -124,19 +112,18 @@ public class CustomErrorController extends AbstractErrorController {
...
@@ -124,19 +112,18 @@ public class CustomErrorController extends AbstractErrorController {
return
list
;
return
list
;
}
}
protected
boolean
isJsonRequest
(
HttpServletRequest
request
)
{
String
requestUri
=
(
String
)
request
.
getAttribute
(
"javax.servlet.error.request_uri"
);
protected
boolean
isJsonRequest
(
HttpServletRequest
request
){
if
(
requestUri
!=
null
&&
requestUri
.
endsWith
(
".json"
))
{
String
requestUri
=
(
String
)
request
.
getAttribute
(
"javax.servlet.error.request_uri"
);
if
(
requestUri
!=
null
&&
requestUri
.
endsWith
(
".json"
)){
return
true
;
return
true
;
}
else
{
}
else
{
return
(
request
.
getHeader
(
"Accept"
).
contains
(
"application/json"
)
||
(
request
.
getHeader
(
"X-Requested-With"
)
!=
null
return
(
request
.
getHeader
(
"Accept"
).
contains
(
"application/json"
)
||
(
request
.
getHeader
(
"X-Requested-With"
)
!=
null
&&
request
.
getHeader
(
"X-Requested-With"
).
contains
(
"XMLHttpRequest"
)));
&&
request
.
getHeader
(
"X-Requested-With"
).
contains
(
"XMLHttpRequest"
)));
}
}
}
}
protected
void
writeJson
(
HttpServletResponse
response
,
JsonResult
error
){
protected
void
writeJson
(
HttpServletResponse
response
,
JsonResult
error
)
{
response
.
setContentType
(
"application/json;charset=utf-8"
);
response
.
setContentType
(
"application/json;charset=utf-8"
);
try
{
try
{
response
.
getWriter
().
write
(
objectMapper
.
writeValueAsString
(
error
));
response
.
getWriter
().
write
(
objectMapper
.
writeValueAsString
(
error
));
...
@@ -146,16 +133,15 @@ public class CustomErrorController extends AbstractErrorController {
...
@@ -146,16 +133,15 @@ public class CustomErrorController extends AbstractErrorController {
}
}
protected
String
getErrorMessage
(
Throwable
ex
)
{
protected
String
getErrorMessage
(
Throwable
ex
)
{
if
(
ex
instanceof
PlatformException
){
if
(
ex
instanceof
PlatformException
)
{
return
ex
.
getMessage
();
return
ex
.
getMessage
();
}
else
{
}
else
{
return
"服务器错误,请联系管理员"
;
return
"服务器错误,请联系管理员"
;
}
}
}
}
protected
Throwable
getCause
(
HttpServletRequest
request
)
{
protected
Throwable
getCause
(
HttpServletRequest
request
)
{
Throwable
error
=
(
Throwable
)
request
.
getAttribute
(
"javax.servlet.error.exception"
);
Throwable
error
=
(
Throwable
)
request
.
getAttribute
(
"javax.servlet.error.exception"
);
if
(
error
!=
null
)
{
if
(
error
!=
null
)
{
while
(
error
instanceof
ServletException
&&
error
.
getCause
()
!=
null
)
{
while
(
error
instanceof
ServletException
&&
error
.
getCause
()
!=
null
)
{
error
=
((
ServletException
)
error
).
getCause
();
error
=
((
ServletException
)
error
).
getCause
();
...
@@ -164,12 +150,9 @@ public class CustomErrorController extends AbstractErrorController {
...
@@ -164,12 +150,9 @@ public class CustomErrorController extends AbstractErrorController {
return
error
;
return
error
;
}
}
@Override
@Override
public
String
getErrorPath
()
{
public
String
getErrorPath
()
{
// TODO Auto-generated method stub
// TODO Auto-generated method stub
return
null
;
return
null
;
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/DataSourceConfig.java
View file @
18144407
...
@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
com.zaxxer.hikari.HikariDataSource
;
import
com.zaxxer.hikari.HikariDataSource
;
@Configuration
@Configuration
public
class
DataSourceConfig
{
public
class
DataSourceConfig
{
@Bean
(
name
=
"baseDataSource"
)
@Bean
(
name
=
"baseDataSource"
)
...
@@ -19,6 +20,3 @@ public class DataSourceConfig {
...
@@ -19,6 +20,3 @@ public class DataSourceConfig {
return
ds
;
return
ds
;
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/FileSystemConfig.java
View file @
18144407
...
@@ -16,19 +16,19 @@ import com.ibeetl.admin.core.file.LocalFileService;
...
@@ -16,19 +16,19 @@ import com.ibeetl.admin.core.file.LocalFileService;
@Configuration
@Configuration
@ConditionalOnMissingBean
(
FileService
.
class
)
@ConditionalOnMissingBean
(
FileService
.
class
)
public
class
FileSystemConfig
{
public
class
FileSystemConfig
{
@Autowired
@Autowired
Environment
env
;
Environment
env
;
@Bean
@Bean
public
FileService
getFileService
(
ApplicationContext
ctx
)
{
public
FileService
getFileService
(
ApplicationContext
ctx
)
{
String
root
=
env
.
getProperty
(
"localFile.root"
);
String
root
=
env
.
getProperty
(
"localFile.root"
);
if
(
StringUtils
.
isEmpty
(
root
))
{
if
(
StringUtils
.
isEmpty
(
root
))
{
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
userDir
=
System
.
getProperty
(
"user.dir"
);
root
=
userDir
+
File
.
separator
+
"filesystem"
;
root
=
userDir
+
File
.
separator
+
"filesystem"
;
}
}
File
f
=
new
File
(
root
);
File
f
=
new
File
(
root
);
if
(!
f
.
exists
())
{
if
(!
f
.
exists
())
{
f
.
mkdirs
();
f
.
mkdirs
();
}
}
return
new
LocalFileService
(
ctx
,
root
);
return
new
LocalFileService
(
ctx
,
root
);
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/JasonConfig.java
View file @
18144407
...
@@ -25,43 +25,40 @@ public class JasonConfig {
...
@@ -25,43 +25,40 @@ public class JasonConfig {
ObjectMapper
objectMapper
=
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
objectMapper
.
setDateFormat
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
));
objectMapper
.
setDateFormat
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
));
objectMapper
.
configure
(
SerializationFeature
.
INDENT_OUTPUT
,
true
);
objectMapper
.
configure
(
SerializationFeature
.
INDENT_OUTPUT
,
true
);
SimpleModule
simpleModule
=
new
SimpleModule
(
"SimpleModule"
,
SimpleModule
simpleModule
=
new
SimpleModule
(
"SimpleModule"
,
Version
.
unknownVersion
());
Version
.
unknownVersion
());
simpleModule
.
addSerializer
(
JsonResult
.
class
,
new
CustomJsonResultSerializer
());
simpleModule
.
addSerializer
(
JsonResult
.
class
,
new
CustomJsonResultSerializer
());
objectMapper
.
registerModule
(
simpleModule
);
objectMapper
.
registerModule
(
simpleModule
);
return
objectMapper
;
return
objectMapper
;
}
}
/**
/**
* layui 前端要求后台返回的数据格式
* layui 前端要求后台返回的数据格式
* @author xiandafu
*
*
* @author xiandafu
*/
*/
public
static
class
CustomJsonResultSerializer
extends
JsonSerializer
<
JsonResult
>
{
public
static
class
CustomJsonResultSerializer
extends
JsonSerializer
<
JsonResult
>
{
public
CustomJsonResultSerializer
()
{
public
CustomJsonResultSerializer
()
{}
}
@Override
@Override
public
void
serialize
(
JsonResult
value
,
JsonGenerator
gen
,
SerializerProvider
serializers
)
throws
IOException
{
public
void
serialize
(
JsonResult
value
,
JsonGenerator
gen
,
SerializerProvider
serializers
)
throws
IOException
{
gen
.
writeStartObject
();
gen
.
writeStartObject
();
if
(
value
.
getCode
().
equals
(
"200"
))
{
if
(
value
.
getCode
().
equals
(
"200"
))
{
gen
.
writeObjectField
(
"code"
,
0
);
gen
.
writeObjectField
(
"code"
,
0
);
}
else
{
}
else
{
gen
.
writeObjectField
(
"code"
,
Integer
.
parseInt
(
value
.
getCode
()));
gen
.
writeObjectField
(
"code"
,
Integer
.
parseInt
(
value
.
getCode
()));
}
}
gen
.
writeStringField
(
"msg"
,
value
.
getMsg
());
gen
.
writeStringField
(
"msg"
,
value
.
getMsg
());
Object
data
=
value
.
getData
();
Object
data
=
value
.
getData
();
if
(
data
instanceof
PageQuery
)
{
if
(
data
instanceof
PageQuery
)
{
PageQuery
query
=
(
PageQuery
)(
data
);
PageQuery
query
=
(
PageQuery
)
(
data
);
gen
.
writeObjectField
(
"count"
,
query
.
getTotalRow
());
gen
.
writeObjectField
(
"count"
,
query
.
getTotalRow
());
gen
.
writeObjectField
(
"data"
,
query
.
getList
());
gen
.
writeObjectField
(
"data"
,
query
.
getList
());
}
else
{
}
else
{
gen
.
writeObjectField
(
"data"
,
data
);
gen
.
writeObjectField
(
"data"
,
data
);
}
}
gen
.
writeEndObject
();
gen
.
writeEndObject
();
}
}
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/MVCConf.java
View file @
18144407
...
@@ -47,12 +47,9 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
...
@@ -47,12 +47,9 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
public
static
final
String
DEFAULT_APP_NAME
=
"开发平台"
;
public
static
final
String
DEFAULT_APP_NAME
=
"开发平台"
;
/**
/** 系统名称,可以在application.properties中配置 app.name=xxx */
* 系统名称,可以在application.properties中配置
// @Value("${app.name}")
* app.name=xxx
// String appName;
*/
// @Value("${app.name}")
// String appName;
// 开发用的模拟当前用户和机构
// 开发用的模拟当前用户和机构
Long
useId
;
Long
useId
;
...
@@ -61,20 +58,15 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
...
@@ -61,20 +58,15 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
String
mvcTestPath
;
String
mvcTestPath
;
@Autowired
@Autowired
Environment
env
;
Environment
env
;
@Autowired
@Autowired
CoreUserService
userService
;
CoreUserService
userService
;
@Autowired
@Autowired
BeetlGroupUtilConfiguration
beetlGroupUtilConfiguration
;
BeetlGroupUtilConfiguration
beetlGroupUtilConfiguration
;
@Autowired
@Autowired
HttpRequestLocal
httpRequestLocal
;
HttpRequestLocal
httpRequestLocal
;
@Autowired
@Autowired
GroupTemplate
groupTemplate
;
GroupTemplate
groupTemplate
;
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
...
@@ -95,7 +87,6 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
...
@@ -95,7 +87,6 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
registry
.
addFormatter
(
new
DateFormatter
(
"yyyy-MM-dd"
));
registry
.
addFormatter
(
new
DateFormatter
(
"yyyy-MM-dd"
));
}
}
@Override
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
public
void
afterPropertiesSet
()
throws
Exception
{
this
.
useId
=
env
.
getProperty
(
"user.id"
,
Long
.
class
);
this
.
useId
=
env
.
getProperty
(
"user.id"
,
Long
.
class
);
...
@@ -103,21 +94,14 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
...
@@ -103,21 +94,14 @@ public class MVCConf implements WebMvcConfigurer, InitializingBean {
this
.
mvcTestPath
=
env
.
getProperty
(
"mvc.test.path"
);
this
.
mvcTestPath
=
env
.
getProperty
(
"mvc.test.path"
);
Map
<
String
,
Object
>
var
=
new
HashMap
<>(
5
);
Map
<
String
,
Object
>
var
=
new
HashMap
<>(
5
);
String
appName
=
env
.
getProperty
(
"app.name"
);
String
appName
=
env
.
getProperty
(
"app.name"
);
if
(
appName
==
null
)
{
if
(
appName
==
null
)
{
var
.
put
(
"appName"
,
DEFAULT_APP_NAME
);
var
.
put
(
"appName"
,
DEFAULT_APP_NAME
);
}
}
var
.
put
(
"jsVer"
,
System
.
currentTimeMillis
());
var
.
put
(
"jsVer"
,
System
.
currentTimeMillis
());
groupTemplate
.
setSharedVars
(
var
);
groupTemplate
.
setSharedVars
(
var
);
}
}
}
}
class
SessionInterceptor
implements
HandlerInterceptor
{
class
SessionInterceptor
implements
HandlerInterceptor
{
...
@@ -133,7 +117,8 @@ class SessionInterceptor implements HandlerInterceptor {
...
@@ -133,7 +117,8 @@ class SessionInterceptor implements HandlerInterceptor {
@Override
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
throws
Exception
{
if
(
conf
.
useId
!=
null
&&
conf
.
orgId
!=
null
if
(
conf
.
useId
!=
null
&&
conf
.
orgId
!=
null
&&
request
.
getSession
().
getAttribute
(
CorePlatformService
.
ACCESS_CURRENT_USER
)
==
null
)
{
&&
request
.
getSession
().
getAttribute
(
CorePlatformService
.
ACCESS_CURRENT_USER
)
==
null
)
{
// 模拟用户登录,用于快速开发,未来用rember么代替?
// 模拟用户登录,用于快速开发,未来用rember么代替?
CoreUser
user
=
conf
.
userService
.
getUserById
(
conf
.
useId
);
CoreUser
user
=
conf
.
userService
.
getUserById
(
conf
.
useId
);
...
@@ -143,22 +128,25 @@ class SessionInterceptor implements HandlerInterceptor {
...
@@ -143,22 +128,25 @@ class SessionInterceptor implements HandlerInterceptor {
request
.
getSession
().
setAttribute
(
CorePlatformService
.
ACCESS_CURRENT_ORG
,
org
);
request
.
getSession
().
setAttribute
(
CorePlatformService
.
ACCESS_CURRENT_ORG
,
org
);
request
.
getSession
().
setAttribute
(
CorePlatformService
.
ACCESS_USER_ORGS
,
orgs
);
request
.
getSession
().
setAttribute
(
CorePlatformService
.
ACCESS_USER_ORGS
,
orgs
);
request
.
getSession
().
setAttribute
(
"ip"
,
request
.
getRemoteHost
());
request
.
getSession
().
setAttribute
(
"ip"
,
request
.
getRemoteHost
());
}
}
httpRequestLocal
.
set
(
request
);
httpRequestLocal
.
set
(
request
);
return
true
;
return
true
;
}
}
@Override
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
public
void
postHandle
(
ModelAndView
modelAndView
)
throws
Exception
{
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
ModelAndView
modelAndView
)
throws
Exception
{
// do nothing
// do nothing
}
}
@Override
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
throws
Exception
{
throws
Exception
{
// do nothing
// do nothing
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/PasswordConfig.java
View file @
18144407
...
@@ -16,12 +16,10 @@ import com.ibeetl.admin.core.conf.PasswordConfig.PasswordEncryptService;
...
@@ -16,12 +16,10 @@ import com.ibeetl.admin.core.conf.PasswordConfig.PasswordEncryptService;
@ConditionalOnMissingBean
(
PasswordEncryptService
.
class
)
@ConditionalOnMissingBean
(
PasswordEncryptService
.
class
)
public
class
PasswordConfig
{
public
class
PasswordConfig
{
public
static
interface
PasswordEncryptService
{
public
static
interface
PasswordEncryptService
{
public
String
password
(
String
pwd
);
public
String
password
(
String
pwd
);
}
}
public
static
class
DefaultEncryptBean
implements
PasswordEncryptService
{
public
static
class
DefaultEncryptBean
implements
PasswordEncryptService
{
@Override
@Override
...
@@ -29,12 +27,10 @@ public class PasswordConfig {
...
@@ -29,12 +27,10 @@ public class PasswordConfig {
// 采用明文,系统应该提供自己的EncryptBean实现以代替默认
// 采用明文,系统应该提供自己的EncryptBean实现以代替默认
return
pwd
;
return
pwd
;
}
}
}
}
@Bean
@Bean
public
PasswordEncryptService
passwordEncryptBean
(){
public
PasswordEncryptService
passwordEncryptBean
()
{
return
new
DefaultEncryptBean
();
return
new
DefaultEncryptBean
();
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/RbacAnnotationConfig.java
View file @
18144407
...
@@ -27,21 +27,19 @@ import com.ibeetl.admin.core.util.PlatformException;
...
@@ -27,21 +27,19 @@ import com.ibeetl.admin.core.util.PlatformException;
@Aspect
@Aspect
@Component
@Component
public
class
RbacAnnotationConfig
{
public
class
RbacAnnotationConfig
{
@Autowired
@Autowired
CorePlatformService
platformService
;
CorePlatformService
platformService
;
@Autowired
CoreAuditService
sysAuditService
;
@Autowired
@Autowired
HttpRequestLocal
httpRequestLocal
;
CoreAuditService
sysAuditService
;
@Autowired
HttpRequestLocal
httpRequestLocal
;
@Autowired
@Autowired
Environment
env
;
Environment
env
;
ObjectMapper
jsonMapper
=
new
ObjectMapper
();
ObjectMapper
jsonMapper
=
new
ObjectMapper
();
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
@org
.
aspectj
.
lang
.
annotation
.
Around
(
"within(@org.springframework.stereotype.Controller *) && @annotation(function)"
)
@org
.
aspectj
.
lang
.
annotation
.
Around
(
public
Object
functionAccessCheck
(
final
ProceedingJoinPoint
pjp
,
Function
function
)
throws
Throwable
{
"within(@org.springframework.stereotype.Controller *) && @annotation(function)"
)
public
Object
functionAccessCheck
(
final
ProceedingJoinPoint
pjp
,
Function
function
)
throws
Throwable
{
// debug
// debug
String
funCode
=
null
;
String
funCode
=
null
;
CoreUser
user
=
null
;
CoreUser
user
=
null
;
...
@@ -62,32 +60,37 @@ public class RbacAnnotationConfig {
...
@@ -62,32 +60,37 @@ public class RbacAnnotationConfig {
Object
o
=
pjp
.
proceed
();
Object
o
=
pjp
.
proceed
();
if
(
function
!=
null
)
{
if
(
function
!=
null
)
{
MethodSignature
ms
=
(
MethodSignature
)
pjp
.
getSignature
();
MethodSignature
ms
=
(
MethodSignature
)
pjp
.
getSignature
();
m
=
ms
.
getMethod
();
m
=
ms
.
getMethod
();
createAudit
(
funCode
,
function
.
name
(),
user
,
true
,
""
,
m
);
createAudit
(
funCode
,
function
.
name
(),
user
,
true
,
""
,
m
);
}
}
return
o
;
return
o
;
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
if
(
function
!=
null
)
{
if
(
function
!=
null
)
{
createAudit
(
funCode
,
function
.
name
(),
user
,
false
,
e
.
getMessage
(),
m
);
createAudit
(
funCode
,
function
.
name
(),
user
,
false
,
e
.
getMessage
(),
m
);
}
}
throw
e
;
throw
e
;
}
}
}
}
private
void
createAudit
(
String
functionCode
,
String
functionName
,
CoreUser
user
,
boolean
success
,
String
msg
,
Method
m
)
{
private
void
createAudit
(
String
functionCode
,
String
functionName
,
CoreUser
user
,
boolean
success
,
String
msg
,
Method
m
)
{
boolean
enable
=
env
.
getProperty
(
"audit.enable"
,
Boolean
.
class
,
false
);
boolean
enable
=
env
.
getProperty
(
"audit.enable"
,
Boolean
.
class
,
false
);
if
(!
enable
)
{
if
(!
enable
)
{
return
;
return
;
}
}
if
(
filter
(
m
,
functionCode
)){
if
(
filter
(
m
,
functionCode
))
{
return
;
return
;
}
}
CoreAudit
audit
=
new
CoreAudit
();
CoreAudit
audit
=
new
CoreAudit
();
if
(
StringUtils
.
isEmpty
(
functionName
))
{
if
(
StringUtils
.
isEmpty
(
functionName
))
{
CoreFunction
fun
=
this
.
platformService
.
getFunction
(
functionCode
);
CoreFunction
fun
=
this
.
platformService
.
getFunction
(
functionCode
);
if
(
fun
==
null
)
{
if
(
fun
==
null
)
{
...
@@ -110,17 +113,16 @@ public class RbacAnnotationConfig {
...
@@ -110,17 +113,16 @@ public class RbacAnnotationConfig {
sysAuditService
.
save
(
audit
);
sysAuditService
.
save
(
audit
);
}
}
private
boolean
filter
(
Method
m
,
String
functionCode
){
private
boolean
filter
(
Method
m
,
String
functionCode
)
{
if
(
functionCode
.
startsWith
(
"audit."
)){
if
(
functionCode
.
startsWith
(
"audit."
))
{
return
true
;
return
true
;
}
}
String
uri
=
httpRequestLocal
.
getRequestURI
();
String
uri
=
httpRequestLocal
.
getRequestURI
();
if
(
uri
!=
null
&&
uri
.
endsWith
(
"/index/condition.json"
)){
if
(
uri
!=
null
&&
uri
.
endsWith
(
"/index/condition.json"
))
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/RbacDataAccessConfig.java
View file @
18144407
...
@@ -8,9 +8,7 @@ import org.springframework.context.annotation.Configuration;
...
@@ -8,9 +8,7 @@ import org.springframework.context.annotation.Configuration;
import
com.ibeetl.admin.core.rbac.DataAccessFactory
;
import
com.ibeetl.admin.core.rbac.DataAccessFactory
;
import
com.ibeetl.admin.core.rbac.da.DefaultDataAccessFactory
;
import
com.ibeetl.admin.core.rbac.da.DefaultDataAccessFactory
;
/**
/** 数据权限,可以自动装配 */
* 数据权限,可以自动装配
*/
@Configuration
@Configuration
public
class
RbacDataAccessConfig
{
public
class
RbacDataAccessConfig
{
@ConditionalOnMissingBean
(
DataAccessFactory
.
class
)
@ConditionalOnMissingBean
(
DataAccessFactory
.
class
)
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreAuditDao.java
View file @
18144407
...
@@ -6,10 +6,8 @@ import org.beetl.sql.core.mapper.BaseMapper;
...
@@ -6,10 +6,8 @@ import org.beetl.sql.core.mapper.BaseMapper;
import
com.ibeetl.admin.core.entity.CoreAudit
;
import
com.ibeetl.admin.core.entity.CoreAudit
;
/*
/*
*
*
* gen by starter mapper 2017-08-01
* gen by starter mapper 2017-08-01
*/
*/
@SqlResource
(
"core.coreAudit"
)
@SqlResource
(
"core.coreAudit"
)
public
interface
CoreAuditDao
extends
BaseMapper
<
CoreAudit
>
{
public
interface
CoreAuditDao
extends
BaseMapper
<
CoreAudit
>
{}
}
\ No newline at end of file
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreDictDao.java
View file @
18144407
...
@@ -9,14 +9,13 @@ import org.beetl.sql.core.mapper.BaseMapper;
...
@@ -9,14 +9,13 @@ import org.beetl.sql.core.mapper.BaseMapper;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.entity.CoreDict
;
/**
/** 字典DAO接口 */
* 字典DAO接口
*/
@SqlResource
(
"core.coreDict"
)
@SqlResource
(
"core.coreDict"
)
public
interface
CoreDictDao
extends
BaseMapper
<
CoreDict
>
{
public
interface
CoreDictDao
extends
BaseMapper
<
CoreDict
>
{
/**
/**
* 查询某个类型下的字典集合
* 查询某个类型下的字典集合
*
* @param type 字典类型
* @param type 字典类型
* @return
* @return
*/
*/
...
@@ -24,16 +23,16 @@ public interface CoreDictDao extends BaseMapper<CoreDict> {
...
@@ -24,16 +23,16 @@ public interface CoreDictDao extends BaseMapper<CoreDict> {
/**
/**
* 查询字段类型列表
* 查询字段类型列表
*
* @param delFlag 删除标记
* @param delFlag 删除标记
* @return
* @return
*/
*/
@SqlStatement
(
returnType
=
Map
.
class
)
@SqlStatement
(
returnType
=
Map
.
class
)
List
<
Map
<
String
,
String
>>
findTypeList
(
int
delFlag
);
List
<
Map
<
String
,
String
>>
findTypeList
(
int
delFlag
);
/**
/**
* 根据父节点Id查询子节点数据
* 根据父节点Id查询子节点数据
*
* @param id 父节点id
* @param id 父节点id
* @return
* @return
*/
*/
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreFileDao.java
View file @
18144407
...
@@ -7,5 +7,5 @@ import com.ibeetl.admin.core.entity.CoreFile;
...
@@ -7,5 +7,5 @@ import com.ibeetl.admin.core.entity.CoreFile;
public
interface
CoreFileDao
extends
BaseMapper
<
CoreFile
>
{
public
interface
CoreFileDao
extends
BaseMapper
<
CoreFile
>
{
@Sql
(
"update core_file set biz_type=?,biz_id=? where file_batch_id=?"
)
@Sql
(
"update core_file set biz_type=?,biz_id=? where file_batch_id=?"
)
public
void
updateBatchIdInfo
(
String
bizType
,
String
bizId
,
String
fileBatchId
);
public
void
updateBatchIdInfo
(
String
bizType
,
String
bizId
,
String
fileBatchId
);
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreFunctionDao.java
View file @
18144407
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreMenuDao.java
View file @
18144407
...
@@ -15,9 +15,7 @@ public interface CoreMenuDao extends BaseMapper<CoreMenu> {
...
@@ -15,9 +15,7 @@ public interface CoreMenuDao extends BaseMapper<CoreMenu> {
public
void
queryByCondtion
(
PageQuery
query
);
public
void
queryByCondtion
(
PageQuery
query
);
public
void
clearMenuFunction
(
List
<
Long
>
functionIds
);
public
void
clearMenuFunction
(
List
<
Long
>
functionIds
);
public
List
<
CoreMenu
>
allMenuWithURL
();
public
List
<
CoreMenu
>
allMenuWithURL
();
}
}
Prev
1
2
3
4
5
6
7
…
9
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