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-core/src/main/java/com/ibeetl/admin/core/service/CoreDictService.java
View file @
18144407
...
...
@@ -17,6 +17,7 @@ import com.ibeetl.admin.core.util.enums.DelFlagEnum;
/**
* 描述: 字典 service,包含常规字典和级联字典的操作。
*
* @author : xiandafu
*/
@Service
...
...
@@ -25,18 +26,15 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CoreDictService
.
class
);
@Autowired
private
CoreDictDao
dictDao
;
@Autowired
private
CoreDictDao
dictDao
;
@Autowired
CorePlatformService
platformService
;
@Autowired
CoreDictService
self
;
@Autowired
CorePlatformService
platformService
;
@Autowired
CoreDictService
self
;
/**
* 根据类型获取字典集合
*
* @param type 字典类型,
* @return List
*/
...
...
@@ -47,19 +45,20 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
/**
* 级联字典查询,必须提供一个字典类型
*
* @param group
* @param value
* @return
*/
@Cacheable
(
value
=
CorePlatformService
.
DICT_CACHE_CHILDREN
)
public
List
<
CoreDict
>
findAllByGroup
(
String
type
,
String
value
)
{
public
List
<
CoreDict
>
findAllByGroup
(
String
type
,
String
value
)
{
List
<
CoreDict
>
list
=
self
.
findAllByType
(
type
);
return
_search
(
list
,
value
);
return
_search
(
list
,
value
);
}
/**
* 级联字段下一级的字段列表
*
* @param parentValue
* @return
*/
...
...
@@ -69,13 +68,13 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
}
@Cacheable
(
value
=
CorePlatformService
.
DICT_CACHE_VALUE
)
public
CoreDict
findCoreDict
(
String
type
,
String
value
)
{
public
CoreDict
findCoreDict
(
String
type
,
String
value
)
{
List
<
CoreDict
>
list
=
self
.
findAllByGroup
(
type
,
value
);
if
(
list
==
null
)
{
if
(
list
==
null
)
{
return
null
;
}
for
(
CoreDict
dict
:
list
)
{
if
(
dict
.
getValue
().
equals
(
value
))
{
for
(
CoreDict
dict
:
list
)
{
if
(
dict
.
getValue
().
equals
(
value
))
{
return
dict
;
}
}
...
...
@@ -84,49 +83,41 @@ public class CoreDictService extends CoreBaseService<CoreDict> {
}
/*通过名字反向查找数据字典,通常用于excel导入*/
public
Map
<
String
,
CoreDict
>
mapDictByName
(
String
type
){
public
Map
<
String
,
CoreDict
>
mapDictByName
(
String
type
)
{
List
<
CoreDict
>
list
=
self
.
findAllByType
(
type
);
Map
<
String
,
CoreDict
>
map
=
new
HashMap
<
String
,
CoreDict
>();
for
(
CoreDict
dict
:
list
)
{
Map
<
String
,
CoreDict
>
map
=
new
HashMap
<
String
,
CoreDict
>();
for
(
CoreDict
dict
:
list
)
{
map
.
put
(
dict
.
getName
(),
dict
);
}
return
map
;
}
/*递归查找*/
private
List
<
CoreDict
>
_search
(
List
<
CoreDict
>
list
,
String
value
)
{
for
(
CoreDict
dict
:
list
)
{
if
(
dict
.
getValue
().
equals
(
value
))
{
private
List
<
CoreDict
>
_search
(
List
<
CoreDict
>
list
,
String
value
)
{
for
(
CoreDict
dict
:
list
)
{
if
(
dict
.
getValue
().
equals
(
value
))
{
return
list
;
}
else
{
}
else
{
List
<
CoreDict
>
children
=
findChildByParent
(
dict
.
getId
());
if
(
children
.
isEmpty
())
{
if
(
children
.
isEmpty
())
{
continue
;
}
else
{
List
<
CoreDict
>
ret
=
_search
(
children
,
value
);
if
(
ret
!=
null
)
{
}
else
{
List
<
CoreDict
>
ret
=
_search
(
children
,
value
);
if
(
ret
!=
null
)
{
return
ret
;
}
}
}
}
return
null
;
}
/**
* 查询字段类型列表
*
* @return
*/
public
List
<
Map
<
String
,
String
>>
findTypeList
()
{
return
dictDao
.
findTypeList
(
DelFlagEnum
.
NORMAL
.
getValue
());
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/service/CorePlatformService.java
View file @
18144407
...
...
@@ -39,17 +39,17 @@ import com.ibeetl.admin.core.util.enums.DelFlagEnum;
/**
* 系统平台功能访问入口,所有方法应该支持缓存或者快速访问
*
* @author xiandafu
*/
@Service
public
class
CorePlatformService
{
//菜单树,组织机构树,功能树缓存标记
// 菜单树,组织机构树,功能树缓存标记
public
static
final
String
MENU_TREE_CACHE
=
"cache:core:menuTree"
;
public
static
final
String
ORG_TREE_CACHE
=
"cache:core:orgTree"
;
public
static
final
String
FUNCTION_TREE_CACHE
=
"cache:core:functionTree"
;
//字典列表
//
字典列表
public
static
final
String
DICT_CACHE_TYPE
=
"cache:core:dictType"
;
public
static
final
String
DICT_CACHE_VALUE
=
"cache:core:dictValue"
;
public
static
final
String
DICT_CACHE_SAME_LEVEL
=
"cache:core:ditcSameLevel"
;
...
...
@@ -70,92 +70,73 @@ public class CorePlatformService {
public
static
final
String
ACCESS_SUPPER_ADMIN
=
"admin"
;
@Autowired
HttpRequestLocal
httpRequestLocal
;
@Autowired
HttpRequestLocal
httpRequestLocal
;
@Autowired
CoreRoleFunctionDao
roleFunctionDao
;
@Autowired
CoreRoleFunctionDao
roleFunctionDao
;
@Autowired
CoreRoleMenuDao
sysRoleMenuDao
;
@Autowired
CoreRoleMenuDao
sysRoleMenuDao
;
@Autowired
CoreOrgDao
sysOrgDao
;
@Autowired
CoreOrgDao
sysOrgDao
;
@Autowired
CoreRoleFunctionDao
sysRoleFunctionDao
;
@Autowired
CoreRoleFunctionDao
sysRoleFunctionDao
;
@Autowired
CoreMenuDao
sysMenuDao
;
@Autowired
CoreMenuDao
sysMenuDao
;
@Autowired
CoreUserDao
sysUserDao
;
@Autowired
CoreUserDao
sysUserDao
;
@Autowired
CoreFunctionDao
sysFunctionDao
;
@Autowired
CoreFunctionDao
sysFunctionDao
;
@Autowired
SQLManager
sqlManager
;
@Autowired
SQLManager
sqlManager
;
@Autowired
DataAccessFunction
dataAccessFunction
;
@Autowired
DataAccessFunction
dataAccessFunction
;
@Autowired
CorePlatformService
self
;
@Autowired
DataAccessFactory
dataAccessFactory
;
@Autowired
CorePlatformService
self
;
@Autowired
DataAccessFactory
dataAccessFactory
;
@PostConstruct
@SuppressWarnings
(
"unchecked"
)
public
void
init
()
{
SQLPlaceholderST
.
textFunList
.
add
(
"function"
);
//sql语句里带有此函数来判断数据权限
//
sql语句里带有此函数来判断数据权限
sqlManager
.
getBeetl
().
getGroupTemplate
().
registerFunction
(
"function"
,
dataAccessFunction
);
sqlManager
.
getBeetl
().
getGroupTemplate
().
registerFunction
(
"nextDay"
,
new
NextDayFunction
());
}
public
CoreUser
getCurrentUser
()
{
checkSession
();
CoreUser
user
=
(
CoreUser
)
httpRequestLocal
.
getSessionValue
(
ACCESS_CURRENT_USER
);
return
user
;
}
public
void
changeOrg
(
Long
orgId
)
{
List
<
CoreOrg
>
orgs
=
this
.
getCurrentOrgs
();
for
(
CoreOrg
org
:
orgs
)
{
if
(
org
.
getId
().
equals
(
orgId
))
{
for
(
CoreOrg
org
:
orgs
)
{
if
(
org
.
getId
().
equals
(
orgId
))
{
httpRequestLocal
.
setSessionValue
(
CorePlatformService
.
ACCESS_CURRENT_ORG
,
org
);
}
}
}
public
Long
getCurrentOrgId
()
{
checkSession
();
CoreOrg
org
=
(
CoreOrg
)
httpRequestLocal
.
getSessionValue
(
ACCESS_CURRENT_ORG
);
return
org
.
getId
();
}
public
CoreOrg
getCurrentOrg
()
{
checkSession
();
CoreOrg
org
=
(
CoreOrg
)
httpRequestLocal
.
getSessionValue
(
ACCESS_CURRENT_ORG
);
return
org
;
}
public
List
<
CoreOrg
>
getCurrentOrgs
()
{
List
<
CoreOrg
>
orgs
=
(
List
<
CoreOrg
>)
httpRequestLocal
.
getSessionValue
(
ACCESS_USER_ORGS
);
return
orgs
;
}
protected
void
checkSession
()
{
CoreOrg
org
=
(
CoreOrg
)
httpRequestLocal
.
getSessionValue
(
ACCESS_CURRENT_ORG
);
if
(
org
==
null
)
{
if
(
org
==
null
)
{
throw
new
PlatformException
(
"会话过期,重新登录"
);
}
}
...
...
@@ -164,7 +145,6 @@ public class CorePlatformService {
httpRequestLocal
.
setSessionValue
(
CorePlatformService
.
ACCESS_CURRENT_USER
,
user
);
httpRequestLocal
.
setSessionValue
(
CorePlatformService
.
ACCESS_CURRENT_ORG
,
currentOrg
);
httpRequestLocal
.
setSessionValue
(
CorePlatformService
.
ACCESS_USER_ORGS
,
orgs
);
}
public
MenuItem
getMenuItem
(
long
userId
,
long
orgId
)
{
...
...
@@ -176,7 +156,6 @@ public class CorePlatformService {
MenuItem
menu
=
this
.
buildMenu
();
menu
.
filter
(
allows
);
return
menu
;
}
public
OrgItem
getUserOrgTree
()
{
...
...
@@ -185,24 +164,19 @@ public class CorePlatformService {
return
root
;
}
OrgItem
current
=
getCurrentOrgItem
();
OrgItem
item
=
dataAccessFactory
.
getUserOrgTree
(
current
);
OrgItem
item
=
dataAccessFactory
.
getUserOrgTree
(
current
);
return
item
;
}
@Cacheable
(
FUNCTION_CACHE
)
public
CoreFunction
getFunction
(
String
functionCode
)
{
return
sysFunctionDao
.
getFunctionByCode
(
functionCode
);
}
public
OrgItem
getCurrentOrgItem
()
{
//@TODO 无法缓存orgItem,因为组织机构在调整
//
@TODO 无法缓存orgItem,因为组织机构在调整
OrgItem
root
=
buildOrg
();
OrgItem
item
=
root
.
findChild
(
getCurrentOrgId
());
if
(
item
==
null
)
{
...
...
@@ -211,9 +185,9 @@ public class CorePlatformService {
return
item
;
}
/**
* 判断用户是否是超级管理员
*
* @param user
* @return
*/
...
...
@@ -226,12 +200,13 @@ public class CorePlatformService {
return
isSupperAdmin
(
user
);
}
public
boolean
isAllowUserName
(
String
name
){
public
boolean
isAllowUserName
(
String
name
)
{
return
!
name
.
startsWith
(
ACCESS_SUPPER_ADMIN
);
}
/**
* 获取用户在指定功能点的数据权限配置,如果没有,返回空集合
*
* @param userId
* @param orgId
* @param fucntionCode
...
...
@@ -243,15 +218,12 @@ public class CorePlatformService {
return
list
;
}
/**
* 当前用户是否能访问功能,用于后台功能验证,functionCode 目前只支持二级域名方式,不支持更多级别
*
* @param functionCode "user.add","user"
* @return
*/
@Cacheable
(
USER_FUNCTION_ACCESS_CACHE
)
public
boolean
canAcessFunction
(
Long
userId
,
Long
orgId
,
String
functionCode
)
{
...
...
@@ -264,17 +236,14 @@ public class CorePlatformService {
boolean
canAccess
=
!
list
.
isEmpty
();
if
(
canAccess
)
{
return
true
;
}
else
{
}
else
{
return
false
;
}
}
/**
* 当前功能的子功能,如果有,则页面需要做按钮级别的过滤
*
* @param userId
* @param orgId
* @param parentFunction 菜单对应的function
...
...
@@ -291,12 +260,11 @@ public class CorePlatformService {
Long
id
=
list
.
get
(
0
).
getId
();
return
sysRoleFunctionDao
.
getRoleChildrenFunction
(
userId
,
orgId
,
id
);
}
/**
* 查询当前用户有用的菜单项目,可以在随后验证是否能显示某项菜单
*
* @return
*/
@Cacheable
(
USER_MENU_CACHE
)
...
...
@@ -305,9 +273,9 @@ public class CorePlatformService {
return
new
HashSet
<
Long
>(
list
);
}
/**
* 验证菜单是否能被显示
*
* @param item
* @param allows
* @return
...
...
@@ -323,69 +291,82 @@ public class CorePlatformService {
public
MenuItem
buildMenu
()
{
List
<
CoreMenu
>
list
=
sysMenuDao
.
allMenuWithURL
();
return
MenuBuildUtil
.
buildMenuTree
(
list
);
}
@Cacheable
(
ORG_TREE_CACHE
)
public
OrgItem
buildOrg
()
{
CoreOrg
root
=
sysOrgDao
.
getRoot
();
OrgItem
rootItem
=
new
OrgItem
(
root
);
CoreOrg
org
=
new
CoreOrg
();
org
.
setDelFlag
(
DelFlagEnum
.
NORMAL
.
getValue
());
List
<
CoreOrg
>
list
=
sysOrgDao
.
template
(
org
);
OrgBuildUtil
.
buildTreeNode
(
rootItem
,
list
);
//集团
OrgBuildUtil
.
buildTreeNode
(
rootItem
,
list
);
//
集团
return
rootItem
;
}
@Cacheable
(
FUNCTION_TREE_CACHE
)
public
FunctionItem
buildFunction
()
{
List
<
CoreFunction
>
list
=
sysFunctionDao
.
all
();
return
FunctionBuildUtil
.
buildOrgTree
(
list
);
}
/**
* 用户信息被管理员修改,重置会话,让用户操作重新登录
*
* @param name
*/
public
void
restUserSession
(
String
name
){
//TODO
}
@CacheEvict
(
cacheNames
=
{
FUNCTION_CACHE
,
FUNCTION_TREE_CACHE
,
/*功能点本身缓存*/
MENU_TREE_CACHE
,
USER_MENU_CACHE
,
/*功能点关联菜单缓存*/
USER_FUNCTION_ACCESS_CACHE
,
USER_FUNCTION_CHIDREN_CACHE
,
USER_DATA_ACCESS_CACHE
,
/*功能点相关权限缓存*/
},
allEntries
=
true
)
public
void
restUserSession
(
String
name
)
{
// TODO
}
@CacheEvict
(
cacheNames
=
{
FUNCTION_CACHE
,
FUNCTION_TREE_CACHE
,
/*功能点本身缓存*/
MENU_TREE_CACHE
,
USER_MENU_CACHE
,
/*功能点关联菜单缓存*/
USER_FUNCTION_ACCESS_CACHE
,
USER_FUNCTION_CHIDREN_CACHE
,
USER_DATA_ACCESS_CACHE
,
/*功能点相关权限缓存*/
},
allEntries
=
true
)
public
void
clearFunctionCache
()
{
//没有做任何事情,交给spring cache来处理了
//
没有做任何事情,交给spring cache来处理了
}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
MENU_TREE_CACHE
,
CorePlatformService
.
USER_MENU_CACHE
},
allEntries
=
true
)
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
MENU_TREE_CACHE
,
CorePlatformService
.
USER_MENU_CACHE
},
allEntries
=
true
)
public
void
clearMenuCache
()
{
//没有做任何事情,交给spring cache来处理了
//
没有做任何事情,交给spring cache来处理了
}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
DICT_CACHE_CHILDREN
,
CorePlatformService
.
DICT_CACHE_SAME_LEVEL
,
CorePlatformService
.
DICT_CACHE_TYPE
,
CorePlatformService
.
DICT_CACHE_VALUE
},
allEntries
=
true
)
public
void
clearDictCache
()
{
}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
DICT_CACHE_CHILDREN
,
CorePlatformService
.
DICT_CACHE_SAME_LEVEL
,
CorePlatformService
.
DICT_CACHE_TYPE
,
CorePlatformService
.
DICT_CACHE_VALUE
},
allEntries
=
true
)
public
void
clearDictCache
()
{}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
ORG_TREE_CACHE
},
allEntries
=
true
)
public
void
clearOrgCache
()
{
}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
ORG_TREE_CACHE
},
allEntries
=
true
)
public
void
clearOrgCache
()
{}
/**
* 得到类型为系统的菜单,通常就是根菜单下面
*
* @return
*/
public
List
<
MenuItem
>
getSysMenu
()
{
MenuItem
root
=
buildMenu
();
List
<
MenuItem
>
list
=
root
.
getChildren
();
for
(
MenuItem
item
:
list
)
{
if
(!
item
.
getData
().
getType
()
.
equals
(
CoreMenu
.
TYPE_SYSTEM
))
{
if
(!
item
.
getData
().
getType
().
equals
(
CoreMenu
.
TYPE_SYSTEM
))
{
throw
new
IllegalArgumentException
(
"本系统没有系统模块"
);
}
}
...
...
@@ -394,6 +375,7 @@ public class CorePlatformService {
/**
* 得到菜单的子菜单
*
* @param menuId
* @return
*/
...
...
@@ -402,9 +384,4 @@ public class CorePlatformService {
List
<
MenuItem
>
list
=
root
.
findChild
(
menuId
).
getChildren
();
return
list
;
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreRoleService.java
View file @
18144407
...
...
@@ -13,6 +13,7 @@ import com.ibeetl.admin.core.entity.CoreRole;
/**
* 描述: 字典 service,包含常规字典和级联字典的操作。
*
* @author : xiandafu
*/
@Service
...
...
@@ -21,18 +22,11 @@ public class CoreRoleService extends CoreBaseService<CoreRole> {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CoreRoleService
.
class
);
@Autowired
private
CoreRoleDao
roleDao
;
@Autowired
private
CoreRoleDao
roleDao
;
public
List
<
CoreRole
>
getAllRoles
(
String
type
){
public
List
<
CoreRole
>
getAllRoles
(
String
type
)
{
CoreRole
template
=
new
CoreRole
();
template
.
setType
(
type
);
return
roleDao
.
template
(
template
);
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreUserService.java
View file @
18144407
...
...
@@ -21,80 +21,75 @@ import com.ibeetl.admin.core.util.enums.GeneralStateEnum;
@Service
@Transactional
public
class
CoreUserService
{
@Autowired
CoreUserDao
userDao
;
@Autowired
CoreUserDao
userDao
;
@Autowired
CoreOrgDao
orgDao
;
@Autowired
CoreOrgDao
orgDao
;
@Autowired
PasswordEncryptService
passwordEncryptService
;
@Autowired
PasswordEncryptService
passwordEncryptService
;
@Autowired
SQLManager
sqlManager
;
public
UserLoginInfo
login
(
String
userName
,
String
password
){
public
UserLoginInfo
login
(
String
userName
,
String
password
)
{
CoreUser
query
=
new
CoreUser
();
query
.
setCode
(
userName
);
query
.
setPassword
(
passwordEncryptService
.
password
(
password
));
query
.
setState
(
GeneralStateEnum
.
ENABLE
.
getValue
());
CoreUser
user
=
userDao
.
createLambdaQuery
().
andEq
(
CoreUser:
:
getCode
,
userName
).
andEq
(
CoreUser:
:
getPassword
,
passwordEncryptService
.
password
(
password
)).
single
();
if
(
user
==
null
)
{
throw
new
PlatformException
(
"用户"
+
userName
+
"不存在或者密码错误"
);
CoreUser
user
=
userDao
.
createLambdaQuery
()
.
andEq
(
CoreUser:
:
getCode
,
userName
)
.
andEq
(
CoreUser:
:
getPassword
,
passwordEncryptService
.
password
(
password
))
.
single
();
if
(
user
==
null
)
{
throw
new
PlatformException
(
"用户"
+
userName
+
"不存在或者密码错误"
);
}
if
(!
user
.
getState
().
equals
(
GeneralStateEnum
.
ENABLE
.
getValue
())){
throw
new
PlatformException
(
"用户"
+
userName
+
"已经失效"
);
if
(!
user
.
getState
().
equals
(
GeneralStateEnum
.
ENABLE
.
getValue
()))
{
throw
new
PlatformException
(
"用户"
+
userName
+
"已经失效"
);
}
if
(
user
.
getDelFlag
()==
DelFlagEnum
.
DELETED
.
getValue
())
{
throw
new
PlatformException
(
"用户"
+
userName
+
"已经删除"
);
if
(
user
.
getDelFlag
()
==
DelFlagEnum
.
DELETED
.
getValue
())
{
throw
new
PlatformException
(
"用户"
+
userName
+
"已经删除"
);
}
List
<
CoreOrg
>
orgs
=
getUserOrg
(
user
.
getId
(),
user
.
getOrgId
());
List
<
CoreOrg
>
orgs
=
getUserOrg
(
user
.
getId
(),
user
.
getOrgId
());
UserLoginInfo
loginInfo
=
new
UserLoginInfo
();
loginInfo
.
setOrgs
(
orgs
);
loginInfo
.
setUser
(
user
);
return
loginInfo
;
}
public
List
<
CoreOrg
>
getUserOrg
(
long
userId
,
long
orgId
){
public
List
<
CoreOrg
>
getUserOrg
(
long
userId
,
long
orgId
)
{
List
<
CoreOrg
>
orgs
=
orgDao
.
queryOrgByUser
(
userId
);
if
(
orgs
.
isEmpty
()){
//没有赋值任何角色,默认给一个所在部门
if
(
orgs
.
isEmpty
())
{
//
没有赋值任何角色,默认给一个所在部门
CoreOrg
userOrg
=
orgDao
.
unique
(
orgId
);
orgs
.
add
(
userOrg
);
}
return
orgs
;
}
public
List
<
CoreUser
>
getAllUsersByRole
(
String
role
){
public
List
<
CoreUser
>
getAllUsersByRole
(
String
role
)
{
return
userDao
.
getUserByRole
(
role
);
}
public
CoreUser
getUserByCode
(
String
userName
){
public
CoreUser
getUserByCode
(
String
userName
)
{
CoreUser
user
=
new
CoreUser
();
user
.
setCode
(
userName
);
return
userDao
.
templateOne
(
user
);
}
public
void
update
(
CoreUser
user
){
public
void
update
(
CoreUser
user
)
{
userDao
.
updateById
(
user
);
}
public
CoreOrg
getOrgById
(
Long
orgId
){
public
CoreOrg
getOrgById
(
Long
orgId
)
{
return
orgDao
.
unique
(
orgId
);
}
public
CoreUser
getUserById
(
Long
userId
){
public
CoreUser
getUserById
(
Long
userId
)
{
return
userDao
.
unique
(
userId
);
}
public
List
<
String
>
getOrgCode
(
List
<
Long
>
orgIds
){
public
List
<
String
>
getOrgCode
(
List
<
Long
>
orgIds
)
{
return
orgDao
.
queryAllOrgCode
(
orgIds
);
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/AnnotationUtil.java
View file @
18144407
...
...
@@ -15,8 +15,7 @@ import java.util.Map;
*/
public
class
AnnotationUtil
{
private
AnnotationUtil
()
{
}
private
AnnotationUtil
()
{}
public
static
AnnotationUtil
getInstance
()
{
return
AnnotationUtilHolder
.
instance
;
...
...
@@ -30,7 +29,8 @@ public class AnnotationUtil {
* @return List<Map<String, Object>>
* @throws Exception
*/
public
List
<
Map
<
String
,
Object
>>
getAnnotations
(
Class
annotationClasss
,
Class
useAnnotationClass
)
{
public
List
<
Map
<
String
,
Object
>>
getAnnotations
(
Class
annotationClasss
,
Class
useAnnotationClass
)
{
List
<
Map
<
String
,
Object
>>
annotationMapList
=
new
ArrayList
<>();
Field
[]
fields
=
useAnnotationClass
.
getDeclaredFields
();
...
...
@@ -49,7 +49,6 @@ public class AnnotationUtil {
private
static
class
AnnotationUtilHolder
{
private
static
AnnotationUtil
instance
=
new
AnnotationUtil
();
private
AnnotationUtilHolder
()
{
}
private
AnnotationUtilHolder
()
{}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/ClassLoaderUtil.java
View file @
18144407
...
...
@@ -6,11 +6,11 @@ import org.slf4j.LoggerFactory;
import
com.ibeetl.admin.core.conf.RbacAnnotationConfig
;
public
class
ClassLoaderUtil
{
private
ClassLoaderUtil
()
{
private
ClassLoaderUtil
()
{}
}
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
RbacAnnotationConfig
.
class
);
public
static
Class
loadClass
(
String
clsName
){
public
static
Class
loadClass
(
String
clsName
)
{
Class
cls
=
null
;
try
{
cls
=
ClassLoaderUtil
.
class
.
getClassLoader
().
loadClass
(
clsName
);
...
...
@@ -24,12 +24,11 @@ public class ClassLoaderUtil {
}
}
if
(
cls
==
null
){
log
.
error
(
"params:{},message:{}"
,
clsName
,
"无法加载类"
);
throw
new
IllegalArgumentException
(
"不能加载"
+
clsName
);
if
(
cls
==
null
)
{
log
.
error
(
"params:{},message:{}"
,
clsName
,
"无法加载类"
);
throw
new
IllegalArgumentException
(
"不能加载"
+
clsName
);
}
return
cls
;
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/ConvertUtil.java
View file @
18144407
...
...
@@ -6,29 +6,29 @@ import java.util.List;
/**
* 数据格式转化类
* @author xiandafu
*
* @author xiandafu
*/
public
class
ConvertUtil
{
/**
* 转化逗号分隔的id到long数组,通常用于批量操作
*
* @param str
* @return
*/
public
static
List
<
Long
>
str2longs
(
String
str
){
if
(
str
.
length
()==
0
){
public
static
List
<
Long
>
str2longs
(
String
str
)
{
if
(
str
.
length
()
==
0
)
{
return
Collections
.
EMPTY_LIST
;
}
String
[]
array
=
str
.
split
(
","
);
List
<
Long
>
rets
=
new
ArrayList
(
array
.
length
);
int
i
=
0
;
for
(
String
id
:
array
){
try
{
for
(
String
id
:
array
)
{
try
{
rets
.
add
(
Long
.
parseLong
(
id
));
}
catch
(
Exception
ex
){
throw
new
RuntimeException
(
"转化 "
+
str
+
" 到Long数组出错"
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
"转化 "
+
str
+
" 到Long数组出错"
);
}
}
return
rets
;
}
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/DateUtil.java
View file @
18144407
...
...
@@ -8,8 +8,6 @@ public class DateUtil {
public
static
Date
MAX_DATE
=
maxDate
();
public
static
String
now
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
sdf
.
format
(
new
Date
());
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/ExcelError.java
View file @
18144407
...
...
@@ -5,20 +5,19 @@ public class ExcelError {
String
cell
;
String
msg
;
public
String
getCell
()
{
return
cell
;
}
public
void
setCell
(
String
cell
)
{
this
.
cell
=
cell
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/FileDownloadUtil.java
View file @
18144407
...
...
@@ -6,9 +6,10 @@ import java.io.OutputStream;
import
javax.servlet.http.HttpServletResponse
;
public
class
FileDownloadUtil
{
public
static
OutputStream
getDownLoad
(
HttpServletResponse
response
,
String
fileName
)
throws
IOException
{
public
static
OutputStream
getDownLoad
(
HttpServletResponse
response
,
String
fileName
)
throws
IOException
{
response
.
setContentType
(
"text/html; charset = UTF-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
fileName
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
fileName
);
return
response
.
getOutputStream
();
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/FileUtil.java
View file @
18144407
...
...
@@ -6,7 +6,7 @@ import java.io.InputStream;
import
java.io.OutputStream
;
public
class
FileUtil
{
public
static
void
copy
(
InputStream
input
,
OutputStream
os
)
{
public
static
void
copy
(
InputStream
input
,
OutputStream
os
)
{
try
{
byte
[]
buf
=
new
byte
[
1024
];
int
bytesRead
;
...
...
@@ -14,10 +14,9 @@ public class FileUtil {
os
.
write
(
buf
,
0
,
bytesRead
);
}
}
catch
(
Exception
ex
)
{
throw
new
PlatformException
(
"文件复制出错"
+
ex
);
}
finally
{
}
catch
(
Exception
ex
)
{
throw
new
PlatformException
(
"文件复制出错"
+
ex
);
}
finally
{
try
{
input
.
close
();
os
.
close
();
...
...
@@ -25,7 +24,6 @@ public class FileUtil {
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/FormFieldException.java
View file @
18144407
...
...
@@ -7,26 +7,22 @@ import org.springframework.validation.FieldError;
public
class
FormFieldException
extends
PlatformException
{
List
<
FieldError
>
errors
=
new
ArrayList
<
FieldError
>();
public
FormFieldException
()
{
super
();
}
public
FormFieldException
(
String
objectName
,
String
field
,
String
error
)
{
super
(
"field "
+
field
+
" "
+
error
);
FieldError
fields
=
new
FieldError
(
objectName
,
field
,
error
);
public
FormFieldException
(
String
objectName
,
String
field
,
String
error
)
{
super
(
"field "
+
field
+
" "
+
error
);
FieldError
fields
=
new
FieldError
(
objectName
,
field
,
error
);
errors
.
add
(
fields
);
}
public
List
<
FieldError
>
getErrors
()
{
return
errors
;
}
public
void
setErrors
(
List
<
FieldError
>
errors
)
{
this
.
errors
=
errors
;
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/FunctionBuildUtil.java
View file @
18144407
...
...
@@ -8,28 +8,27 @@ import com.ibeetl.admin.core.rbac.tree.FunctionItem;
/**
* 创建一个功能树,用于前端选择
* @author xiandafu
*
* @author xiandafu
*/
public
class
FunctionBuildUtil
{
private
FunctionBuildUtil
()
{
private
FunctionBuildUtil
()
{}
}
public
static
FunctionItem
buildOrgTree
(
List
<
CoreFunction
>
list
){
public
static
FunctionItem
buildOrgTree
(
List
<
CoreFunction
>
list
)
{
CoreFunction
root
=
new
CoreFunction
();
root
.
setId
(
0L
);
FunctionItem
rootOrg
=
new
FunctionItem
(
root
);
buildTreeNode
(
rootOrg
,
list
);
buildTreeNode
(
rootOrg
,
list
);
return
rootOrg
;
}
private
static
void
buildTreeNode
(
FunctionItem
parent
,
List
<
CoreFunction
>
list
){
private
static
void
buildTreeNode
(
FunctionItem
parent
,
List
<
CoreFunction
>
list
)
{
long
id
=
parent
.
getId
();
List
<
CoreFunction
>
dels
=
new
ArrayList
<>();
for
(
CoreFunction
SysFunction
:
list
){
if
(
SysFunction
.
getParentId
()!=
null
&&
SysFunction
.
getParentId
()==
id
){
for
(
CoreFunction
SysFunction
:
list
)
{
if
(
SysFunction
.
getParentId
()
!=
null
&&
SysFunction
.
getParentId
()
==
id
)
{
FunctionItem
item
=
new
FunctionItem
(
SysFunction
);
item
.
setParent
(
parent
);
dels
.
add
(
SysFunction
);
...
...
@@ -37,12 +36,11 @@ public class FunctionBuildUtil {
}
list
.
removeAll
(
dels
);
if
(
list
.
isEmpty
()){
return
;
if
(
list
.
isEmpty
())
{
return
;
}
for
(
FunctionItem
child
:
parent
.
getChildren
()){
buildTreeNode
(
child
,
list
);
for
(
FunctionItem
child
:
parent
.
getChildren
())
{
buildTreeNode
(
child
,
list
);
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/FunctionLocal.java
View file @
18144407
...
...
@@ -3,31 +3,27 @@ package com.ibeetl.admin.core.util;
import
javax.servlet.http.HttpSession
;
/**
* 用户Controller对应的功能
* {@link MVCConf}
* @author lijiazhi
* 用户Controller对应的功能 {@link MVCConf}
*
* @author lijiazhi
*/
public
class
FunctionLocal
{
private
FunctionLocal
(){
}
private
FunctionLocal
()
{}
private
static
final
ThreadLocal
<
String
>
sessions
=
new
ThreadLocal
<
String
>()
{
@Override
protected
String
initialValue
()
{
@Override
protected
String
initialValue
()
{
return
null
;
}
};
public
static
String
get
(){
public
static
String
get
()
{
return
sessions
.
get
();
}
public
static
void
set
(
String
session
){
public
static
void
set
(
String
session
)
{
sessions
.
set
(
session
);
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/HttpRequestLocal.java
View file @
18144407
...
...
@@ -10,81 +10,78 @@ import org.springframework.stereotype.Component;
import
com.ibeetl.admin.core.conf.MVCConf
;
/**
* 保留用户会话,以方便在业务代码任何地方调用
* {@link MVCConf}
* @author lijiazhi
* 保留用户会话,以方便在业务代码任何地方调用 {@link MVCConf}
*
* @author lijiazhi
*/
@Component
public
class
HttpRequestLocal
{
public
HttpRequestLocal
(){
}
public
HttpRequestLocal
()
{}
private
static
final
ThreadLocal
<
HttpServletRequest
>
requests
=
new
ThreadLocal
<
HttpServletRequest
>()
{
@Override
protected
HttpServletRequest
initialValue
()
{
@Override
protected
HttpServletRequest
initialValue
()
{
return
null
;
}
};
public
Object
getSessionValue
(
String
attr
){
public
Object
getSessionValue
(
String
attr
)
{
return
requests
.
get
().
getSession
().
getAttribute
(
attr
);
}
public
void
setSessionValue
(
String
attr
,
Object
obj
){
requests
.
get
().
getSession
().
setAttribute
(
attr
,
obj
);
public
void
setSessionValue
(
String
attr
,
Object
obj
)
{
requests
.
get
().
getSession
().
setAttribute
(
attr
,
obj
);
}
public
Object
getRequestValue
(
String
attr
){
public
Object
getRequestValue
(
String
attr
)
{
return
requests
.
get
().
getAttribute
(
attr
);
}
public
String
getRequestURI
(){
public
String
getRequestURI
()
{
return
requests
.
get
().
getRequestURI
();
}
public
String
getRequestIP
(){
public
String
getRequestIP
()
{
return
getIpAddr
(
requests
.
get
());
}
public
void
set
(
HttpServletRequest
request
){
public
void
set
(
HttpServletRequest
request
)
{
requests
.
set
(
request
);
}
/**
* 获取当前网络ip
*
* @param request
* @return
*/
public
String
getIpAddr
(
HttpServletRequest
request
)
{
public
String
getIpAddr
(
HttpServletRequest
request
)
{
String
ipAddress
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getRemoteAddr
();
if
(
ipAddress
.
equals
(
"127.0.0.1"
)
||
ipAddress
.
equals
(
"0:0:0:0:0:0:0:1"
))
{
//根据网卡取本机配置的IP
InetAddress
inet
=
null
;
if
(
ipAddress
.
equals
(
"127.0.0.1"
)
||
ipAddress
.
equals
(
"0:0:0:0:0:0:0:1"
))
{
//
根据网卡取本机配置的IP
InetAddress
inet
=
null
;
try
{
inet
=
InetAddress
.
getLocalHost
();
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
ipAddress
=
inet
.
getHostAddress
();
ipAddress
=
inet
.
getHostAddress
();
}
}
//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if
(
ipAddress
!=
null
&&
ipAddress
.
length
()
>
15
){
//"***.***.***.***".length() = 15
if
(
ipAddress
.
indexOf
(
","
)
>
0
){
ipAddress
=
ipAddress
.
substring
(
0
,
ipAddress
.
indexOf
(
","
));
//
对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if
(
ipAddress
!=
null
&&
ipAddress
.
length
()
>
15
)
{
//
"***.***.***.***".length() = 15
if
(
ipAddress
.
indexOf
(
","
)
>
0
)
{
ipAddress
=
ipAddress
.
substring
(
0
,
ipAddress
.
indexOf
(
","
));
}
}
return
ipAddress
;
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/MenuBuildUtil.java
View file @
18144407
...
...
@@ -9,9 +9,7 @@ import com.ibeetl.admin.core.entity.CoreMenu;
import
com.ibeetl.admin.core.rbac.tree.MenuItem
;
public
class
MenuBuildUtil
{
private
MenuBuildUtil
()
{
}
private
MenuBuildUtil
()
{}
public
static
MenuItem
buildMenuTree
(
List
<
CoreMenu
>
list
)
{
CoreMenu
root
=
new
CoreMenu
();
...
...
@@ -29,7 +27,6 @@ public class MenuBuildUtil {
return
;
}
long
id
=
parent
.
getId
();
List
<
CoreMenu
>
dels
=
new
ArrayList
<>();
for
(
CoreMenu
sysMenu
:
list
)
{
...
...
@@ -50,19 +47,17 @@ public class MenuBuildUtil {
for
(
MenuItem
child
:
parent
.
getChildren
())
{
buildTreeNode
(
child
,
list
);
}
}
private
static
void
sortMenu
(
List
<
MenuItem
>
children
)
{
Collections
.
sort
(
children
,
new
Comparator
<
MenuItem
>()
{
Collections
.
sort
(
children
,
new
Comparator
<
MenuItem
>()
{
@Override
public
int
compare
(
MenuItem
o1
,
MenuItem
o2
)
{
return
o1
.
getSeq
().
compareTo
(
o2
.
getSeq
());
}
});
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/OrgBuildUtil.java
View file @
18144407
...
...
@@ -7,19 +7,14 @@ import com.ibeetl.admin.core.entity.CoreOrg;
import
com.ibeetl.admin.core.rbac.tree.OrgItem
;
public
class
OrgBuildUtil
{
private
OrgBuildUtil
(){
}
public
static
void
buildTreeNode
(
OrgItem
parent
,
List
<
CoreOrg
>
list
){
private
OrgBuildUtil
()
{}
public
static
void
buildTreeNode
(
OrgItem
parent
,
List
<
CoreOrg
>
list
)
{
long
id
=
parent
.
getId
();
List
<
CoreOrg
>
dels
=
new
ArrayList
<>();
for
(
CoreOrg
sysOrg
:
list
){
if
(
sysOrg
.
getParentOrgId
()!=
null
&&
sysOrg
.
getParentOrgId
()==
id
){
for
(
CoreOrg
sysOrg
:
list
)
{
if
(
sysOrg
.
getParentOrgId
()
!=
null
&&
sysOrg
.
getParentOrgId
()
==
id
)
{
OrgItem
item
=
new
OrgItem
(
sysOrg
);
item
.
setParent
(
parent
);
dels
.
add
(
sysOrg
);
...
...
@@ -27,12 +22,11 @@ public class OrgBuildUtil {
}
list
.
removeAll
(
dels
);
if
(
list
.
isEmpty
()){
return
;
if
(
list
.
isEmpty
())
{
return
;
}
for
(
OrgItem
child
:
parent
.
getChildren
()){
buildTreeNode
(
child
,
list
);
for
(
OrgItem
child
:
parent
.
getChildren
())
{
buildTreeNode
(
child
,
list
);
}
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/PlatformException.java
View file @
18144407
...
...
@@ -5,12 +5,11 @@ public class PlatformException extends RuntimeException {
super
();
}
public
PlatformException
(
String
message
)
{
super
(
message
);
}
public
PlatformException
(
String
message
,
Throwable
e
){
super
(
message
,
e
);
public
PlatformException
(
String
message
,
Throwable
e
)
{
super
(
message
,
e
);
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/Tool.java
View file @
18144407
...
...
@@ -9,28 +9,27 @@ import java.util.Date;
* 常用工具类方法
*
* @author lijiazhi
*
*/
public
class
Tool
{
static
final
String
DATE_FORAMT
=
"yyyy-MM-dd"
;
static
final
String
DATETIME_FORAMT
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
Date
[]
parseDataRange
(
String
str
)
{
//查询范围
//
查询范围
String
[]
arrays
=
str
.
split
(
"至"
);
Date
min
=
parseDate
(
arrays
[
0
]);
Date
max
=
parseDate
(
arrays
[
1
]);
return
new
Date
[]
{
min
,
max
};
return
new
Date
[]
{
min
,
max
};
}
public
static
Date
[]
parseDataTimeRange
(
String
str
)
{
//查询范围
//
查询范围
String
[]
arrays
=
str
.
split
(
"至"
);
Date
min
=
parseDateWithPattern
(
arrays
[
0
],
DATETIME_FORAMT
);
Date
max
=
parseDateWithPattern
(
arrays
[
1
],
DATETIME_FORAMT
);
return
new
Date
[]
{
min
,
max
};
return
new
Date
[]
{
min
,
max
};
}
public
static
Date
parseDate
(
String
str
)
{
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/UUIDUtil.java
View file @
18144407
...
...
@@ -8,5 +8,4 @@ public class UUIDUtil {
String
randomUUIDString
=
uuid
.
toString
();
return
randomUUIDString
;
}
}
Prev
1
…
3
4
5
6
7
8
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