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-console/src/main/java/com/ibeetl/admin/console/service/DictConsoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.service
;
import
java.util.List
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.console.dao.DictConsoleDao
;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.service.BaseService
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
* CoreDict Service
*/
@Service
@Transactional
public
class
DictConsoleService
extends
BaseService
<
CoreDict
>{
@Autowired
private
DictConsoleDao
dictDao
;
public
PageQuery
<
CoreDict
>
queryByCondition
(
PageQuery
query
){
PageQuery
ret
=
dictDao
.
queryByCondition
(
query
);
queryListAfter
(
ret
.
getList
());
return
ret
;
}
public
void
batchDelCoreDict
(
List
<
String
>
ids
){
try
{
dictDao
.
batchDelCoreDictByIds
(
ids
);
}
catch
(
Exception
e
)
{
throw
new
PlatformException
(
"批量删除CoreDict失败"
,
e
);
}
}
}
\ No newline at end of file
admin-console/src/main/java/com/ibeetl/admin/console/service/FunctionConsoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.console.dao.FunctionConsoleDao
;
import
com.ibeetl.admin.console.dao.RoleFunctionConsoleDao
;
import
com.ibeetl.admin.console.web.dto.RoleDataAccessFunction
;
import
com.ibeetl.admin.core.dao.CoreMenuDao
;
import
com.ibeetl.admin.core.dao.CoreRoleMenuDao
;
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.CoreRoleMenu
;
import
com.ibeetl.admin.core.rbac.tree.FunctionItem
;
import
com.ibeetl.admin.core.rbac.tree.OrgItem
;
import
com.ibeetl.admin.core.service.BaseService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
* @author lijiazhi
*
*/
@Service
@Transactional
public
class
FunctionConsoleService
extends
BaseService
<
CoreFunction
>{
@Autowired
FunctionConsoleDao
functionDao
;
@Autowired
CoreMenuDao
menuDao
;
@Autowired
RoleFunctionConsoleDao
roleFunctionConsoleDao
;
@Autowired
CoreRoleMenuDao
sysRoleMenuDao
;
@Autowired
CorePlatformService
platformService
;
public
void
queryByCondtion
(
PageQuery
<
CoreFunction
>
query
)
{
functionDao
.
queryByCondtion
(
query
);
List
<
CoreFunction
>
list
=
query
.
getList
();
this
.
queryListAfter
(
list
);
//处理父功能名称显示
FunctionItem
root
=
platformService
.
buildFunction
();
for
(
CoreFunction
function:
list
)
{
Long
parentId
=
function
.
getParentId
();
String
name
=
""
;
if
(
parentId
!=
0
)
{
FunctionItem
item
=
root
.
findChild
(
parentId
);
name
=
item
!=
null
?
item
.
getName
():
""
;
}
function
.
set
(
"parentFunctionText"
,
name
);
}
}
public
Long
saveFunction
(
CoreFunction
function
){
functionDao
.
insert
(
function
,
true
);
platformService
.
clearFunctionCache
();
return
function
.
getId
();
}
/** 删除功能点,跟菜单有关联的无法删除,删除功能点导致所有缓存都需要更新
* @param functionId
* @return
*/
public
void
deleteFunction
(
Long
functionId
){
deleteFunctionId
(
functionId
);
platformService
.
clearFunctionCache
();
}
public
void
batchDeleteFunction
(
List
<
Long
>
functionIds
){
for
(
Long
id:
functionIds
){
deleteFunctionId
(
id
);
}
platformService
.
clearFunctionCache
();
}
public
void
updateFunction
(
CoreFunction
function
){
functionDao
.
updateById
(
function
);
platformService
.
clearFunctionCache
();
}
public
CoreFunction
getFunction
(
Long
functionId
){
return
functionDao
.
unique
(
functionId
);
}
public
CoreFunction
getFunction
(
String
code
){
CoreFunction
query
=
new
CoreFunction
();
query
.
setCode
(
code
);
CoreFunction
db
=
functionDao
.
templateOne
(
query
);
return
db
;
}
/**
* 得到角色对应的所有功能点
* @param roleId
* @return
*/
public
List
<
Long
>
getFunctionByRole
(
Long
roleId
){
return
this
.
roleFunctionConsoleDao
.
getFunctionIdByRole
(
roleId
);
}
/**
* 得到角色对应的所有数据权限功能点
* @param roleId
* @return
*/
public
List
<
RoleDataAccessFunction
>
getQueryFunctionByRole
(
Long
roleId
){
return
this
.
roleFunctionConsoleDao
.
getQueryFunctionAndRoleData
(
roleId
);
}
/**
* 更新角色对应的功能点所有,
* @param roleId
* @param data,必须包含id,和 dataAcerssType,采用模板更新
*/
public
void
updateFunctionAccessByRole
(
List
<
RoleDataAccessFunction
>
data
){
for
(
RoleDataAccessFunction
fun:
data
){
Long
roleId
=
fun
.
getRoleId
();
Long
functionId
=
fun
.
getId
();
int
accessType
=
fun
.
getDataAccessType
();
CoreRoleFunction
template
=
new
CoreRoleFunction
();
template
.
setRoleId
(
roleId
);
template
.
setFunctionId
(
functionId
);
CoreRoleFunction
ret
=
roleFunctionConsoleDao
.
templateOne
(
template
);
if
(
ret
!=
null
)
{
ret
.
setDataAccessType
(
accessType
);
roleFunctionConsoleDao
.
updateById
(
ret
);
}
else
{
template
.
setDataAccessType
(
accessType
);
template
.
setCreateTime
(
new
Date
());
roleFunctionConsoleDao
.
insert
(
template
);
}
}
}
/** 给角色赋予功能同时,根据赋予的功能权限,更新能访问的菜单
* @param adds
* @param updates
* @param dels
* @return 返回增加的项的id,用于前端
*/
public
void
updateSysRoleFunction
(
Long
roleId
,
List
<
Long
>
adds
,
List
<
Long
>
dels
){
for
(
Long
del:
dels
){
//获得功能关联的菜单
CoreRoleFunction
temp
=
new
CoreRoleFunction
();
temp
.
setRoleId
(
roleId
);
temp
.
setFunctionId
(
del
);
CoreRoleFunction
roleFunction
=
roleFunctionConsoleDao
.
templateOne
(
temp
);
if
(
roleFunction
==
null
){
throw
new
PlatformException
(
"已经被删除了RoleId="
+
roleId
+
" functionId="
+
del
);
}
CoreMenu
menu
=
queryFunctionMenu
(
roleFunction
.
getFunctionId
());
roleFunctionConsoleDao
.
deleteById
(
roleFunction
.
getId
());
if
(
menu
!=
null
){
//同时,需要删除与此功能关联的菜单
CoreRoleMenu
sysRoleMenu
=
querySysRoleMenu
(
roleFunction
.
getRoleId
(),
menu
.
getId
());
if
(
sysRoleMenu
!=
null
){
sysRoleMenuDao
.
deleteById
(
sysRoleMenu
.
getId
());
}
}
}
for
(
Long
add:
adds
){
CoreRoleFunction
function
=
new
CoreRoleFunction
();
function
.
setCreateTime
(
new
Date
());
function
.
setRoleId
(
roleId
);
function
.
setFunctionId
(
add
);
this
.
sqlManager
.
insert
(
function
);
CoreMenu
menu
=
queryFunctionMenu
(
add
);
if
(
menu
!=
null
){
//同时,需要增加菜单
CoreRoleMenu
roleMenu
=
new
CoreRoleMenu
();
roleMenu
.
setMenuId
(
menu
.
getId
());
roleMenu
.
setRoleId
(
roleId
);
sysRoleMenuDao
.
insert
(
roleMenu
);
}
}
//清楚缓存
platformService
.
clearFunctionCache
();
}
private
CoreMenu
queryFunctionMenu
(
Long
functionId
){
CoreMenu
query
=
new
CoreMenu
();
query
.
setFunctionId
(
functionId
);
List
<
CoreMenu
>
menus
=
menuDao
.
template
(
query
);
return
menus
.
isEmpty
()?
null
:
menus
.
get
(
0
);
}
private
CoreRoleMenu
querySysRoleMenu
(
Long
roleId
,
Long
menuId
){
CoreRoleMenu
query
=
new
CoreRoleMenu
();
query
.
setMenuId
(
menuId
);
query
.
setRoleId
(
roleId
);
List
<
CoreRoleMenu
>
menus
=
sysRoleMenuDao
.
template
(
query
);
return
menus
.
isEmpty
()?
null
:
menus
.
get
(
0
);
}
/**
* 删除某一个功能点及其子功能,对应的role-function 需要删除,菜单对应的function需要设置成空
* @param functionId
*/
private
void
deleteFunctionId
(
Long
functionId
){
FunctionItem
root
=
platformService
.
buildFunction
();
FunctionItem
fun
=
root
.
findChild
(
functionId
);
List
<
FunctionItem
>
all
=
fun
.
findAllItem
();
//也删除自身
all
.
add
(
fun
);
realDeleteFunction
(
all
);
}
private
void
realDeleteFunction
(
List
<
FunctionItem
>
all
){
List
<
Long
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
FunctionItem
item:
all
){
ids
.
add
(
item
.
getId
());
this
.
functionDao
.
deleteById
(
item
.
getId
());
}
//删除角色和功能的关系
this
.
roleFunctionConsoleDao
.
deleteRoleFunction
(
ids
);
//设置菜单对应的功能项为空
menuDao
.
clearMenuFunction
(
ids
);
}
}
admin-console/src/main/java/com/ibeetl/admin/console/service/MenuConsoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.service
;
import
com.ibeetl.admin.console.dao.MenuConsoleDao
;
import
com.ibeetl.admin.console.web.query.MenuQuery
;
import
com.ibeetl.admin.core.dao.CoreRoleMenuDao
;
import
com.ibeetl.admin.core.entity.CoreMenu
;
import
com.ibeetl.admin.core.rbac.tree.MenuItem
;
import
com.ibeetl.admin.core.service.BaseService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
@Transactional
public
class
MenuConsoleService
extends
BaseService
<
CoreMenu
>
{
@Autowired
MenuConsoleDao
menuDao
;
@Autowired
CoreRoleMenuDao
roleMenuDao
;
@Autowired
CorePlatformService
platformService
;
public
void
queryByCondtion
(
PageQuery
<
CoreMenu
>
query
)
{
menuDao
.
queryByCondtion
(
query
);
queryListAfter
(
query
.
getList
());
}
public
Long
saveMenu
(
CoreMenu
menu
)
{
CoreMenu
query
=
new
CoreMenu
();
query
.
setCode
(
menu
.
getCode
());
long
queryCount
=
menuDao
.
templateCount
(
query
);
if
(
queryCount
>
0
)
{
throw
new
PlatformException
(
"菜单编码已存在"
);
}
menuDao
.
insert
(
menu
,
true
);
platformService
.
clearMenuCache
();
return
menu
.
getId
();
}
public
void
deleteMenu
(
Long
menuId
)
{
deleteMenuId
(
menuId
);
}
public
void
batchDeleteMenuId
(
List
<
Long
>
menuIds
)
{
for
(
Long
id
:
menuIds
)
{
deleteMenuId
(
id
);
}
platformService
.
clearMenuCache
();
}
public
void
updateMenu
(
CoreMenu
menu
)
{
menuDao
.
updateById
(
menu
);
platformService
.
clearMenuCache
();
}
public
CoreMenu
getMenu
(
Long
menuId
)
{
CoreMenu
menu
=
menuDao
.
unique
(
menuId
);
platformService
.
clearMenuCache
();
return
menu
;
}
private
void
deleteMenuId
(
Long
menuId
)
{
MenuItem
root
=
platformService
.
buildMenu
();
MenuItem
fun
=
root
.
findChild
(
menuId
);
List
<
MenuItem
>
all
=
fun
.
findAllItem
();
//也删除自身
all
.
add
(
fun
);
realDeleteMenu
(
all
);
}
private
void
realDeleteMenu
(
List
<
MenuItem
>
all
)
{
List
<
Long
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
MenuItem
item
:
all
)
{
ids
.
add
(
item
.
getId
());
this
.
menuDao
.
deleteById
(
item
.
getId
());
}
//删除角色和菜单的关系
roleMenuDao
.
deleteRoleMenu
(
ids
);
}
}
admin-console/src/main/java/com/ibeetl/admin/console/service/OrgConsoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.console.dao.OrgConsoleDao
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.rbac.tree.OrgItem
;
import
com.ibeetl.admin.core.service.BaseService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
*
* @author : xiandafu
*/
@Service
@Transactional
public
class
OrgConsoleService
extends
BaseService
<
CoreOrg
>
{
@Autowired
private
OrgConsoleDao
orgDao
;
@Autowired
private
CorePlatformService
platformService
;
/**
* 根据条件查询
* @param query
*/
public
void
queryByCondtion
(
PageQuery
query
)
{
orgDao
.
queryByCondtion
(
query
);
List
<
CoreOrg
>
list
=
query
.
getList
();
queryListAfter
(
list
);
OrgItem
root
=
platformService
.
buildOrg
();
//处理父机构名称显示,没有用sql查询是考虑到跨数据库
for
(
CoreOrg
org:
list
)
{
Long
parentId
=
org
.
getParentOrgId
();
OrgItem
item
=
root
.
findChild
(
parentId
);
String
name
=
item
!=
null
?
item
.
getName
():
""
;
org
.
set
(
"parentOrgText"
,
name
);
}
}
/**
* 获取机构下面的所以机构
* @param orgId 机构id
*/
public
List
<
Long
>
getAllChildIdsByOrgId
(
Long
orgId
)
{
if
(
orgId
==
null
)
return
null
;
OrgItem
orgItem
=
platformService
.
buildOrg
().
findChild
(
orgId
);
if
(
orgItem
==
null
)
{
return
null
;
}
List
<
Long
>
ids
=
orgItem
.
findAllChildrenId
();
if
(
ids
==
null
)
{
ids
=
new
ArrayList
<>();
}
ids
.
add
(
orgId
);
return
ids
;
}
@Override
public
boolean
deleteById
(
List
<
Long
>
ids
)
{
OrgItem
root
=
platformService
.
buildOrg
();
//检查子节点
for
(
Long
id
:
ids
)
{
OrgItem
child
=
root
.
findChild
(
id
);
if
(
child
.
getChildren
().
size
()!=
0
){
throw
new
PlatformException
(
"不能删除 "
+
child
.
getOrg
().
getName
()+
",还包含子机构"
);
}
}
return
super
.
deleteById
(
ids
);
}
}
admin-console/src/main/java/com/ibeetl/admin/console/service/RoleConsoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.service
;
import
java.util.List
;
import
org.beetl.sql.core.SQLManager
;
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.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.console.dao.RoleConsoleDao
;
import
com.ibeetl.admin.core.entity.CoreRole
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.rbac.tree.OrgItem
;
import
com.ibeetl.admin.core.service.BaseService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.enums.RoleTypeEnum
;
@Service
@Transactional
public
class
RoleConsoleService
extends
BaseService
<
CoreRole
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RoleConsoleService
.
class
);
@Autowired
private
RoleConsoleDao
roleDao
;
@Autowired
private
SQLManager
sqlManager
;
@Autowired
CorePlatformService
platformService
;
/**
* 获取全部操作角色集合
* @return
*/
public
List
<
CoreRole
>
queryAllPermissionList
()
{
CoreRole
template
=
new
CoreRole
();
template
.
setType
(
RoleTypeEnum
.
ACCESS
.
getValue
());
return
roleDao
.
template
(
template
);
}
/**
* 根据删标记获取全部角色集合
* @param delFlagEnum 删除标记
* @return
*/
public
List
<
CoreRole
>
queryAllList
()
{
return
roleDao
.
all
();
}
/**
* 根据条件查询
* @param query
*/
public
void
queryByCondtion
(
PageQuery
query
)
{
roleDao
.
queryByCondtion
(
query
);
super
.
queryListAfter
(
query
.
getList
());
}
public
PageQuery
<
CoreUser
>
queryRoleUser
(
PageQuery
query
)
{
OrgItem
root
=
platformService
.
buildOrg
();
PageQuery
<
CoreUser
>
ret
=
roleDao
.
queryUser
(
query
);
List
<
CoreUser
>
list
=
ret
.
getList
();
//从缓存里取出组织机构名称
for
(
CoreUser
user:
list
)
{
Long
orgId
=
user
.
getOrgId
();
Integer
orgId1
=
(
Integer
)
user
.
get
(
"orgId1"
);
user
.
set
(
"orgIdText"
,
root
.
findChild
(
orgId
).
getName
());
user
.
set
(
"orgId1Text"
,
root
.
findChild
((
long
)
orgId1
).
getName
());
}
//再次处理数据字典
this
.
queryListAfter
(
list
);
return
ret
;
}
/**
* 根据编号查询
* @param code 角色编号
* @return
*/
public
CoreRole
queryByCode
(
String
code
)
{
CoreRole
queryRole
=
new
CoreRole
();
queryRole
.
setCode
(
code
);
CoreRole
role
=
roleDao
.
templateOne
(
queryRole
);
return
role
;
}
public
boolean
deleteById
(
List
<
Long
>
ids
)
{
if
(
ids
==
null
||
ids
.
isEmpty
())
{
throw
new
PlatformException
(
"删除数据ID不能为空"
);
}
roleDao
.
batchDelByIds
(
ids
);
roleDao
.
batchDeleteRoleFunction
(
ids
);
roleDao
.
batchDeleteRoleMenu
(
ids
);
roleDao
.
batchDeleteUserRole
(
ids
);
return
true
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/service/UserConsoleService.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.service
;
import
java.util.Date
;
import
java.util.List
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.console.dao.UserConsoleDao
;
import
com.ibeetl.admin.console.exception.DeletedException
;
import
com.ibeetl.admin.console.exception.NoResourceException
;
import
com.ibeetl.admin.console.web.query.UserRoleQuery
;
import
com.ibeetl.admin.core.conf.PasswordConfig.PasswordEncryptService
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.entity.CoreUserRole
;
import
com.ibeetl.admin.core.service.BaseService
;
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
UserConsoleService
extends
BaseService
<
CoreUser
>
{
@Autowired
UserConsoleDao
userDao
;
@Autowired
PasswordEncryptService
passwordEncryptService
;
/**
* 根据条件查询
*
* @param query
*/
public
void
queryByCondtion
(
PageQuery
<
CoreUser
>
query
)
{
PageQuery
<
CoreUser
>
ret
=
userDao
.
queryByCondtion
(
query
);
queryListAfter
(
ret
.
getList
());
}
/**
* 插入一条用户数据
*
* @param user
*/
public
void
saveUser
(
CoreUser
user
)
{
CoreUser
query
=
new
CoreUser
();
query
.
setCode
(
user
.
getCode
());
CoreUser
dbUser
=
userDao
.
templateOne
(
query
);
if
(
dbUser
!=
null
)
{
throw
new
PlatformException
(
"保存用户信息失败,用户已经存在"
);
}
user
.
setCreateTime
(
new
Date
());
user
.
setState
(
GeneralStateEnum
.
ENABLE
.
getValue
());
user
.
setPassword
(
passwordEncryptService
.
password
(
user
.
getPassword
()));
user
.
setDelFlag
(
DelFlagEnum
.
NORMAL
.
getValue
());
userDao
.
insert
(
user
,
true
);
}
/**
* 根据用户id查询一条数据
*
* @param userId
*/
public
CoreUser
queryUserById
(
Long
userId
)
{
return
userDao
.
unique
(
userId
);
}
/**
* 更新用户 只更新不为空的字段
*
* @param user
* @return
*/
public
int
updateSysUser
(
CoreUser
user
)
{
return
userDao
.
updateTemplateById
(
user
);
}
/**
* 删除用户
*
* @param userId
* 用户id
*/
public
void
delSysUser
(
Long
userId
)
{
CoreUser
user
=
queryUserById
(
userId
);
if
(
user
==
null
)
{
throw
new
NoResourceException
(
"用户不存在!"
);
}
if
(
user
.
getDelFlag
()==
DelFlagEnum
.
DELETED
.
getValue
())
{
throw
new
DeletedException
(
"用户已被删除!"
);
}
user
=
new
CoreUser
();
user
.
setId
(
userId
);
user
.
setDelFlag
(
DelFlagEnum
.
DELETED
.
getValue
());
userDao
.
updateTemplateById
(
user
);
}
/**
* 批量删除用户 <br/>
* 软删除 标记用户删除状态
*
* @param userIds
* 用户id
*/
public
void
batchDelSysUser
(
List
<
Long
>
userIds
)
{
try
{
userDao
.
batchDelUserByIds
(
userIds
);
}
catch
(
Exception
e
)
{
throw
new
PlatformException
(
"批量删除用户失败"
,
e
);
}
}
/**
* 批量停用用户 <br/>
* 标记用户状态 停用
*
* @param userIds
* 用户id
*/
public
void
batchUpdateUserState
(
List
<
Long
>
userIds
,
GeneralStateEnum
stateEnum
)
{
userDao
.
batchUpdateUserState
(
userIds
,
stateEnum
);
}
/**
* 重置用户密码
*
* @param uId
* @param password
*/
public
int
resetPassword
(
Long
id
,
String
password
)
{
CoreUser
user
=
new
CoreUser
();
user
.
setId
(
id
);
user
.
setPassword
(
passwordEncryptService
.
password
(
password
));
user
.
setUpdateTime
(
new
Date
());
return
userDao
.
updateTemplateById
(
user
);
}
public
List
<
CoreUserRole
>
getUserRoles
(
UserRoleQuery
roleQuery
)
{
return
userDao
.
queryUserRole
(
roleQuery
.
getUserId
(),
roleQuery
.
getOrgId
(),
roleQuery
.
getRoleId
());
}
public
void
deleteUserRoles
(
List
<
Long
>
ids
)
{
//考虑到这个操作较少使用,就不做批处理优化了
for
(
Long
id
:
ids
)
{
sqlManager
.
deleteById
(
CoreUserRole
.
class
,
id
);
}
}
public
void
saveUserRole
(
CoreUserRole
userRole
)
{
long
queryCount
=
sqlManager
.
templateCount
(
userRole
);
if
(
queryCount
>
0
)
{
throw
new
PlatformException
(
"已存在用户角色关系"
);
}
sqlManager
.
insert
(
userRole
);
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/AuditConsoleController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.service.AuditConsoleService
;
import
com.ibeetl.admin.console.web.query.AuditQuery
;
import
com.ibeetl.admin.console.web.query.UserQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreAudit
;
import
com.ibeetl.admin.core.util.AnnotationUtil
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
* 用户管理接口
* @author xiandafu
*
*/
@Controller
public
class
AuditConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/audit"
;
@Autowired
AuditConsoleService
auditConsoleService
;
/*页面*/
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"audit"
)
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/audit/index.html"
);
view
.
addObject
(
"search"
,
AuditQuery
.
class
.
getName
());
return
view
;
}
/*Json*/
@PostMapping
(
MODEL
+
"/view.json"
)
@ResponseBody
@Function
(
"audit.query"
)
public
JsonResult
<
CoreAudit
>
view
(
Long
id
)
{
CoreAudit
audit
=
auditConsoleService
.
queryById
(
id
);
return
JsonResult
.
success
(
audit
);
}
@RequestMapping
(
MODEL
+
"/list.json"
)
@Function
(
"audit.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreAudit
>>
list
(
AuditQuery
condtion
)
{
PageQuery
<
CoreAudit
>
page
=
condtion
.
getPageQuery
();
auditConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"audit.query"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
listCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
AuditQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/CmsBlogController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.web.JsonResult
;
import
com.ibeetl.admin.core.util.*
;
import
com.ibeetl.admin.console.entity.*
;
import
com.ibeetl.admin.console.service.*
;
import
com.ibeetl.admin.console.web.query.*
;
/**
* CmsBlog 接口
*/
@Controller
public
class
CmsBlogController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/cmsBlog"
;
@Autowired
private
CmsBlogService
cmsBlogService
;
/* 页面 */
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"cmsBlog.query"
)
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/cmsBlog/index.html"
)
;
view
.
addObject
(
"search"
,
CmsBlogQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"cmsBlog.edit"
)
@ResponseBody
public
ModelAndView
edit
(
Long
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/cmsBlog/edit.html"
);
CmsBlog
cmsBlog
=
cmsBlogService
.
queryById
(
id
);
view
.
addObject
(
"cmsBlog"
,
cmsBlog
);
return
view
;
}
@GetMapping
(
MODEL
+
"/add.do"
)
@Function
(
"cmsBlog.add"
)
@ResponseBody
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/cmsBlog/add.html"
);
return
view
;
}
/* ajax json */
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"cmsBlog.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
CmsBlogQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
cmsBlogService
.
queryByCondition
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"cmsBlog.add"
)
@ResponseBody
public
JsonResult
addCmsBlog
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CmsBlog
cmsBlog
)
{
cmsBlogService
.
save
(
cmsBlog
);
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"cmsBlog.update"
)
@ResponseBody
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CmsBlog
cmsBlog
)
{
boolean
success
=
cmsBlogService
.
update
(
cmsBlog
);
if
(
success
)
{
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
@GetMapping
(
MODEL
+
"/view.json"
)
@Function
(
"cmsBlog.query"
)
@ResponseBody
public
JsonResult
<
CmsBlog
>
queryInfo
(
Long
id
)
{
CmsBlog
cmsBlog
=
cmsBlogService
.
queryById
(
id
);
return
JsonResult
.
success
(
cmsBlog
);
}
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"cmsBlog.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
if
(
ids
.
endsWith
(
","
))
{
ids
=
StringUtils
.
substringBeforeLast
(
ids
,
","
);
}
List
<
Long
>
idList
=
ConvertUtil
.
str2longs
(
ids
);
cmsBlogService
.
batchDelCmsBlog
(
idList
);
return
new
JsonResult
().
success
();
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/DictConsoleController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.service.DictConsoleService
;
import
com.ibeetl.admin.console.web.query.CoreDictQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
* CoreDict 接口
*/
@Controller
public
class
DictConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/dict"
;
@Autowired
private
DictConsoleService
dictService
;
/* 页面 */
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"dict.query"
)
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/index.html"
)
;
view
.
addObject
(
"search"
,
CoreDictQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"dict.edit"
)
@ResponseBody
public
ModelAndView
edit
(
String
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/edit.html"
);
CoreDict
dict
=
dictService
.
queryById
(
id
);
view
.
addObject
(
"dict"
,
dict
);
return
view
;
}
@GetMapping
(
MODEL
+
"/add.do"
)
@Function
(
"dict.add"
)
@ResponseBody
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/add.html"
);
return
view
;
}
/* ajax json */
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"dict.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
CoreDictQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
dictService
.
queryByCondition
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"dict.add"
)
@ResponseBody
public
JsonResult
add
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreDict
dict
)
{
dict
.
setCreateTime
(
new
Date
());
dictService
.
save
(
dict
);
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"dict.update"
)
@ResponseBody
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreDict
dict
)
{
boolean
success
=
dictService
.
update
(
dict
);
if
(
success
)
{
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
@GetMapping
(
MODEL
+
"/view.json"
)
@Function
(
"dict.query"
)
@ResponseBody
public
JsonResult
<
CoreDict
>
queryInfo
(
Long
id
)
{
CoreDict
dict
=
dictService
.
queryById
(
id
);
return
JsonResult
.
success
(
dict
);
}
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"dict.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
if
(
ids
.
endsWith
(
","
))
{
ids
=
StringUtils
.
substringBeforeLast
(
ids
,
","
);
}
List
<
String
>
idList
=
Arrays
.
asList
(
ids
.
split
(
","
));
dictService
.
batchDelCoreDict
(
idList
);
return
new
JsonResult
().
success
();
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/FunctionController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
com.ibeetl.admin.console.service.FunctionConsoleService
;
import
com.ibeetl.admin.console.web.query.AuditQuery
;
import
com.ibeetl.admin.console.web.query.FunctionQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreFunction
;
import
com.ibeetl.admin.core.rbac.tree.FunctionItem
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.AnnotationUtil
;
import
com.ibeetl.admin.core.util.ConvertUtil
;
import
com.ibeetl.admin.core.util.FormFieldException
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.web.JsonResult
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* 描述: 功能点管理
*
* @author : lijiazhi
*/
@Controller
public
class
FunctionController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/function"
;
@Autowired
CorePlatformService
platformService
;
@Autowired
private
FunctionConsoleService
functionConsoleService
;
/*页面*/
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"function"
)
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/function/index.html"
);
view
.
addObject
(
"search"
,
FunctionQuery
.
class
.
getName
());
return
view
;
}
/*Json*/
@RequestMapping
(
MODEL
+
"/add.json"
)
@Function
(
"function.add"
)
@ResponseBody
public
JsonResult
<
CoreFunction
>
addFunction
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreFunction
function
)
{
String
code
=
function
.
getCode
();
CoreFunction
dbFunction
=
functionConsoleService
.
getFunction
(
code
);
if
(
dbFunction
!=
null
){
throw
new
FormFieldException
(
CoreFunction
.
class
.
getName
(),
"code"
,
"已经存在"
);
}
if
(
function
.
getParentId
()==
null
){
function
.
setParentId
(
0
l
);
}
function
.
setCreateTime
(
new
Date
());
functionConsoleService
.
saveFunction
(
function
);
return
JsonResult
.
success
(
function
);
}
@RequestMapping
(
MODEL
+
"/update.json"
)
@Function
(
"function.update"
)
@ResponseBody
public
JsonResult
<?>
updateFunction
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreFunction
function
)
{
String
code
=
function
.
getCode
();
CoreFunction
dbFunction
=
functionConsoleService
.
getFunction
(
function
.
getCode
());
if
(
dbFunction
!=
null
&&!
dbFunction
.
getId
().
equals
(
function
.
getId
())){
throw
new
FormFieldException
(
CoreFunction
.
class
.
getName
(),
"code"
,
"已经存在"
);
}
if
(
function
.
getParentId
()==
null
){
function
.
setParentId
(
0
l
);
}
functionConsoleService
.
updateFunction
(
function
);
return
JsonResult
.
success
();
}
@RequestMapping
(
MODEL
+
"/view.json"
)
@Function
(
"function.query"
)
@ResponseBody
public
JsonResult
<
CoreFunction
>
getFunction
(
Long
id
)
{
CoreFunction
function
=
functionConsoleService
.
getFunction
(
id
);
if
(
function
.
hasParent
()){
CoreFunction
parent
=
functionConsoleService
.
getFunction
(
function
.
getParentId
());
function
.
set
(
"parentName"
,
parent
.
getName
());
}
else
{
function
.
set
(
"parentName"
,
""
);
}
functionConsoleService
.
queryEntityAfter
(
function
);
return
JsonResult
.
success
(
function
);
}
@RequestMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"function.delete"
)
@ResponseBody
public
JsonResult
deleteFunction
(
Long
id
)
{
CoreFunction
fun
=
functionConsoleService
.
queryById
(
id
);
if
(
fun
==
null
)
{
throw
new
PlatformException
(
"删除失败,没有找到Function "
+
id
+
"!"
);
}
//删除功能和所有子功能
functionConsoleService
.
deleteFunction
(
id
);
return
new
JsonResult
().
success
();
}
/**
* 字典列表 分页
*
* @param condtion
* @return
*/
@RequestMapping
(
MODEL
+
"/list.json"
)
@Function
(
"function.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreFunction
>>
list
(
FunctionQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
functionConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"function.query"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
listCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
FunctionQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
private
List
<
Long
>
findChildFunctionIds
(
Long
funtionId
)
{
FunctionItem
funItem
=
platformService
.
buildFunction
().
findChild
(
funtionId
);
List
<
Long
>
children
=
funItem
.
findAllChildrenId
();
children
.
add
(
funtionId
);
return
children
;
}
@RequestMapping
(
MODEL
+
"/batchDel.json"
)
@Function
(
"function.delete"
)
@ResponseBody
public
JsonResult
batchDel
(
String
ids
)
{
List
<
Long
>
dels
=
ConvertUtil
.
str2longs
(
ids
);
JsonResult
result
=
new
JsonResult
();
//todo 导致缓存多次操作.
functionConsoleService
.
batchDeleteFunction
(
dels
);
return
result
.
success
();
}
@PostMapping
(
MODEL
+
"/tree.json"
)
@Function
(
"function.query"
)
@ResponseBody
public
JsonResult
<
List
<
FunctionNodeView
>
>
tree
()
{
FunctionItem
root
=
this
.
platformService
.
buildFunction
();
List
<
FunctionNodeView
>
tree
=
buildFunctionTree
(
root
);
return
JsonResult
.
success
(
tree
);
}
private
List
<
FunctionNodeView
>
buildFunctionTree
(
FunctionItem
node
){
List
<
FunctionItem
>
list
=
node
.
getChildren
();
if
(
list
.
size
()==
0
){
return
Collections
.
EMPTY_LIST
;
}
List
<
FunctionNodeView
>
views
=
new
ArrayList
<
FunctionNodeView
>(
list
.
size
());
for
(
FunctionItem
item
:
list
){
FunctionNodeView
view
=
new
FunctionNodeView
();
view
.
setCode
(
item
.
getData
().
getCode
());
view
.
setName
(
item
.
getData
().
getName
());
view
.
setId
(
item
.
getData
().
getId
());
List
<
FunctionNodeView
>
children
=
this
.
buildFunctionTree
(
item
);
view
.
setChildren
(
children
);
views
.
add
(
view
);
}
return
views
;
}
class
FunctionNodeView
{
String
name
;
String
code
;
Long
id
;
String
icon
;
List
<
FunctionNodeView
>
children
=
new
ArrayList
<
FunctionNodeView
>();
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
List
<
FunctionNodeView
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
FunctionNodeView
>
children
)
{
this
.
children
=
children
;
}
public
String
getIcon
()
{
return
icon
;
}
public
void
setIcon
(
String
icon
)
{
this
.
icon
=
icon
;
}
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/MenuController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.ibeetl.admin.console.service.MenuConsoleService
;
import
com.ibeetl.admin.console.web.query.MenuQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreMenu
;
import
com.ibeetl.admin.core.rbac.tree.MenuItem
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.AnnotationUtil
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
* @author lijiazhi
*/
@Controller
public
class
MenuController
{
private
static
final
String
MODEL
=
"/admin/menu"
;
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
@Autowired
MenuConsoleService
menuService
;
@Autowired
CorePlatformService
platformService
;
/**
* 查询
* @param menu
* @return
*/
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"menu.query"
)
@ResponseBody
public
JsonResult
condition
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
MenuQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"menu.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
MenuQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
menuService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
/**
* 添加
* @param menu
* @return
*/
@PostMapping
(
MODEL
+
"/save.json"
)
@Function
(
"menu.save"
)
@ResponseBody
public
JsonResult
save
(
@Validated
CoreMenu
menu
)
{
menu
.
setCreateTime
(
new
Date
());
Long
id
=
menuService
.
saveMenu
(
menu
);
return
JsonResult
.
success
(
id
);
}
/**
* 更新
* @param fun
* @return
*/
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"menu.update"
)
@ResponseBody
public
JsonResult
update
(
CoreMenu
fun
)
{
menuService
.
updateMenu
(
fun
);
return
new
JsonResult
().
success
();
}
/**
* 根据id查询菜单信息
* @param id 菜单Id
* @return
*/
@PostMapping
(
MODEL
+
"/view.json"
)
@Function
(
"menu.query"
)
@ResponseBody
public
JsonResult
<
CoreMenu
>
view
(
Long
id
)
{
CoreMenu
fun
=
menuService
.
queryById
(
id
);
MenuItem
root
=
this
.
platformService
.
buildMenu
();
MenuItem
child
=
root
.
findChild
(
fun
.
getId
());
CoreMenu
parent
=
child
.
getParent
().
getData
();
fun
.
set
(
"parentMenuName"
,
parent
.
getName
());
return
JsonResult
.
success
(
fun
);
}
/**
* 删除
* @param id 菜单id
* @return
*/
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"menu.delete"
)
@ResponseBody
public
JsonResult
delete
(
Long
id
)
{
menuService
.
deleteMenu
(
id
);
return
new
JsonResult
().
success
();
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/OrgConsoleController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.service.OrgConsoleService
;
import
com.ibeetl.admin.console.service.UserConsoleService
;
import
com.ibeetl.admin.console.web.query.OrgQuery
;
import
com.ibeetl.admin.console.web.query.OrgUserQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.AnnotationUtil
;
import
com.ibeetl.admin.core.util.ConvertUtil
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
* 描述: 组织机构 controller
* @author : xiandafu
*/
@Controller
public
class
OrgConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/org"
;
@Autowired
private
OrgConsoleService
orgConsoleService
;
@Autowired
UserConsoleService
userConsoleService
;
@Autowired
CorePlatformService
platformService
;
/*页面*/
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"org.query"
)
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/org/index.html"
);
view
.
addObject
(
"search"
,
OrgQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"org.edit"
)
@ResponseBody
public
ModelAndView
edit
(
String
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/org/edit.html"
);
CoreOrg
org
=
orgConsoleService
.
queryById
(
id
);
view
.
addObject
(
"org"
,
org
);
return
view
;
}
@GetMapping
(
MODEL
+
"/user/list.do"
)
@Function
(
"org.query"
)
@ResponseBody
public
ModelAndView
getUsers
(
Long
orgId
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/org/orgUser.html"
);
CoreOrg
org
=
orgConsoleService
.
queryById
(
orgId
);
view
.
addObject
(
"org"
,
org
);
view
.
addObject
(
"search"
,
OrgUserQuery
.
class
.
getName
());
return
view
;
}
/**
* 组织机构列表 分页
* @param condtion 查询条件
* @return
*/
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"org.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreOrg
>>
list
(
OrgQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
orgConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
/**
* 获取列表查询条件
* @return
*/
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"org.query"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
listCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
OrgQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
/**
* 保存数据
* @param org
* @return
*/
@PostMapping
(
MODEL
+
"/save.json"
)
@Function
(
"org.save"
)
@ResponseBody
public
JsonResult
<
Long
>
save
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreOrg
org
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
return
JsonResult
.
failMessage
(
result
.
toString
());
}
org
.
setCreateTime
(
new
Date
());
orgConsoleService
.
save
(
org
);
platformService
.
clearOrgCache
();
return
JsonResult
.
success
(
org
.
getId
());
}
/**
* 更新数据
* @param org
* @return
*/
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"org.update"
)
@ResponseBody
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreOrg
org
)
{
boolean
success
=
orgConsoleService
.
updateTemplate
(
org
);
if
(
success
)
{
platformService
.
clearOrgCache
();
return
JsonResult
.
successMessage
(
"保存成功"
);
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
/**
* 删除组织机构
* @param ids 组织id,多个用“,”隔开
* @return
*/
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"org.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
if
(
ids
.
endsWith
(
","
))
{
ids
=
StringUtils
.
substringBeforeLast
(
ids
,
","
);
}
List
<
Long
>
idList
=
ConvertUtil
.
str2longs
(
ids
);
orgConsoleService
.
deleteById
(
idList
);
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/user/list.json"
)
@Function
(
"org.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreUser
>>
getUsers
(
OrgUserQuery
userQuery
)
{
PageQuery
<
CoreUser
>
page
=
userQuery
.
getPageQuery
();
userConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/RoleConsoleController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.service.FunctionConsoleService
;
import
com.ibeetl.admin.console.service.OrgConsoleService
;
import
com.ibeetl.admin.console.service.RoleConsoleService
;
import
com.ibeetl.admin.console.web.dto.RoleDataAccessFunction
;
import
com.ibeetl.admin.console.web.query.RoleQuery
;
import
com.ibeetl.admin.console.web.query.RoleUserQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreRole
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.AnnotationUtil
;
import
com.ibeetl.admin.core.util.ConvertUtil
;
import
com.ibeetl.admin.core.util.DictUtil
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
* 角色
*/
@Controller
public
class
RoleConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/role"
;
@Autowired
private
RoleConsoleService
roleConsoleService
;
@Autowired
private
FunctionConsoleService
functionConsoleService
;
@Autowired
CorePlatformService
platformService
;
@Autowired
private
OrgConsoleService
orgConsoleService
;
@Autowired
DictUtil
dictUtil
;
/* 页面 */
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"role.edit"
)
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/index.html"
);
view
.
addObject
(
"search"
,
RoleQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"role.edit"
)
@ResponseBody
public
ModelAndView
edit
(
String
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/edit.html"
);
CoreRole
role
=
roleConsoleService
.
queryById
(
id
);
view
.
addObject
(
"role"
,
role
);
return
view
;
}
@GetMapping
(
MODEL
+
"/add.do"
)
@Function
(
"role.add"
)
@ResponseBody
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/add.html"
);
return
view
;
}
@GetMapping
(
MODEL
+
"/user/list.do"
)
@Function
(
"role.user.query"
)
@ResponseBody
public
ModelAndView
users
(
Long
roleId
)
{
CoreRole
role
=
roleConsoleService
.
queryById
(
roleId
);
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/roleUser.html"
);
view
.
addObject
(
"role"
,
role
);
view
.
addObject
(
"search"
,
RoleUserQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/function.do"
)
@Function
(
"role.function.query"
)
@ResponseBody
public
ModelAndView
functions
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/function.html"
);
return
view
;
}
@GetMapping
(
MODEL
+
"/data.do"
)
@Function
(
"role.function.query"
)
@ResponseBody
public
ModelAndView
data
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/data.html"
);
return
view
;
}
/**
* 列表页、 分页数据
*
* @param condtion
* @return
*/
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"role.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
RoleQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
roleConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
@GetMapping
(
MODEL
+
"/all.json"
)
@Function
(
"role.query"
)
@ResponseBody
public
JsonResult
<
List
<
CoreRole
>>
all
()
{
List
<
CoreRole
>
list
=
roleConsoleService
.
queryAllPermissionList
();
return
JsonResult
.
success
(
list
);
}
/**
* 获取列表查询条件
*
* @return
*/
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"role.query"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
listCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
RoleQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
/**
* 保存
*
* @return
*/
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"role.add"
)
@ResponseBody
public
JsonResult
addRole
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreRole
role
)
{
CoreRole
role1
=
roleConsoleService
.
queryByCode
(
role
.
getCode
());
if
(
role1
!=
null
)
{
return
JsonResult
.
failMessage
(
"用户编号已存在"
);
}
JsonResult
result
=
new
JsonResult
();
role
.
setCreateTime
(
new
Date
());
roleConsoleService
.
save
(
role
);
platformService
.
clearFunctionCache
();
return
result
.
success
();
}
/**
* 更新
*
* @param role
* @return
*/
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"role.update"
)
@ResponseBody
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreRole
role
)
{
boolean
success
=
roleConsoleService
.
update
(
role
);
if
(
success
)
{
platformService
.
clearFunctionCache
();
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
/**
* 查询角色信息
*
* @param id
* @return
*/
@GetMapping
(
MODEL
+
"/view.json"
)
@Function
(
"role.query"
)
@ResponseBody
public
JsonResult
<
CoreRole
>
queryInfo
(
Long
id
)
{
CoreRole
role
=
roleConsoleService
.
queryById
(
id
);
return
JsonResult
.
success
(
role
);
}
/**
* (批量)删除
*
* @param ids
* 角色id
* @return
*/
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"role.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
if
(
ids
.
endsWith
(
","
))
{
ids
=
StringUtils
.
substringBeforeLast
(
ids
,
","
);
}
List
<
Long
>
idList
=
ConvertUtil
.
str2longs
(
ids
);
roleConsoleService
.
deleteById
(
idList
);
return
new
JsonResult
().
success
();
}
/**
* 查询角色下授权用户列表
*
* @param queryCondtion
* 查询条件
* @return
*/
@PostMapping
(
MODEL
+
"/user/list.json"
)
@Function
(
"role.user.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreUser
>>
userList
(
RoleUserQuery
query
)
{
PageQuery
page
=
query
.
getPageQuery
();
PageQuery
<
CoreUser
>
pageQuery
=
roleConsoleService
.
queryRoleUser
(
page
);
return
JsonResult
.
success
(
page
);
}
// /**
// * 给角色添加用户
// * @param userRole 角色用户关系
// * @return
// */
// @PostMapping(MODEL + "/user/save.json")
// @Function("role.user.save")
// @ResponseBody
// public JsonResult saveRoleUser(CoreUserRole userRole) {
// userRole.setCreateTime(new Date());
// userRoleConsoleService.saveSysUserRole(userRole);
// platformService.clearFunctionCache();
// return JsonResult.success();
// }
//
//
// /**
// * 用户授权删除
// * @param ids 记录id
// * @return
// */
// @GetMapping(MODEL + "/user/delete.json")
// @Function("role.user.delete")
// @ResponseBody
// public Object deleteRoleUser(String ids) {
// List<Long> dels = ConvertUtil.str2longs(ids);
// userRoleConsoleService.deleteUserRoles(dels);
// platformService.clearFunctionCache();
// return JsonResult.success();
// }
@PostMapping
(
MODEL
+
"/function/ids.json"
)
@Function
(
"role.function.list"
)
@ResponseBody
public
JsonResult
<
List
<
Long
>>
getFunctionIdByRole
(
Long
roleId
)
{
List
<
Long
>
list
=
functionConsoleService
.
getFunctionByRole
(
roleId
);
return
JsonResult
.
success
(
list
);
}
@GetMapping
(
MODEL
+
"/function/queryFunction.json"
)
@Function
(
"role.function.list"
)
@ResponseBody
public
JsonResult
<
List
<
RoleDataAccessFunction
>>
getQueryFunctionByRole
(
Long
roleId
)
{
List
<
RoleDataAccessFunction
>
list
=
functionConsoleService
.
getQueryFunctionByRole
(
roleId
);
return
JsonResult
.
success
(
list
);
}
@PostMapping
(
MODEL
+
"/function/update.json"
)
@Function
(
"role.function.update"
)
@ResponseBody
public
JsonResult
updateFunction
(
Long
roleId
,
String
ids
)
{
List
<
Long
>
all
=
ConvertUtil
.
str2longs
(
ids
);
List
<
Long
>
addIds
=
new
ArrayList
<
Long
>();
List
<
Long
>
delIds
=
new
ArrayList
<
Long
>();
List
<
Long
>
dbs
=
functionConsoleService
.
getFunctionByRole
(
roleId
);
Iterator
<
Long
>
it
=
all
.
iterator
();
for
(
Long
id:
all
)
{
if
(!
dbs
.
contains
(
id
))
{
addIds
.
add
(
id
);
}
}
for
(
Long
id:
dbs
)
{
if
(!
all
.
contains
(
id
))
{
delIds
.
add
(
id
);
}
}
functionConsoleService
.
updateSysRoleFunction
(
roleId
,
addIds
,
delIds
);
return
JsonResult
.
success
();
}
@PostMapping
(
MODEL
+
"/function/updateDataAccess.json"
)
@Function
(
"role.function.updateDataAccess"
)
@ResponseBody
public
JsonResult
updateFunctionDataAccess
(
Long
roleId
,
Long
fnId
,
Integer
accessType
)
{
RoleDataAccessFunction
data
=
new
RoleDataAccessFunction
();
data
.
setRoleId
(
roleId
);
data
.
setId
(
fnId
);
data
.
setDataAccessType
(
accessType
);
functionConsoleService
.
updateFunctionAccessByRole
(
Arrays
.
asList
(
data
));
return
JsonResult
.
success
();
}
/*后端模板渲染*/
@PostMapping
(
MODEL
+
"/function/dataAccess.do"
)
@Function
(
"role.function.updateDataAccess"
)
public
ModelAndView
datapage
(
Long
roleId
)
{
List
<
RoleDataAccessFunction
>
list
=
functionConsoleService
.
getQueryFunctionByRole
(
roleId
);
ModelAndView
view
=
new
ModelAndView
(
"/admin/role/dataConfigPart.html"
);
view
.
addObject
(
"list"
,
list
);
return
view
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/UserConsoleController.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.service.OrgConsoleService
;
import
com.ibeetl.admin.console.service.RoleConsoleService
;
import
com.ibeetl.admin.console.service.UserConsoleService
;
import
com.ibeetl.admin.console.web.query.UserQuery
;
import
com.ibeetl.admin.console.web.query.UserRoleQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.entity.CoreUserRole
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.AnnotationUtil
;
import
com.ibeetl.admin.core.util.ConvertUtil
;
import
com.ibeetl.admin.core.util.DictUtil
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.util.enums.GeneralStateEnum
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
* 用户管理接口
*
* @author xiandafu
*/
@Controller
public
class
UserConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/user"
;
@Autowired
UserConsoleService
userConsoleService
;
@Autowired
CorePlatformService
platformService
;
@Autowired
RoleConsoleService
roleConsoleService
;
@Autowired
OrgConsoleService
orgConsoleService
;
@Autowired
DictUtil
dictUtil
;
/* 页面 */
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"user.edit"
)
@ResponseBody
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/user/index.html"
);
view
.
addObject
(
"search"
,
UserQuery
.
class
.
getName
());
return
view
;
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"user.edit"
)
@ResponseBody
public
ModelAndView
edit
(
String
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/user/edit.html"
);
CoreUser
user
=
userConsoleService
.
queryById
(
id
);
view
.
addObject
(
"user"
,
user
);
return
view
;
}
@GetMapping
(
MODEL
+
"/add.do"
)
@Function
(
"user.add"
)
@ResponseBody
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/user/add.html"
);
return
view
;
}
@GetMapping
(
MODEL
+
"/changePassword.do"
)
@Function
(
"user.add"
)
@ResponseBody
public
ModelAndView
changePassword
(
Long
id
)
{
CoreUser
user
=
userConsoleService
.
queryById
(
id
);
ModelAndView
view
=
new
ModelAndView
(
"/admin/user/changePassword.html"
);
view
.
addObject
(
"user"
,
user
);
return
view
;
}
@GetMapping
(
MODEL
+
"/role/list.do"
)
@Function
(
"user.role"
)
@ResponseBody
public
ModelAndView
userRoleIndex
(
Long
id
)
{
CoreUser
user
=
userConsoleService
.
queryById
(
id
);
ModelAndView
view
=
new
ModelAndView
(
"/admin/user/userRole.html"
);
view
.
addObject
(
"search"
,
UserRoleQuery
.
class
.
getName
());
view
.
addObject
(
"user"
,
user
);
return
view
;
}
@GetMapping
(
MODEL
+
"/role/add.do"
)
@Function
(
"user.role"
)
@ResponseBody
public
ModelAndView
userRoleAdd
(
Long
id
)
{
CoreUser
user
=
userConsoleService
.
queryById
(
id
);
ModelAndView
view
=
new
ModelAndView
(
"/admin/user/userRoleAdd.html"
);
view
.
addObject
(
"user"
,
user
);
return
view
;
}
/* Json */
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"user.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
List
<
Long
>
dels
=
ConvertUtil
.
str2longs
(
ids
);
userConsoleService
.
batchDelSysUser
(
dels
);
return
JsonResult
.
success
();
}
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"user.update"
)
@ResponseBody
public
JsonResult
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreUser
user
)
{
boolean
success
=
userConsoleService
.
updateTemplate
(
user
);
if
(
success
)
{
this
.
platformService
.
clearFunctionCache
();
return
JsonResult
.
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败!"
);
}
}
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"user.add"
)
@ResponseBody
public
JsonResult
<
Long
>
add
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreUser
user
)
{
if
(!
platformService
.
isAllowUserName
(
user
.
getCode
()))
{
return
JsonResult
.
failMessage
(
"不允许的注册名字 "
+
user
.
getCode
());
}
user
.
setCreateTime
(
new
Date
());
userConsoleService
.
saveUser
(
user
);
return
JsonResult
.
success
(
user
.
getId
());
}
@PostMapping
(
MODEL
+
"/view.json"
)
@ResponseBody
@Function
(
"user.query"
)
public
JsonResult
<
CoreUser
>
view
(
Long
id
)
{
CoreUser
user
=
userConsoleService
.
queryById
(
id
);
return
JsonResult
.
success
(
user
);
}
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"user.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreUser
>>
index
(
UserQuery
condtion
)
{
PageQuery
<
CoreUser
>
page
=
condtion
.
getPageQuery
();
userConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"user.query"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
indexCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
UserQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
@PostMapping
(
MODEL
+
"/disable.json"
)
@Function
(
"user.disable"
)
@ResponseBody
public
JsonResult
disableUser
(
String
ids
)
{
List
<
Long
>
dels
=
ConvertUtil
.
str2longs
(
ids
);
userConsoleService
.
batchUpdateUserState
(
dels
,
GeneralStateEnum
.
DISABLE
);
for
(
Long
id
:
dels
)
{
CoreUser
user
=
userConsoleService
.
queryById
(
id
);
this
.
platformService
.
restUserSession
(
user
.
getCode
());
}
return
JsonResult
.
success
();
}
/**
* 启用用户操作
*
* @return
*/
@PostMapping
(
MODEL
+
"/enable.json"
)
@Function
(
"user.enable"
)
@ResponseBody
public
JsonResult
enableUser
(
String
ids
)
{
List
<
Long
>
enables
=
ConvertUtil
.
str2longs
(
ids
);
userConsoleService
.
batchUpdateUserState
(
enables
,
GeneralStateEnum
.
ENABLE
);
return
JsonResult
.
success
();
}
/**
* 管理员重置用户密码
*
* @return
*/
@PostMapping
(
MODEL
+
"/changePassword.json"
)
@Function
(
"user.reset"
)
@ResponseBody
public
JsonResult
changePassword
(
Long
id
,
String
password
)
{
userConsoleService
.
resetPassword
(
id
,
password
);
return
new
JsonResult
().
success
();
}
/**
* 用户所有授权角色列表
*
* @param id
* 用户id
* @return
*/
@PostMapping
(
MODEL
+
"/role/list.json"
)
@Function
(
"user.role"
)
@ResponseBody
public
JsonResult
<
List
<
CoreUserRole
>>
getRoleList
(
UserRoleQuery
roleQuery
)
{
List
<
CoreUserRole
>
list
=
userConsoleService
.
getUserRoles
(
roleQuery
);
return
JsonResult
.
success
(
list
);
}
/**
* 用户添加授权角色页
*
* @return
*/
@PostMapping
(
MODEL
+
"/role/add.json"
)
@Function
(
"user.role"
)
@ResponseBody
public
JsonResult
saveUserRole
(
@Validated
CoreUserRole
userRole
)
{
userRole
.
setCreateTime
(
new
Date
());
this
.
userConsoleService
.
saveUserRole
(
userRole
);
this
.
platformService
.
clearFunctionCache
();
return
JsonResult
.
success
(
userRole
.
getId
());
}
/**
* 删除用户角色授权
*
* @return
*/
@PostMapping
(
MODEL
+
"/role/delete.json"
)
@Function
(
"user.role"
)
@ResponseBody
public
JsonResult
delUserRole
(
String
ids
)
{
List
<
Long
>
dels
=
ConvertUtil
.
str2longs
(
ids
);
userConsoleService
.
deleteUserRoles
(
dels
);
this
.
platformService
.
clearFunctionCache
();
return
JsonResult
.
success
();
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/dto/RoleDataAccessFunction.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web.dto
;
import
com.ibeetl.admin.core.entity.CoreFunction
;
public
class
RoleDataAccessFunction
extends
CoreFunction
{
private
Integer
dataAccessType
;
private
Long
roleId
;
public
Integer
getDataAccessType
()
{
return
dataAccessType
;
}
public
void
setDataAccessType
(
Integer
dataAccessType
)
{
this
.
dataAccessType
=
dataAccessType
;
}
public
Long
getRoleId
()
{
return
roleId
;
}
public
void
setRoleId
(
Long
roleId
)
{
this
.
roleId
=
roleId
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/query/AuditQuery.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web.query
;
import
java.util.Date
;
import
org.apache.commons.lang3.StringUtils
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.util.Tool
;
import
com.ibeetl.admin.core.web.query.PageParam
;
/**
* 审计查询条件
*/
public
class
AuditQuery
extends
PageParam
{
@Query
(
name
=
"功能名称"
,
display
=
true
,
fuzzy
=
true
)
private
String
functionName
;
@Query
(
name
=
"功能编号"
,
display
=
true
,
fuzzy
=
true
)
private
String
functionCode
;
@Query
(
name
=
"用户名称"
,
display
=
true
,
fuzzy
=
true
)
private
String
userName
;
@Query
(
name
=
"创建日期"
,
display
=
true
,
type
=
Query
.
TYPE_DATE_BETWEEN
)
private
String
createDateRange
;
private
Date
createDateMin
;
private
Date
createDateMax
;
public
String
getFunctionCode
()
{
return
functionCode
;
}
public
void
setFunctionCode
(
String
functionCode
)
{
this
.
functionCode
=
functionCode
;
}
public
String
getUserName
()
{
return
userName
;
}
public
void
setUserName
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getCreateDateRange
()
{
return
createDateRange
;
}
public
void
setCreateDateRange
(
String
createDateRange
)
{
this
.
createDateRange
=
createDateRange
;
if
(
StringUtils
.
isEmpty
(
createDateRange
))
{
return
;
}
Date
[]
ds
=
Tool
.
parseDataRange
(
createDateRange
);
this
.
createDateMin
=
ds
[
0
];
this
.
createDateMax
=
ds
[
1
];
}
public
Date
getCreateDateMin
()
{
return
createDateMin
;
}
public
void
setCreateDateMin
(
Date
createDateMin
)
{
this
.
createDateMin
=
createDateMin
;
}
public
Date
getCreateDateMax
()
{
return
createDateMax
;
}
public
void
setCreateDateMax
(
Date
createDateMax
)
{
this
.
createDateMax
=
createDateMax
;
}
public
String
getFunctionName
()
{
return
functionName
;
}
public
void
setFunctionName
(
String
functionName
)
{
this
.
functionName
=
functionName
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/query/CmsBlogQuery.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web.query
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
import
com.ibeetl.admin.core.web.query.PageParam
;
import
java.util.Date
;
/**
*CmsBlog查询
*/
public
class
CmsBlogQuery
extends
PageParam
{
@Query
(
name
=
"id"
,
display
=
true
)
private
Integer
id
;
public
Integer
getId
(){
return
id
;
}
public
void
setId
(
Integer
id
){
this
.
id
=
id
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/query/CoreDictQuery.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web.query
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
import
com.ibeetl.admin.core.web.query.PageParam
;
import
java.util.Date
;
/**
*CoreDict查询
*/
public
class
CoreDictQuery
extends
PageParam
{
@Query
(
name
=
"字典值"
,
display
=
true
)
private
String
value
;
@Query
(
name
=
"字典名称"
,
display
=
true
)
private
String
name
;
@Query
(
name
=
"字典类型名称"
,
display
=
true
)
private
String
typeName
;
@Query
(
name
=
"父字典"
,
display
=
true
)
private
String
parent
;
public
String
getValue
(){
return
value
;
}
public
void
setValue
(
String
value
){
this
.
value
=
value
;
}
public
String
getName
(){
return
name
;
}
public
void
setName
(
String
name
){
this
.
name
=
name
;
}
public
String
getTypeName
(){
return
typeName
;
}
public
void
setTypeName
(
String
typeName
){
this
.
typeName
=
typeName
;
}
public
String
getParent
(){
return
parent
;
}
public
void
setParent
(
String
parent
){
this
.
parent
=
parent
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/query/CoreFunctionQuery.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web.query
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.util.enums.CoreDictType
;
import
com.ibeetl.admin.core.web.query.PageParam
;
/**
*功能查询
*/
public
class
CoreFunctionQuery
extends
PageParam
{
@Query
(
name
=
"名称"
,
display
=
true
)
private
String
name
;
@Query
(
name
=
"访问路径"
,
display
=
true
)
private
String
accessUrl
;
@Query
(
name
=
"功能点类型"
,
display
=
true
)
private
String
type
;
public
String
getName
(){
return
name
;
}
public
void
setName
(
String
name
){
this
.
name
=
name
;
}
public
String
getAccessUrl
(){
return
accessUrl
;
}
public
void
setAccessUrl
(
String
accessUrl
){
this
.
accessUrl
=
accessUrl
;
}
public
String
getType
(){
return
type
;
}
public
void
setType
(
String
type
){
this
.
type
=
type
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/query/FunctionQuery.java
0 → 100644
View file @
321361c9
package
com.ibeetl.admin.console.web.query
;
import
java.util.List
;
import
com.ibeetl.admin.core.annotation.Query
;
import
com.ibeetl.admin.core.web.query.PageParam
;
/**
* 功能表单查询条件
*/
public
class
FunctionQuery
extends
PageParam
{
@Query
(
name
=
"代码"
,
display
=
true
,
fuzzy
=
true
)
private
String
code
;
@Query
(
name
=
"名称"
,
display
=
true
,
fuzzy
=
true
)
private
String
name
;
@Query
(
name
=
"访问地址"
,
fuzzy
=
true
)
private
String
accessUrl
;
@Query
(
name
=
"上一级功能"
,
display
=
true
,
type
=
Query
.
TYPE_CONTROL
,
control
=
"fun"
)
private
Long
parentFunctionId
;
private
Long
functionId
;
//查询子类
private
List
<
Long
>
functionIds
;
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getAccessUrl
()
{
return
accessUrl
;
}
public
void
setAccessUrl
(
String
accessUrl
)
{
this
.
accessUrl
=
accessUrl
;
}
public
List
<
Long
>
getFunctionIds
()
{
return
functionIds
;
}
public
void
setFunctionIds
(
List
<
Long
>
functionIds
)
{
this
.
functionIds
=
functionIds
;
}
public
Long
getFunctionId
()
{
return
functionId
;
}
public
void
setFunctionId
(
Long
functionId
)
{
this
.
functionId
=
functionId
;
}
public
Long
getParentFunctionId
()
{
return
parentFunctionId
;
}
public
void
setParentFunctionId
(
Long
parentFunctionId
)
{
this
.
parentFunctionId
=
parentFunctionId
;
}
}
Prev
1
2
3
4
5
6
…
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