feat(fix): 1.权限查询效率优化 2.替换权限开启图标,3.授权对象类型切换 授权资源权限依旧保留问题,4.开放普通用户 组织对菜单的授权

This commit is contained in:
wangjiahao 2021-06-04 23:21:47 +08:00
parent 03f43fde95
commit 0b56ae1b3c
5 changed files with 39 additions and 15 deletions

View File

@ -8,18 +8,30 @@
<result column="leaf" property="leaf"/>
</resultMap>
<!-- 函数嵌套会导致循环调用函数 导致查询速度变慢 所有预先经需要嵌套查询的函数分解查询-->
<select id="searchTree" resultMap="BaseResultMapDTO">
SELECT
auth.*,
authCount.children_count AS children_count,
IF
(( authCount.children_count > 0 ), 0, 1 ) AS leaf
FROM (select get_grant_auths (#{modelType},#{createBy}) cids1) t1,
( SELECT * FROM (select get_grant_auths (#{modelType},#{createBy}) cids2) t2 ,v_auth_model
FROM (select get_grant_auths (#{modelType},#{createBy}) c_auth_ids) t1,
( SELECT * FROM (select GET_V_AUTH_MODEL_WITH_PARENT(get_grant_auths (#{modelType},#{createBy}),#{modelType}) c_auth_parent_ids) t2,
<if test="withExtend == 'parent' and id != null">
(select GET_V_AUTH_MODEL_WITH_PARENT(#{id},#{modelType}) c_model_parent_ids) tmp,
</if>
<if test="withExtend == 'children' and id != null">
(select GET_V_AUTH_MODEL_WITH_CHILDREN(#{id},#{modelType}) c_model_children_ids) tmc,
</if>
<if test="name != null and name !='' and withExtend == 'parent'">
(select GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from
v_auth_model where model_type = #{modelType} and `name` like CONCAT('%', #{name},'%')) ,#{modelType}) c_model_parent_seartch_ids) tmsc,
</if>
v_auth_model
<where>
model_type = #{modelType}
<if test="1== withAuth">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( cids2 ,#{modelType}))
and FIND_IN_SET(v_auth_model.id,c_auth_parent_ids)
</if>
<if test="pid !=null">
and v_auth_model.pid = #{pid}
@ -29,15 +41,14 @@
and v_auth_model.id = #{id}
</if>
<if test="withExtend == 'parent' and id != null">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT(#{id},#{modelType}))
and FIND_IN_SET(v_auth_model.id,c_model_parent_ids)
</if>
<if test="withExtend == 'children' and id != null">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_CHILDREN(#{id},#{modelType}))
and FIND_IN_SET(v_auth_model.id,c_model_children_ids)
</if>
<if test="name != null and name !='' and withExtend == 'parent'">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from
v_auth_model where model_type = #{modelType} and `name` like CONCAT('%', #{name},'%')) ,#{modelType}))
and FIND_IN_SET(v_auth_model.id,c_model_parent_seartch_ids)
</if>
<if test="name != null and name =='' and withExtend == 'parent'">
@ -51,11 +62,11 @@
count( 1 ) AS `children_count`,
`authTemp`.`pid` AS `pid`
FROM
( SELECT * FROM (select get_grant_auths (#{modelType},#{createBy}) cids3) t3,v_auth_model
( SELECT * FROM (select GET_V_AUTH_MODEL_WITH_PARENT(get_grant_auths (#{modelType},#{createBy}),#{modelType}) cids3) t3,v_auth_model
<where>
model_type = #{modelType}
<if test="1== withAuth">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( cids3 ,#{modelType}))
and FIND_IN_SET(v_auth_model.id,cids3)
</if>
</where>
) authTemp
@ -65,7 +76,7 @@
auth.id = authCount.pid
<where>
<if test="1== withAuth">
(authCount.children_count>0 or FIND_IN_SET(auth.id,cids1) )
(authCount.children_count>0 or FIND_IN_SET(auth.id,c_auth_ids) )
</if>
</where>

View File

@ -1 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1622003025732" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7043" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M810.666667 213.333333l0 597.333333L213.333333 810.666667 213.333333 213.333333 810.666667 213.333333M810.666667 128 213.333333 128C166.4 128 128 166.4 128 213.333333l0 597.333333c0 46.933333 38.4 85.333333 85.333333 85.333333l597.333333 0c46.933333 0 85.333333-38.4 85.333333-85.333333L896 213.333333C896 166.4 857.6 128 810.666667 128L810.666667 128z" p-id="7044" fill="#bfbfbf"></path></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1622801178544" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1323" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M2 512c0-141 114-255 255-255h510c141 0 255 114 255 255S908 767 767 767H257C116 767 2 653 2 512z m255 208.8c115.5 0 208.8-93.2 208.8-208.8S372.5 303.2 257 303.2c-115.5 0-208.8 93.2-208.8 208.8S141.5 720.8 257 720.8z" fill="#DCDFE6" p-id="1324"></path></svg>

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 633 B

View File

@ -1 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1622002928181" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6752" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M810.666667 128H213.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v597.333334c0 46.933333 38.4 85.333333 85.333333 85.333333h597.333334c46.933333 0 85.333333-38.4 85.333333-85.333333V213.333333c0-46.933333-38.4-85.333333-85.333333-85.333333z m-384 597.333333l-213.333334-213.333333 59.733334-59.733333 153.6 153.6 324.266666-324.266667L810.666667 341.333333l-384 384z" p-id="6753" fill="#0a7be0"></path></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1622801110786" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="17204" data-spm-anchor-id="a313x.7781069.0.i2" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M2 512c0-141 114-255 255-255h510c141 0 255 114 255 255S908 767 767 767H257C116 767 2 653 2 512z m765 208.8c115.5 0 208.8-93.2 208.8-208.8S882.5 303.2 767 303.2c-115.5 0-208.8 93.2-208.8 208.8S651.5 720.8 767 720.8z" fill="#0a7be0" p-id="17205"></path></svg>

Before

Width:  |  Height:  |  Size: 794 B

After

Width:  |  Height:  |  Size: 675 B

View File

@ -10,6 +10,7 @@
<el-tabs v-model="targetActiveName" :class="{'de-search-header': showTargetSearchInput}" @tab-click="handleClick">
<el-tab-pane v-for="(targetInfo, index) in targetInfoArray" :key="index" :lazy="true" :label="targetInfo.tabName" :name="targetInfo.authType">
<lazy-tree
v-if="targetActiveName===targetInfo.authType"
:active-name="targetActiveName"
:filter-text="targetFilterText"
:data-info="targetInfo"
@ -35,6 +36,7 @@
:data-info="sourceInfo"
show-extent
:auth-condition="authCondition"
:attach-active-name="targetActiveName"
/>
</el-tab-pane>
</el-tabs>
@ -115,7 +117,7 @@ export default {
head: this.$t('auth.menuAuthHead'),
direction: 'source',
authType: 'menu',
authTargets: 'role'
authTargets: 'dept,role,user'
}
],
targetActiveName: null,

View File

@ -1,5 +1,5 @@
<template xmlns:el-col="http://www.w3.org/1999/html">
<el-col class="tree-main">
<el-col v-loading="loading" class="tree-main">
<el-row v-if="showExtent" class="tree-head">
<span style="float: left;padding-left: 10px">{{ dataInfo.head }}</span>
<span v-for="auth in defaultAuthDetails" :key="auth.privilegeName" class="auth-span">
@ -67,6 +67,7 @@ export default {
type: String,
required: true
},
attachActiveName: String,
defaultProps: {
type: Object,
required: false,
@ -85,6 +86,7 @@ export default {
},
data() {
return {
loading: false,
treeData: [],
changeIndex: 0,
timeMachine: null,
@ -119,6 +121,12 @@ export default {
this.loadAuth()
},
deep: true
},
attachActiveName: {
handler(newVal, oldVla) {
this.authDetails = {}
},
deep: true
}
},
created() {
@ -138,7 +146,8 @@ export default {
// authTarget authSource
authQueryCondition = {
authTarget: this.authCondition.id,
authTargetType: this.authCondition.type
authTargetType: this.authCondition.type,
authSourceType: this.dataInfo.authType
}
} else {
authQueryCondition = {
@ -248,9 +257,11 @@ export default {
authDetail: auth
}
}
this.loading = true
authChange(authChangeCondition).then(res => {
//
this.loadAuth()
this.loading = false
})
},
//