Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
duckula
duckula-ops
提交
e9126310
duckula-ops
项目概览
duckula
/
duckula-ops
通知
6
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
duckula-ops
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e9126310
编写于
6月 18, 2021
作者:
偏锋书生
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
资源分派
上级
8e61f9c0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
21 deletion
+57
-21
src/main/java/net/wicp/tams/duckula/ops/pages/cas/ResAllot.java
...in/java/net/wicp/tams/duckula/ops/pages/cas/ResAllot.java
+43
-16
src/main/resources/net/wicp/tams/duckula/ops/pages/cas/ResAllot.tml
...esources/net/wicp/tams/duckula/ops/pages/cas/ResAllot.tml
+14
-5
未找到文件。
src/main/java/net/wicp/tams/duckula/ops/pages/cas/ResAllot.java
浏览文件 @
e9126310
package
net.wicp.tams.duckula.ops.pages.cas
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.List
;
import
org.apache.commons.collections.CollectionUtils
;
...
...
@@ -16,10 +17,13 @@ import org.apache.tapestry5.util.TextStreamResponse;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wicp.tams.app.duckula.controller.bean.models.SysOrg
;
import
net.wicp.tams.app.duckula.controller.bean.models.SysRole
;
import
net.wicp.tams.app.duckula.controller.bean.models.SysRoleAssignExample
;
import
net.wicp.tams.app.duckula.controller.bean.models.SysRoleRes
;
import
net.wicp.tams.app.duckula.controller.bean.models.SysRoleResExample
;
import
net.wicp.tams.app.duckula.controller.bean.models.SysRoleResExample.Criteria
;
import
net.wicp.tams.app.duckula.controller.dao.SysRoleAssignMapper
;
import
net.wicp.tams.app.duckula.controller.dao.SysRoleMapper
;
import
net.wicp.tams.app.duckula.controller.dao.SysRoleResMapper
;
import
net.wicp.tams.app.duckula.controller.service.cas.IMenuService
;
...
...
@@ -36,7 +40,6 @@ import net.wicp.tams.duckula.ops.pages.ParentPageBean;
*
*/
@Import
(
stack
=
"easyuistack"
)
@Slf4j
public
class
ResAllot
extends
ParentPageBean
<
SysOrg
>
{
@Inject
private
IMenuService
menuService
;
...
...
@@ -54,6 +57,8 @@ public class ResAllot extends ParentPageBean<SysOrg> {
@Inject
private
SysRoleResMapper
sysRoleResMapper
;
@Inject
private
SysRoleAssignMapper
sysRoleAssignMapper
;
public
String
getTreeData
()
{
List
<
EasyUINode
>
roots
=
menuService
.
findAllModuleMenu
(
I18NConvert
,
false
);
...
...
@@ -67,48 +72,59 @@ public class ResAllot extends ParentPageBean<SysOrg> {
List
<
SysRoleRes
>
roleRess
=
sysRoleResMapper
.
selectByMap
(
CollectionUtil
.
newMap
(
"role_id"
,
roleid
));
if
(
CollectionUtils
.
isNotEmpty
(
roleRess
))
{
for
(
SysRoleRes
roleRes
:
roleRess
)
{
if
(
"0"
.
equals
(
roleRes
.
getResId
()))
{
// TODO 查资源值
continue
;
}
retobj
.
add
(
roleRes
.
getResId
());
}
}
return
retobj
;
}
@SuppressWarnings
(
"rawtypes"
)
public
TextStreamResponse
onSaveMenuForRole
()
{
final
String
roleIdStr
=
request
.
getParameter
(
"roleId"
);
int
roleid
=
Integer
.
parseInt
(
roleIdStr
);
long
roleid
=
Long
.
parseLong
(
roleIdStr
);
String
nodeIds
=
request
.
getParameter
(
"nodeIds"
);
QueryWrapper
<
SysRoleRes
>
queryWrapper
=
new
QueryWrapper
<
SysRoleRes
>();
queryWrapper
.
eq
(
"role_id"
,
roleid
);
List
<
SysRoleRes
>
oldResList
=
sysRoleResMapper
.
selectList
(
queryWrapper
);
// 旧的权限
// 删除所有关联的资源
sysRoleResMapper
.
deleteByMap
(
CollectionUtil
.
newMap
(
"role_id"
,
roleid
));
// 添加新的资源对象
if
(
StringUtils
.
isNotBlank
(
nodeIds
))
{
SysRole
role
=
sysRoleMapper
.
selectById
(
roleid
);
String
[]
resAry
=
nodeIds
.
split
(
","
);
for
(
String
resIdStr
:
resAry
)
{
long
resid
=
Long
.
parseLong
(
resIdStr
);
final
List
<
String
>
newResIdList
=
Arrays
.
asList
(
resAry
);
List
<
Long
>
olsResIdList
=
(
List
<
Long
>)
CollectionUtil
.
getColFromObj
(
oldResList
,
"resId"
);
// 需要增加的id,string类型
Collection
addlist
=
CollectionUtils
.
select
(
newResIdList
,
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg0
)
{
return
!
olsResIdList
.
contains
(
Long
.
parseLong
(
String
.
valueOf
(
arg0
)));
}
});
SysRole
role
=
sysRoleMapper
.
selectById
(
roleid
);
for
(
Object
resIdStr
:
addlist
)
{
long
resid
=
Long
.
parseLong
(
String
.
valueOf
(
resIdStr
));
SysRoleRes
insertObj
=
new
SysRoleRes
();
insertObj
.
setAuthCode
(
1
l
);
insertObj
.
setRoleId
(
role
.
getId
());
insertObj
.
setResId
(
resid
);
;
sysRoleResMapper
.
insert
(
insertObj
);
}
final
List
<
String
>
newResList
=
Arrays
.
asList
(
resAry
);
// 删除的资源
@SuppressWarnings
(
"unchecked"
)
List
<
String
>
delList
=
(
List
<
String
>)
CollectionUtils
.
select
(
oldRes
List
,
new
Predicate
()
{
List
<
Long
>
delList
=
(
List
<
Long
>)
CollectionUtils
.
select
(
olsResId
List
,
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
object
)
{
return
!
newResList
.
contains
(
String
.
valueOf
(
object
));
return
!
newRes
Id
List
.
contains
(
String
.
valueOf
(
object
));
}
});
if
(
CollectionUtils
.
isNotEmpty
(
delList
))
{
SysRoleResExample
example
=
new
SysRoleResExample
();
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andResIdIn
(
delList
);
sysRoleResMapper
.
deleteByExample
(
example
);
}
// 保存到Redis缓存
// Jedis jedis = RedisClient.getConnectionDefault();
...
...
@@ -175,7 +191,18 @@ public class ResAllot extends ParentPageBean<SysOrg> {
public
TextStreamResponse
onDelRole
()
{
String
idstr
=
request
.
getParameter
(
"id"
);
sysRoleMapper
.
deleteById
(
Long
.
parseLong
(
idstr
));
long
roleId
=
Long
.
parseLong
(
idstr
);
sysRoleMapper
.
deleteById
(
roleId
);
// 删除角色对应的资源
SysRoleResExample
example
=
new
SysRoleResExample
();
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andRoleIdEqualTo
(
roleId
);
sysRoleResMapper
.
deleteByExample
(
example
);
// 删除角色对应的权限
SysRoleAssignExample
example2
=
new
SysRoleAssignExample
();
SysRoleAssignExample
.
Criteria
criteria2
=
example2
.
createCriteria
();
criteria2
.
andRoleIdEqualTo
(
roleId
);
sysRoleAssignMapper
.
deleteByExample
(
example2
);
return
retSuccInfo
();
}
...
...
src/main/resources/net/wicp/tams/duckula/ops/pages/cas/ResAllot.tml
浏览文件 @
e9126310
...
...
@@ -12,9 +12,9 @@
<t:loop
source=
"roles"
value=
"role"
>
<div
title=
"${role.name}"
class=
"easyui-layout"
data-options=
"queryParams:{id:'${role.id}',name:'${role.name}',status:'${role.status}',remark:'${role.remark}'}"
style=
"padding:0px;height:100%;"
>
<div
data-options=
"region:'west',title:'分派的资源',split:true,collapsible:false,fit:true"
style=
"width:350px;"
>
<a
class=
"easyui-linkbutton"
id=
"saveButton"
data-options=
"iconCls: 'icon-save'"
onClick=
"saveMenu(
${role.id}
)"
<a
class=
"easyui-linkbutton"
id=
"saveButton"
data-options=
"iconCls: 'icon-save'"
onClick=
"saveMenu(
'${role.id}'
)"
style=
"width:100px;height:28px;padding-top:2px;margin-top: 15px;margin-bottom: 15px;"
>
${message:common.button.save}
</a>
<ul
id=
"role${role.id}"
></ul>
<ul
id=
"role${role.id}"
name=
"roletree"
></ul>
</div>
<div
data-options=
"region:'east',title:'已分派的单位',split:true"
style=
"width:200px;padding:5px;background:#eee;height:100%"
>
可以分单位类型(组织、群组、职位) 查出单位,并且可以解除与角色的绑定
...
...
@@ -22,7 +22,7 @@
</div>
</t:loop>
</div>
<r:dialog
id=
"saveDlg"
height=
"2
00"
width=
"500"
toolbar=
"[{id:'saveRoleBut',text:'common.button.save',iconCls:'icon-save'}]
"
>
<r:dialog
id=
"saveDlg"
height=
"2
50"
width=
"500"
toolbar=
"[{id:'saveRoleBut',text:'common.button.save',iconCls:'icon-save'}]"
title=
"角色处理
"
>
<form
id=
"editForm"
>
<table
class=
"frame_table_list_2"
>
<tr>
...
...
@@ -105,8 +105,17 @@
//设置check
$
.
post
(
contextpath
+
'
/cas/ResAllot:querySelResForRole/
'
+
queryParams
.
id
,{},
function
(
data
){
$
.
each
(
data
,
function
(
i
,
n
){
var
node
=
$
(
treeid
).
tree
(
'
find
'
,
n
);
$
(
treeid
).
tree
(
'
check
'
,
node
.
target
);
var
node
=
$
(
treeid
).
tree
(
'
find
'
,
n
);
//如果有子节点就不要设置为勾选,这样会把下面的子全部勾选上。
try
{
var
nodes
=
$
(
treeid
).
tree
(
'
getChildren
'
,
node
.
target
);
// get checked nodes
if
(
nodes
){
if
(
nodes
.
length
==
0
){
$
(
treeid
).
tree
(
'
check
'
,
node
.
target
);
}
}
}
catch
(
e
){
}
});
},
'
json
'
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录