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
321361c9
Commit
321361c9
authored
Feb 21, 2018
by
xiandafu
Browse files
init
parent
2971e3f1
Changes
449
Hide whitespace changes
Inline
Side-by-side
admin-core/src/main/java/com/ibeetl/admin/core/service/CoreCodeGenService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.service
;
import
org.beetl.core.Configuration
;
import
org.beetl.core.GroupTemplate
;
import
org.beetl.core.Template
;
import
org.beetl.core.resource.ClasspathResourceLoader
;
import
org.beetl.sql.core.JavaType
;
import
org.beetl.sql.core.NameConversion
;
import
org.beetl.sql.core.SQLManager
;
import
org.beetl.sql.core.db.ClassDesc
;
import
org.beetl.sql.core.db.ColDesc
;
import
org.beetl.sql.core.db.MetadataManager
;
import
org.beetl.sql.core.db.TableDesc
;
import
org.beetl.sql.ext.gen.GenConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ibeetl.admin.core.gen.model.Attribute
;
import
com.ibeetl.admin.core.gen.model.Entity
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
/**
* 代码生成,用于根据表或者视图生成entity,mapper,service,conroller
* 未来可以生成swagger api,界面
* @author xiandafu
*/
@Service
public
class
CoreCodeGenService
{
@Autowired
SQLManager
sqlManager
;
public
List
<
Entity
>
getAllEntityInfo
(){
MetadataManager
meta
=
sqlManager
.
getMetaDataManager
();
Set
<
String
>
set
=
meta
.
allTable
();
List
<
Entity
>
list
=
new
ArrayList
<
Entity
>();
for
(
String
table:
set
)
{
list
.
add
(
getEntitySimpleInfo
(
table
));
}
return
list
;
}
public
Entity
getEntitySimpleInfo
(
String
table
)
{
MetadataManager
meta
=
sqlManager
.
getMetaDataManager
();
NameConversion
nc
=
sqlManager
.
getNc
();
TableDesc
tableDesc
=
meta
.
getTable
(
table
);
if
(
tableDesc
==
null
)
{
return
null
;
}
ClassDesc
classDesc
=
tableDesc
.
getClassDesc
(
nc
);
Entity
e
=
new
Entity
();
e
.
setName
(
nc
.
getClassName
(
table
));
e
.
setComment
(
tableDesc
.
getRemark
());
e
.
setTableName
(
table
);
return
e
;
}
public
Entity
getEntityInfo
(
String
table
)
{
MetadataManager
meta
=
sqlManager
.
getMetaDataManager
();
NameConversion
nc
=
sqlManager
.
getNc
();
TableDesc
tableDesc
=
meta
.
getTable
(
table
);
if
(
tableDesc
==
null
)
{
return
null
;
}
ClassDesc
classDesc
=
tableDesc
.
getClassDesc
(
nc
);
Entity
e
=
new
Entity
();
e
.
setName
(
nc
.
getClassName
(
table
));
e
.
setComment
(
tableDesc
.
getRemark
());
e
.
setTableName
(
table
);
e
.
setCode
(
getEntityCode
(
e
.
getName
()));
Set
<
String
>
cols
=
tableDesc
.
getCols
();
ArrayList
<
Attribute
>
attrs
=
new
ArrayList
<
Attribute
>();
int
i
=
1
;
for
(
String
col:
cols
)
{
ColDesc
desc
=
tableDesc
.
getColDesc
(
col
);
Attribute
attr
=
new
Attribute
();
attr
.
setColName
(
col
);
attr
.
setName
(
nc
.
getPropertyName
(
col
));
if
(
tableDesc
.
getIdNames
().
contains
(
col
))
{
//TODO,代码生成实际上用了一个Id,因此具备联合主键的,不应该生成代码
attr
.
setId
(
true
);
e
.
setIdAttribute
(
attr
);
}
attr
.
setComment
(
desc
.
remark
);
String
type
=
JavaType
.
getType
(
desc
.
sqlType
,
desc
.
size
,
desc
.
digit
);
if
(
type
.
equals
(
"Double"
)){
type
=
"BigDecimal"
;
}
if
(
type
.
equals
(
"Timestamp"
)){
type
=
"Date"
;
}
attr
.
setJavaType
(
type
);
setGetDisplayName
(
attr
);
attrs
.
add
(
attr
);
}
e
.
setList
(
attrs
);
return
e
;
}
//根据类名提供一个变量名
private
String
getEntityCode
(
String
s
)
{
//找到最后一个大写字母,以此为变量名
if
(
Character
.
isLowerCase
(
s
.
charAt
(
0
)))
return
s
;
else
return
(
new
StringBuilder
())
.
append
(
Character
.
toLowerCase
(
s
.
charAt
(
0
)))
.
append
(
s
.
substring
(
1
)).
toString
();
}
/*根据数据库注释来判断显示名称*/
private
void
setGetDisplayName
(
Attribute
attr
)
{
String
comment
=
attr
.
getComment
();
if
(
comment
==
null
)
{
attr
.
setDisplayName
(
attr
.
getName
());
return
;
}
String
displayName
=
null
;
int
index
=
comment
.
indexOf
(
","
);
if
(
index
!=-
1
)
{
displayName
=
comment
.
substring
(
0
,
index
);
attr
.
setDisplayName
(
displayName
);
}
else
{
attr
.
setDisplayName
(
attr
.
getName
());
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/service/CoreDictService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.core.dao.CoreDictDao
;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.enums.DelFlagEnum
;
/**
* 描述: 字典 service,包含常规字典和级联字典的操作。
* @author : xiandafu
*/
@Service
@Transactional
public
class
CoreDictService
extends
BaseService
<
CoreDict
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CoreDictService
.
class
);
@Autowired
private
CoreDictDao
dictDao
;
@Autowired
CorePlatformService
platformService
;
@Autowired
CoreDictService
self
;
/**
* 新增一条数据,返回int型主键值
* @param model 实体类
* @return
*/
public
String
saveReturnId
(
CoreDict
model
)
{
dictDao
.
insert
(
model
);
platformService
.
clearDictCache
();
return
model
.
getValue
();
}
/**
* 更新
* @param model 要更新的对象
* @return
*/
public
boolean
update
(
CoreDict
model
)
{
int
count
=
dictDao
.
updateTemplateById
(
model
);
if
(
count
>
0
)
{
platformService
.
clearDictCache
();
}
return
count
>
0
;
}
/**
* 根据类型获取字典集合
* @param type 字典类型,
* @return List
*/
@Cacheable
(
value
=
CorePlatformService
.
DICT_CACHE_TYPE
)
public
List
<
CoreDict
>
findAllByType
(
String
type
)
{
return
dictDao
.
findAllList
(
type
);
}
@Cacheable
(
value
=
CorePlatformService
.
DICT_CACHE_CHILDREN
)
public
List
<
CoreDict
>
findChildrenByValue
(
String
value
)
{
return
self
.
findChildByParent
(
value
);
}
@Cacheable
(
value
=
CorePlatformService
.
DICT_CACHE_VALUE
)
public
CoreDict
findCoreDict
(
String
value
)
{
CoreDict
dict
=
dictDao
.
unique
(
value
);
return
dict
;
}
/**
* 级联字典,查询字典值后的所有子孙字典
* @param value
* @return
*/
public
List
<
List
<
CoreDict
>>
batchFindChidren
(
String
value
){
List
<
List
<
CoreDict
>>
all
=
new
ArrayList
();
List
<
CoreDict
>
list
=
self
.
findChildrenByValue
(
value
);
if
(
list
.
isEmpty
())
{
return
all
;
}
else
{
all
.
add
(
list
);
addChildren
(
all
,
list
.
get
(
0
));
}
return
all
;
}
private
void
addChildren
(
List
<
List
<
CoreDict
>>
all
,
CoreDict
first
)
{
List
<
CoreDict
>
list
=
self
.
findChildrenByValue
(
first
.
getValue
());
if
(
list
.
size
()==
0
)
{
return
;
}
else
{
all
.
add
(
list
);
addChildren
(
all
,
list
.
get
(
0
));
}
}
/**
* 级连字典数据,根据字典类型,获取每一级的字典第一项,用于页面展示,参考DictUpQueryFunction
* @param type
* @return
*/
public
List
<
CoreDict
>
findDefalutLevel
(
String
type
){
CoreDict
dict
=
self
.
findAllByType
(
type
).
get
(
0
);
if
(
dict
==
null
)
{
throw
new
PlatformException
(
"字典不存在 ,type="
+
type
);
}
List
<
CoreDict
>
level
=
new
ArrayList
<
CoreDict
>();
level
.
add
(
dict
);
while
(
dict
!=
null
)
{
dict
=
self
.
getFirstCoreDictByParent
(
dict
.
getValue
());
if
(
dict
!=
null
)
{
level
.
add
(
dict
);
}
else
{
break
;
}
}
return
level
;
}
/**
* 级联字典,根据最末端的值,向上找到级联的每个字典
* @param value
* @return
*/
public
List
<
CoreDict
>
findLevelByValue
(
String
value
){
List
<
CoreDict
>
level
=
new
ArrayList
<
CoreDict
>();
CoreDict
dict
=
self
.
findCoreDict
(
value
);
if
(
dict
==
null
)
{
throw
new
PlatformException
(
"字典不存在,value= "
+
value
);
}
level
.
add
(
dict
);
while
(
dict
!=
null
)
{
String
strParentId
=
dict
.
getParent
();
if
(
StringUtils
.
isEmpty
(
strParentId
))
{
break
;
}
dict
=
self
.
findCoreDict
(
strParentId
);
level
.
add
(
0
,
dict
);
}
return
level
;
}
public
CoreDict
getFirstCoreDict
(
String
type
)
{
CoreDict
dict
=
(
CoreDict
)
dictDao
.
createQuery
().
lambda
().
andEq
(
CoreDict:
:
getType
,
type
).
desc
(
CoreDict:
:
getSort
).
single
();
return
dict
;
}
public
CoreDict
getFirstCoreDictByParent
(
String
value
)
{
List
<
CoreDict
>
list
=
self
.
findChildrenByValue
(
value
);
if
(
list
.
size
()==
0
)
{
return
null
;
}
return
list
.
get
(
0
);
}
/**
* 根据条件查询
* @param query 查询条件
*/
public
void
queryByCondtion
(
PageQuery
query
)
{
dictDao
.
queryByCondtion
(
query
);
}
/**
* 查询字段类型列表
* @return
*/
public
List
<
Map
<
String
,
String
>>
findTypeList
()
{
return
dictDao
.
findTypeList
(
DelFlagEnum
.
NORMAL
.
getValue
());
}
/**
* 级联字段下一级的字段列表
* @param parentValue
* @return
*/
public
List
<
CoreDict
>
findChildByParent
(
String
parentValue
)
{
return
dictDao
.
findChildByParent
(
parentValue
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/service/CorePlatformService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.service
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
javax.annotation.PostConstruct
;
import
org.beetl.sql.core.SQLManager
;
import
org.beetl.sql.core.engine.SQLPlaceholderST
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
com.ibeetl.admin.core.dao.CoreFunctionDao
;
import
com.ibeetl.admin.core.dao.CoreMenuDao
;
import
com.ibeetl.admin.core.dao.CoreOrgDao
;
import
com.ibeetl.admin.core.dao.CoreRoleFunctionDao
;
import
com.ibeetl.admin.core.dao.CoreRoleMenuDao
;
import
com.ibeetl.admin.core.dao.CoreUserDao
;
import
com.ibeetl.admin.core.entity.CoreFunction
;
import
com.ibeetl.admin.core.entity.CoreMenu
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.entity.CoreRoleFunction
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.rbac.DataAccessFactory
;
import
com.ibeetl.admin.core.rbac.tree.FunctionItem
;
import
com.ibeetl.admin.core.rbac.tree.MenuItem
;
import
com.ibeetl.admin.core.rbac.tree.OrgItem
;
import
com.ibeetl.admin.core.util.FunctionBuildUtil
;
import
com.ibeetl.admin.core.util.HttpRequestLocal
;
import
com.ibeetl.admin.core.util.MenuBuildUtil
;
import
com.ibeetl.admin.core.util.OrgBuildUtil
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.beetl.DataAccessFunction
;
import
com.ibeetl.admin.core.util.beetl.NextDayFunction
;
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_CHILDREN
=
"cache:core:dictChildren"
;
public
static
final
String
USER_FUNCTION_ACCESS_CACHE
=
"cache:core:userFunctionAccess"
;
public
static
final
String
USER_FUNCTION_CHIDREN_CACHE
=
"ccache:core:functionChildren"
;
public
static
final
String
FUNCTION_CACHE
=
"cache:core:function"
;
public
static
final
String
USER_DATA_ACCESS_CACHE
=
"cache:core:userDataAccess"
;
public
static
final
String
USER_MENU_CACHE
=
"cache:core:userMenu"
;
/*当前用户会话*/
public
static
final
String
ACCESS_CURRENT_USER
=
"core:user"
;
/*当前登录用户所在部门*/
public
static
final
String
ACCESS_CURRENT_ORG
=
"core:currentOrg"
;
/*用户可选部门*/
public
static
final
String
ACCESS_USER_ORGS
=
"core:orgs"
;
public
static
final
String
ACCESS_SUPPER_ADMIN
=
"admin"
;
@Autowired
HttpRequestLocal
httpRequestLocal
;
@Autowired
CoreRoleFunctionDao
roleFunctionDao
;
@Autowired
CoreRoleMenuDao
sysRoleMenuDao
;
@Autowired
CoreOrgDao
sysOrgDao
;
@Autowired
CoreRoleFunctionDao
sysRoleFunctionDao
;
@Autowired
CoreMenuDao
sysMenuDao
;
@Autowired
CoreUserDao
sysUserDao
;
@Autowired
CoreFunctionDao
sysFunctionDao
;
@Autowired
SQLManager
sqlManager
;
@Autowired
DataAccessFunction
dataAccessFunction
;
@Autowired
CorePlatformService
self
;
@Autowired
DataAccessFactory
dataAccessFactory
;
@PostConstruct
@SuppressWarnings
(
"unchecked"
)
public
void
init
()
{
SQLPlaceholderST
.
textFunList
.
add
(
"function"
);
//sql语句里带有此函数来判断数据权限
sqlManager
.
getBeetl
().
getGroupTemplate
().
registerFunction
(
"function"
,
dataAccessFunction
);
sqlManager
.
getBeetl
().
getGroupTemplate
().
registerFunction
(
"nextDay"
,
new
NextDayFunction
());
}
public
CoreUser
getCurrentUser
()
{
return
(
CoreUser
)
httpRequestLocal
.
getSessionValue
(
ACCESS_CURRENT_USER
);
}
public
void
changeOrg
(
Long
orgId
)
{
List
<
CoreOrg
>
orgs
=
this
.
getCurrentOrgs
();
for
(
CoreOrg
org:
orgs
)
{
if
(
org
.
getId
().
equals
(
orgId
))
{
httpRequestLocal
.
setSessionValue
(
CorePlatformService
.
ACCESS_CURRENT_ORG
,
org
);
}
}
}
public
Long
getCurrentOrgId
()
{
CoreOrg
org
=
(
CoreOrg
)
httpRequestLocal
.
getSessionValue
(
ACCESS_CURRENT_ORG
);
return
org
.
getId
();
}
public
CoreOrg
getCurrentOrg
()
{
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
;
}
public
void
setLoginUser
(
CoreUser
user
,
CoreOrg
currentOrg
,
List
<
CoreOrg
>
orgs
)
{
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
)
{
CoreUser
user
=
this
.
sysUserDao
.
unique
(
userId
);
if
(
this
.
isSupperAdmin
(
user
))
{
return
self
.
buildMenu
();
}
Set
<
Long
>
allows
=
self
.
getCurrentMenuIds
(
userId
,
orgId
);
MenuItem
menu
=
this
.
buildMenu
();
menu
.
filter
(
allows
);
return
menu
;
}
public
OrgItem
getUserOrgTree
()
{
if
(
this
.
isCurrentSupperAdmin
())
{
OrgItem
root
=
self
.
buildOrg
();
return
root
;
}
OrgItem
current
=
getCurrentOrgItem
();
OrgItem
item
=
dataAccessFactory
.
getUserOrgTree
(
current
);
return
item
;
}
@Cacheable
(
FUNCTION_CACHE
)
public
CoreFunction
getFunction
(
String
functionCode
)
{
return
sysFunctionDao
.
getFunctionByCode
(
functionCode
);
}
public
OrgItem
getCurrentOrgItem
()
{
//@TODO 无法缓存orgItem,因为组织机构在调整
OrgItem
root
=
buildOrg
();
OrgItem
item
=
root
.
findChild
(
getCurrentOrgId
());
if
(
item
==
null
)
{
throw
new
PlatformException
(
"未找到组织机构"
);
}
return
item
;
}
/**
* 判断用户是否是超级管理员
* @param user
* @return
*/
public
boolean
isSupperAdmin
(
CoreUser
user
)
{
return
user
.
getCode
().
startsWith
(
ACCESS_SUPPER_ADMIN
);
}
public
boolean
isCurrentSupperAdmin
()
{
CoreUser
user
=
this
.
getCurrentUser
();
return
isSupperAdmin
(
user
);
}
public
boolean
isAllowUserName
(
String
name
){
return
!
name
.
startsWith
(
ACCESS_SUPPER_ADMIN
);
}
/**
* 获取用户在指定功能点的数据权限配置,如果没有,返回空集合
* @param userId
* @param orgId
* @param fucntionCode
* @return
*/
@Cacheable
(
USER_DATA_ACCESS_CACHE
)
public
List
<
CoreRoleFunction
>
getRoleFunction
(
Long
userId
,
Long
orgId
,
String
fucntionCode
)
{
List
<
CoreRoleFunction
>
list
=
sysRoleFunctionDao
.
getRoleFunction
(
userId
,
orgId
,
fucntionCode
);
return
list
;
}
/**
* 当前用户是否能访问功能,用于后台功能验证,functionCode 目前只支持二级域名方式,不支持更多级别
* @param functionCode "user.add","user"
* @return
*/
@Cacheable
(
USER_FUNCTION_ACCESS_CACHE
)
public
boolean
canAcessFunction
(
Long
userId
,
Long
orgId
,
String
functionCode
)
{
CoreUser
user
=
getCurrentUser
();
if
(
user
.
getId
()
==
userId
&&
isSupperAdmin
(
user
))
{
return
true
;
}
String
str
=
functionCode
;
// do {
// List<SysRoleFunction> list = sysRoleFunctionDao.getRoleFunction(userId, orgId, str);
// boolean canAccess = !list.isEmpty();
// if (canAccess) {
// return true;
// }
// int index = str.lastIndexOf('.');
// if (index == -1) {
// break;
// }
// str = str.substring(0, index);
// } while (true);
List
<
CoreRoleFunction
>
list
=
sysRoleFunctionDao
.
getRoleFunction
(
userId
,
orgId
,
str
);
boolean
canAccess
=
!
list
.
isEmpty
();
if
(
canAccess
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
* 当前功能的子功能,如果有,则页面需要做按钮级别的过滤
* @param userId
* @param orgId
* @param parentFunction 菜单对应的function
* @return
*/
@Cacheable
(
USER_FUNCTION_CHIDREN_CACHE
)
public
List
<
String
>
getChildrenFunction
(
Long
userId
,
Long
orgId
,
String
parentFunction
)
{
CoreFunction
template
=
new
CoreFunction
();
template
.
setCode
(
parentFunction
);
List
<
CoreFunction
>
list
=
sysFunctionDao
.
template
(
template
);
if
(
list
.
size
()
!=
1
)
{
throw
new
PlatformException
(
"访问权限未配置"
);
}
Long
id
=
list
.
get
(
0
).
getId
();
return
sysRoleFunctionDao
.
getRoleChildrenFunction
(
userId
,
orgId
,
id
);
}
/**
* 查询当前用户有用的菜单项目,可以在随后验证是否能显示某项菜单
* @return
*/
@Cacheable
(
USER_MENU_CACHE
)
public
Set
<
Long
>
getCurrentMenuIds
(
Long
userId
,
Long
orgId
)
{
List
<
Long
>
list
=
sysRoleMenuDao
.
queryMenuByUser
(
userId
,
orgId
);
return
new
HashSet
<
Long
>(
list
);
}
/**
* 验证菜单是否能被显示
* @param item
* @param allows
* @return
*/
public
boolean
canShowMenu
(
CoreUser
user
,
MenuItem
item
,
Set
<
Long
>
allows
)
{
if
(
isSupperAdmin
(
user
))
{
return
true
;
}
return
allows
.
contains
(
item
.
getData
().
getId
());
}
@Cacheable
(
MENU_TREE_CACHE
)
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
);
//集团
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
clearFunctionCache
()
{
//没有做任何事情,交给spring cache来处理了
}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
MENU_TREE_CACHE
,
CorePlatformService
.
USER_MENU_CACHE
},
allEntries
=
true
)
public
void
clearMenuCache
()
{
//没有做任何事情,交给spring cache来处理了
}
@CacheEvict
(
cacheNames
=
{
CorePlatformService
.
DICT_CACHE_CHILDREN
,
CorePlatformService
.
DICT_CACHE_TYPE
,
CorePlatformService
.
DICT_CACHE_VALUE
},
allEntries
=
true
)
public
void
clearDictCache
()
{
}
@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
))
{
throw
new
IllegalArgumentException
(
"本系统没有系统模块"
);
}
}
return
list
;
}
/**
* 得到菜单的子菜单
* @param menuId
* @return
*/
public
List
<
MenuItem
>
getChildMenu
(
Long
menuId
)
{
MenuItem
root
=
buildMenu
();
List
<
MenuItem
>
list
=
root
.
findChild
(
menuId
).
getChildren
();
return
list
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/service/CoreRoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.service
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.core.dao.CoreRoleDao
;
import
com.ibeetl.admin.core.entity.CoreRole
;
import
com.ibeetl.admin.core.util.enums.DelFlagEnum
;
import
com.ibeetl.admin.core.util.enums.RoleTypeEnum
;
/**
* 描述: 字典 service,包含常规字典和级联字典的操作。
* @author : xiandafu
*/
@Service
@Transactional
public
class
CoreRoleService
extends
BaseService
<
CoreRole
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CoreRoleService
.
class
);
@Autowired
private
CoreRoleDao
roleDao
;
public
List
<
CoreRole
>
getAllRoles
(
String
type
){
CoreRole
template
=
new
CoreRole
();
template
.
setType
(
type
);
return
roleDao
.
template
(
template
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/service/CoreServiceLocator.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.service
;
/**
* 服务注册和发现,单机情况,注册在本地系统,多机情况,用zookeeper完成注册,计划改成Spring cloud
* @author lijiazhi
*
*/
public
interface
CoreServiceLocator
{
public
void
addServiceURI
(
String
path
,
String
url
);
public
String
getServiceURI
(
String
path
);
}
admin-core/src/main/java/com/ibeetl/admin/core/service/CoreUserService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.service
;
import
java.util.List
;
import
org.beetl.sql.core.SQLManager
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.core.conf.PasswordConfig
;
import
com.ibeetl.admin.core.conf.PasswordConfig.PasswordEncryptService
;
import
com.ibeetl.admin.core.dao.CoreOrgDao
;
import
com.ibeetl.admin.core.dao.CoreUserDao
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.rbac.UserLoginInfo
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.enums.DelFlagEnum
;
import
com.ibeetl.admin.core.util.enums.GeneralStateEnum
;
@Service
@Transactional
public
class
CoreUserService
{
@Autowired
CoreUserDao
userDao
;
@Autowired
CoreOrgDao
orgDao
;
@Autowired
PasswordEncryptService
passwordEncryptService
;
@Autowired
SQLManager
sqlManager
;
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
.
getSQLManager
().
templateOne
(
query
);
// SysUser user = userDao.templateOne(query);
if
(
user
==
null
){
return
null
;
}
if
(
user
.
getDelFlag
()==
DelFlagEnum
.
DELETED
.
getValue
()||
user
.
getState
()==
GeneralStateEnum
.
DISABLE
.
getValue
()){
throw
new
PlatformException
(
"用户"
+
userName
+
"已经删除或者失效"
);
}
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
){
List
<
CoreOrg
>
orgs
=
orgDao
.
queryOrgByUser
(
userId
);
if
(
orgs
.
isEmpty
()){
//没有赋值任何角色,默认给一个所在部门
CoreOrg
userOrg
=
orgDao
.
unique
(
orgId
);
orgs
.
add
(
userOrg
);
}
return
orgs
;
}
public
List
<
CoreUser
>
getAllUsersByRole
(
String
role
){
return
userDao
.
getUserByRole
(
role
);
}
public
CoreUser
getUserByCode
(
String
userName
){
CoreUser
user
=
new
CoreUser
();
user
.
setCode
(
userName
);
return
userDao
.
templateOne
(
user
);
}
public
void
update
(
CoreUser
user
){
userDao
.
updateById
(
user
);
}
public
CoreOrg
getOrgById
(
Long
orgId
){
return
orgDao
.
unique
(
orgId
);
}
public
CoreUser
getUserById
(
Long
userId
){
return
userDao
.
unique
(
userId
);
}
public
List
<
String
>
getOrgCode
(
List
<
Long
>
orgIds
){
return
orgDao
.
queryAllOrgCode
(
orgIds
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/AnnotationUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
org.springframework.core.annotation.AnnotationUtils
;
import
java.lang.annotation.Annotation
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
/**
* 描述: 获取注解的值
*
* @author : xiandafu
*/
public
class
AnnotationUtil
{
private
AnnotationUtil
()
{
}
public
static
AnnotationUtil
getInstance
()
{
return
AnnotationUtilHolder
.
instance
;
}
/**
* 获取一个类注解的名称和值
*
* @param annotationClasss 注解定义类
* @param useAnnotationClass 使用注解的类
* @return List<Map<String, Object>>
* @throws Exception
*/
public
List
<
Map
<
String
,
Object
>>
getAnnotations
(
Class
annotationClasss
,
Class
useAnnotationClass
)
{
List
<
Map
<
String
,
Object
>>
annotationMapList
=
new
ArrayList
<>();
Field
[]
fields
=
useAnnotationClass
.
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
if
(
field
.
isAnnotationPresent
(
annotationClasss
))
{
Annotation
p
=
field
.
getAnnotation
(
annotationClasss
);
Map
map
=
AnnotationUtils
.
getAnnotationAttributes
(
p
);
map
.
put
(
"fieldName"
,
field
.
getName
());
annotationMapList
.
add
(
map
);
}
}
return
annotationMapList
;
}
private
static
class
AnnotationUtilHolder
{
private
static
AnnotationUtil
instance
=
new
AnnotationUtil
();
private
AnnotationUtilHolder
()
{
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/ClassLoaderUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.ibeetl.admin.core.conf.RbacAnnotationConfig
;
public
class
ClassLoaderUtil
{
private
ClassLoaderUtil
(){
}
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
RbacAnnotationConfig
.
class
);
public
static
Class
loadClass
(
String
clsName
){
Class
cls
=
null
;
try
{
cls
=
ClassLoaderUtil
.
class
.
getClassLoader
().
loadClass
(
clsName
);
}
catch
(
ClassNotFoundException
e
)
{
log
.
info
(
e
.
getMessage
());
ClassLoader
loader
=
Thread
.
currentThread
().
getContextClassLoader
();
try
{
return
loader
.
loadClass
(
clsName
);
}
catch
(
ClassNotFoundException
e1
)
{
log
.
info
(
e1
.
getMessage
());
}
}
if
(
cls
==
null
){
log
.
error
(
"params:{},message:{}"
,
clsName
,
"无法加载类"
);
throw
new
IllegalArgumentException
(
"不能加载"
+
clsName
);
}
return
cls
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/ConvertUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* 数据格式转化类
* @author xiandafu
*
*/
public
class
ConvertUtil
{
/**
* 转化逗号分隔的id到long数组,通常用于批量操作
* @param str
* @return
*/
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
{
rets
.
add
(
Long
.
parseLong
(
id
));
}
catch
(
Exception
ex
){
throw
new
RuntimeException
(
"转化 "
+
str
+
" 到Long数组出错"
);
}
}
return
rets
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/DictUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.service.CoreDictService
;
/**
* 描述:
* @author : xiandafu
*/
@Component
public
class
DictUtil
{
@Autowired
CoreDictService
platformDictService
;
/**
* 根据字典值和类型,得到字典显示内容
* @param value 字典值
* @param type 字典类型 参考 @link{com.}
* @param defaultValue
* @return
*/
public
String
getDictName
(
String
value
)
{
CoreDict
dict
=
platformDictService
.
findCoreDict
(
value
);
return
dict
.
getName
();
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/FieldDict.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
com.ibeetl.admin.core.annotation.Dict
;
public
class
FieldDict
{
String
defaultValue
=
""
;
String
suffix
;
String
type
;
String
field
;
public
FieldDict
(
String
field
,
String
type
){
this
(
field
,
type
,
"Text"
,
null
);
}
public
FieldDict
(
String
field
,
Dict
dict
){
this
(
field
,
dict
.
type
(),
dict
.
suffix
(),
dict
.
defaultDisplay
());
}
public
FieldDict
(
String
field
,
String
type
,
String
suffix
,
String
defaultValue
){
this
.
field
=
field
;
this
.
type
=
type
;
this
.
suffix
=
suffix
;
this
.
defaultValue
=
defaultValue
;
}
public
String
getDefaultValue
()
{
return
defaultValue
;
}
public
void
setDefaultValue
(
String
defaultValue
)
{
this
.
defaultValue
=
defaultValue
;
}
public
String
getSuffix
()
{
return
suffix
;
}
public
void
setSuffix
(
String
suffix
)
{
this
.
suffix
=
suffix
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getField
()
{
return
field
;
}
public
void
setField
(
String
field
)
{
this
.
field
=
field
;
}
public
String
getDisplayField
(){
return
this
.
field
+
this
.
suffix
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/FormFieldException.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.util.ArrayList
;
import
java.util.List
;
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
);
errors
.
add
(
fields
);
}
public
List
<
FieldError
>
getErrors
()
{
return
errors
;
}
public
void
setErrors
(
List
<
FieldError
>
errors
)
{
this
.
errors
=
errors
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/FunctionBuildUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.ibeetl.admin.core.entity.CoreFunction
;
import
com.ibeetl.admin.core.rbac.tree.FunctionItem
;
/**
* 创建一个功能树,用于前端选择
* @author xiandafu
*
*/
public
class
FunctionBuildUtil
{
private
FunctionBuildUtil
(){
}
public
static
FunctionItem
buildOrgTree
(
List
<
CoreFunction
>
list
){
CoreFunction
root
=
new
CoreFunction
();
root
.
setId
(
0L
);
FunctionItem
rootOrg
=
new
FunctionItem
(
root
);
buildTreeNode
(
rootOrg
,
list
);
return
rootOrg
;
}
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
){
FunctionItem
item
=
new
FunctionItem
(
SysFunction
);
item
.
setParent
(
parent
);
dels
.
add
(
SysFunction
);
}
}
list
.
removeAll
(
dels
);
if
(
list
.
isEmpty
()){
return
;
}
for
(
FunctionItem
child:
parent
.
getChildren
()){
buildTreeNode
(
child
,
list
);
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/FunctionLocal.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
javax.servlet.http.HttpSession
;
/**
* 用户Controller对应的功能
* {@link MVCConf}
* @author lijiazhi
*
*/
public
class
FunctionLocal
{
private
FunctionLocal
(){
}
private
static
final
ThreadLocal
<
String
>
sessions
=
new
ThreadLocal
<
String
>()
{
@Override
protected
String
initialValue
()
{
return
null
;
}
};
public
static
String
get
(){
return
sessions
.
get
();
}
public
static
void
set
(
String
session
){
sessions
.
set
(
session
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/HttpRequestLocal.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.stereotype.Component
;
import
com.ibeetl.admin.core.conf.MVCConf
;
/**
* 保留用户会话,以方便在业务代码任何地方调用
* {@link MVCConf}
* @author lijiazhi
*
*/
@Component
public
class
HttpRequestLocal
{
public
HttpRequestLocal
(){
}
private
static
final
ThreadLocal
<
HttpServletRequest
>
requests
=
new
ThreadLocal
<
HttpServletRequest
>()
{
@Override
protected
HttpServletRequest
initialValue
()
{
return
null
;
}
};
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
Object
getRequestValue
(
String
attr
){
return
requests
.
get
().
getAttribute
(
attr
);
}
public
String
getRequestURI
(){
return
requests
.
get
().
getRequestURI
();
}
public
String
getRequestIP
(){
return
getIpAddr
(
requests
.
get
());
}
public
void
set
(
HttpServletRequest
request
){
requests
.
set
(
request
);
}
/**
* 获取当前网络ip
* @param request
* @return
*/
public
String
getIpAddr
(
HttpServletRequest
request
){
String
ipAddress
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ipAddress
==
null
||
ipAddress
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ipAddress
))
{
ipAddress
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
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
))
{
ipAddress
=
request
.
getRemoteAddr
();
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
();
}
}
//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if
(
ipAddress
!=
null
&&
ipAddress
.
length
()>
15
){
//"***.***.***.***".length() = 15
if
(
ipAddress
.
indexOf
(
","
)>
0
){
ipAddress
=
ipAddress
.
substring
(
0
,
ipAddress
.
indexOf
(
","
));
}
}
return
ipAddress
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/MenuBuildUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.ibeetl.admin.core.entity.CoreMenu
;
import
com.ibeetl.admin.core.rbac.tree.MenuItem
;
public
class
MenuBuildUtil
{
private
MenuBuildUtil
()
{
}
public
static
MenuItem
buildMenuTree
(
List
<
CoreMenu
>
list
)
{
CoreMenu
root
=
new
CoreMenu
();
root
.
setId
(
0L
);
root
.
setType
(
""
);
root
.
setName
(
"主菜单"
);
MenuItem
rootMenu
=
new
MenuItem
(
root
);
buildTreeNode
(
rootMenu
,
list
);
return
rootMenu
;
}
private
static
void
buildTreeNode
(
MenuItem
parent
,
List
<
CoreMenu
>
list
)
{
if
(
parent
.
getData
().
getType
().
equals
(
CoreMenu
.
TYPE_MENUITEM
))
{
return
;
}
long
id
=
parent
.
getId
();
List
<
CoreMenu
>
dels
=
new
ArrayList
<>();
for
(
CoreMenu
sysMenu
:
list
)
{
if
(
sysMenu
.
getParentMenuId
()
==
id
)
{
MenuItem
item
=
new
MenuItem
(
sysMenu
);
item
.
setParent
(
parent
);
dels
.
add
(
sysMenu
);
}
}
list
.
removeAll
(
dels
);
if
(
list
.
isEmpty
())
{
return
;
}
for
(
MenuItem
child
:
parent
.
getChildren
())
{
buildTreeNode
(
child
,
list
);
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/OrgBuildUtil.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.util.ArrayList
;
import
java.util.List
;
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
){
long
id
=
parent
.
getId
();
List
<
CoreOrg
>
dels
=
new
ArrayList
<>();
for
(
CoreOrg
sysOrg:
list
){
if
(
sysOrg
.
getParentOrgId
()!=
null
&&
sysOrg
.
getParentOrgId
()==
id
){
OrgItem
item
=
new
OrgItem
(
sysOrg
);
item
.
setParent
(
parent
);
dels
.
add
(
sysOrg
);
}
}
list
.
removeAll
(
dels
);
if
(
list
.
isEmpty
()){
return
;
}
for
(
OrgItem
child:
parent
.
getChildren
()){
buildTreeNode
(
child
,
list
);
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/PlatformException.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
public
class
PlatformException
extends
RuntimeException
{
public
PlatformException
()
{
super
();
}
public
PlatformException
(
String
message
)
{
super
(
message
);
}
public
PlatformException
(
String
message
,
Throwable
e
){
super
(
message
,
e
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/Tool.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
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
};
}
public
static
Date
parseDate
(
String
str
)
{
try
{
return
new
SimpleDateFormat
(
DATE_FORAMT
).
parse
(
str
.
trim
());
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/ValidateConfig.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.core.util
;
public
class
ValidateConfig
{
public
interface
ADD
{
}
public
interface
UPDATE
{
}
}
Prev
1
…
8
9
10
11
12
13
14
15
16
…
23
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