Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
bed72360
Commit
bed72360
authored
Sep 08, 2023
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.5.8-hgw-权限-角色-账号
parent
178255c5
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
145 additions
and
16 deletions
+145
-16
SysUserRoleRes.java
.../cloud/plus/v1/yifu/permission/entity/SysUserRoleRes.java
+3
-0
SysUserInfoController.java
.../plus/v1/permission/controller/SysUserInfoController.java
+1
-2
SysUserRoleResController.java
...us/v1/permission/controller/SysUserRoleResController.java
+10
-0
SysUserInfoMapper.java
...fu/cloud/plus/v1/permission/mapper/SysUserInfoMapper.java
+7
-1
SysUserRoleResMapper.java
...cloud/plus/v1/permission/mapper/SysUserRoleResMapper.java
+11
-0
SysUserInfoService.java
.../cloud/plus/v1/permission/service/SysUserInfoService.java
+7
-1
SysUserRoleResService.java
...oud/plus/v1/permission/service/SysUserRoleResService.java
+9
-0
SysUserInfoServiceImpl.java
...us/v1/permission/service/impl/SysUserInfoServiceImpl.java
+41
-4
SysUserRoleResServiceImpl.java
...v1/permission/service/impl/SysUserRoleResServiceImpl.java
+12
-0
SysUserInfoMapper.xml
...ssion-biz/src/main/resources/mapper/SysUserInfoMapper.xml
+35
-8
SysUserRoleResMapper.xml
...on-biz/src/main/resources/mapper/SysUserRoleResMapper.xml
+9
-0
No files found.
yifu-permission/yifu-permission-api/src/main/java/com/yifu/cloud/plus/v1/yifu/permission/entity/SysUserRoleRes.java
View file @
bed72360
...
...
@@ -67,4 +67,7 @@ public class SysUserRoleRes {
@TableField
(
exist
=
false
)
private
String
roleName
;
@TableField
(
exist
=
false
)
private
String
userName
;
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/controller/SysUserInfoController.java
View file @
bed72360
...
...
@@ -151,8 +151,7 @@ public class SysUserInfoController {
@SysLog
(
"测试权限sql"
)
@PostMapping
(
"/testPermission"
)
public
R
<
String
>
testPermission
(
@RequestParam
String
menuId
,
@RequestParam
(
required
=
false
)
String
userId
)
{
sysUserInfoService
.
testPermission
(
menuId
,
userId
);
return
R
.
ok
();
return
R
.
ok
(
sysUserInfoService
.
testPermission
(
menuId
,
userId
));
}
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/controller/SysUserRoleResController.java
View file @
bed72360
...
...
@@ -56,6 +56,16 @@ public class SysUserRoleResController {
return
R
.
ok
(
sysUserRoleResService
.
noPageDiy
(
sysUserRoleRes
));
}
/**
* 根据角色id获取被使用的账号名称
* @return
*/
@Operation
(
summary
=
"根据角色id获取被使用的账号名称"
,
description
=
"根据角色id获取被使用的账号名称"
)
@GetMapping
(
"/getSysUserByRoleId"
)
public
R
<
List
<
String
>>
getSysUserByRoleId
(
@RequestParam
String
roleId
)
{
return
R
.
ok
(
sysUserRoleResService
.
getSysUserByRoleId
(
roleId
));
}
/**
* 通过id查询新权限-账号-角色关联表
*
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/mapper/SysUserInfoMapper.java
View file @
bed72360
...
...
@@ -54,7 +54,13 @@ public interface SysUserInfoMapper extends BaseMapper<SysUserInfo> {
List
<
SysUserRoleRes
>
getResAndRoleNameUserId
(
@Param
(
"userId"
)
String
userId
);
List
<
SysUserInfo
>
getAuthByUserAndMenu
(
@Param
(
"menuId"
)
String
menuId
,
@Param
(
"userId"
)
String
userId
);
/**
* @Description: 获取列表是否全量的权限
* @Author: hgw
* @Date: 2023/9/8 17:00
* @return: java.lang.int
**/
int
getAuthByUserIdAndMenuId
(
@Param
(
"menuId"
)
String
menuId
,
@Param
(
"userId"
)
String
userId
);
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/mapper/SysUserRoleResMapper.java
View file @
bed72360
...
...
@@ -22,6 +22,8 @@ import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserRoleRes;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 新权限-账号-角色关联表
*
...
...
@@ -38,6 +40,15 @@ public interface SysUserRoleResMapper extends BaseMapper<SysUserRoleRes> {
*/
IPage
<
SysUserRoleRes
>
getSysUserRoleResPage
(
Page
<
SysUserRoleRes
>
page
,
@Param
(
"sysUserRoleRes"
)
SysUserRoleRes
sysUserRoleRes
);
/**
* @param roleId
* @Description: 根据角色id获取被使用的账号名称
* @Author: hgw
* @Date: 2023/9/8 17:38
* @return: java.util.List<java.lang.String>
**/
List
<
String
>
getSysUserByRoleId
(
@Param
(
"roleId"
)
String
roleId
);
boolean
deleteByUserId
(
@Param
(
"userId"
)
String
userId
);
boolean
deleteByRoleId
(
@Param
(
"roleId"
)
String
roleId
);
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysUserInfoService.java
View file @
bed72360
...
...
@@ -69,6 +69,12 @@ public interface SysUserInfoService extends IService<SysUserInfo> {
**/
void
doRefreshEkpUser
();
void
testPermission
(
String
menuId
,
String
userId
);
/**
* @Description: 给EKP用的,获取权限
* @Author: hgw
* @Date: 2023/9/8 16:35
* @return: java.lang.String
**/
String
testPermission
(
String
menuId
,
String
userId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysUserRoleResService.java
View file @
bed72360
...
...
@@ -25,6 +25,15 @@ public interface SysUserRoleResService extends IService<SysUserRoleRes> {
List
<
SysUserRoleRes
>
noPageDiy
(
SysUserRoleResSearchVo
searchVo
);
/**
* @param roleId
* @Description: 根据角色id获取被使用的账号名称
* @Author: hgw
* @Date: 2023/9/8 17:38
* @return: java.util.List<java.lang.String>
**/
List
<
String
>
getSysUserByRoleId
(
String
roleId
);
/**
* @param userId
* @Description: 根据账号删除关联表
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysUserInfoServiceImpl.java
View file @
bed72360
...
...
@@ -173,16 +173,53 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
private
final
SysMenuService
sysMenuService
;
/**
* @param menuId
* @param userId
* @Description: 给EKP用的,获取权限
* @Author: hgw
* @Date: 2023/9/8 16:04
* @return: void
**/
@Override
public
void
testPermission
(
String
menuId
,
String
userId
)
{
public
String
testPermission
(
String
menuId
,
String
userId
)
{
//1:获取菜单是否已配置,是:第2步;否:结束,用EKP本身权限;
//2:获取账号,有:第3步;无:结束,用EKP;
//3:检测账号的角色 是否有 对应的菜单,有,第4不,无:结束,用ekp;
//4:查询角色的数据权限,如果是全量或部分全量,检测当前菜单是否有对应维度,有,直接查全量,无,第5步;
//5:查询用户当前菜单数据权限,拼接sql:
//and ((客户字段 in (客户1,客户2))
//or (商机字段 in (商机1,商机2))
//)——最后一个括号放在最后合上,此处可以去掉
//6:判断创建人权限;
//or (docCreateUser = 账号id)
//7:部门权限
//如果有部门权限,先查部门以及下属部门的所有账号id;
//第6步的sql要改为:
//or (docCreateUser in (账号id,其他账号id))
String
sql
=
""
;
// 测试权限
SysMenu
menu
=
sysMenuService
.
getById
(
menuId
);
if
(
menu
!=
null
)
{
// TODO
baseMapper
.
getAuthByUserAndMenu
(
menuId
,
userId
);
// 返回0:无配置;1:全量;2:继续下一步,找数据权限配置
int
allAuth
=
baseMapper
.
getAuthByUserIdAndMenuId
(
menuId
,
userId
);
if
(
allAuth
==
0
)
{
sql
=
" 1=2 "
;
}
else
if
(
allAuth
==
1
)
{
sql
=
" 1=1 "
;
}
else
{
// TODO-继续下一步,找数据权限配置
}
}
}
if
(
Common
.
isNotNull
(
sql
))
{
return
" or ("
+
sql
+
" ) "
;
}
return
""
;
}
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysUserRoleResServiceImpl.java
View file @
bed72360
...
...
@@ -63,6 +63,18 @@ public class SysUserRoleResServiceImpl extends ServiceImpl<SysUserRoleResMapper,
return
baseMapper
.
selectList
(
wrapper
);
}
/**
* @param roleId
* @Description: 根据角色id获取被使用的账号名称
* @Author: hgw
* @Date: 2023/9/8 17:38
* @return: java.util.List<java.lang.String>
**/
@Override
public
List
<
String
>
getSysUserByRoleId
(
String
roleId
)
{
return
baseMapper
.
getSysUserByRoleId
(
roleId
);
}
@Override
public
boolean
deleteByUserId
(
String
userId
)
{
return
baseMapper
.
deleteByUserId
(
userId
);
...
...
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysUserInfoMapper.xml
View file @
bed72360
...
...
@@ -138,14 +138,41 @@
where a.user_id=#{userId}
</select>
<!--list-->
<select
id=
"getAuthByUserAndMenu"
resultMap=
"sysUserInfoMap"
>
SELECT
a.*
FROM sys_user_info a
LEFT JOIN sys_user_role_res res on a.fd_id=res.user_id
LEFT JOIN sys_role_info r on res.role_id=r.fd_id and r.delete_flag = 0 and r.status = 0
where a.fd_id=#{userId} and a.fd_id=#{menuId}
<!--给EKP用的,获取列表是否全量的权限-->
<!--#全量0;部分全量1;数据权限2;客户a;商机b;报价单c;合同d;项目e;BUf;条线g;收入归属h;)-->
<select
id=
"getAuthByUserIdAndMenuId"
resultType=
"java.lang.Integer"
>
select
case
when a.data_auth is null then 0
when a.data_auth like "%0%" then 1
when a.data_auth like "%a%" and a.CUSTOMER_ID is not null then 1
when a.data_auth like "%b%" and a.BUSSINESS_ID is not null then 1
when a.data_auth like "%c%" and a.QUOTATION_ID is not null then 1
when a.data_auth like "%d%" and a.CONTRACT_ID is not null then 1
when a.data_auth like "%e%" and a.DOMAIN_ID is not null then 1
when a.data_auth like "%f%" and a.BU_ID is not null then 1
when a.data_auth like "%g%" and a.LINE_ID is not null then 1
when a.data_auth like "%h%" and a.INCOME_ID is not null then 1
else 2 end
from (
SELECT
GROUP_CONCAT(DISTINCT a.data_auth) as data_auth
,b.INCOME_ID
,b.CUSTOMER_ID
,b.CONTRACT_ID
,b.BUSSINESS_ID
,b.QUOTATION_ID
,b.DOMAIN_ID
,b.BU_ID
,b.LINE_ID
FROM
sys_menu b
join sys_role_menu_res m on b.id=m.menu_id
join sys_role_info a on m.role_id = a.fd_id
join sys_user_role_res r on r.role_id = a.fd_id
where a.delete_flag = 0 and a.status = 0 and b.DELETE_STATUS='1' and b.PERMISSION_STATUS='0'
and r.user_id = #{userId} and b.MODEL_ID=#{menuId}
) a
</select>
</mapper>
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysUserRoleResMapper.xml
View file @
bed72360
...
...
@@ -57,6 +57,15 @@
</where>
</select>
<!--sysUserRoleRes简单分页查询-->
<select
id=
"getSysUserByRoleId"
resultType=
"java.lang.String"
>
SELECT
DISTINCT u.fd_name
FROM sys_user_role_res a
join sys_user_info u on a.user_id=u.fd_id
where a.role_id = #{roleId}
</select>
<!-- 根据账号删除关联表 -->
<delete
id=
"deleteByUserId"
>
delete from sys_user_role_res where user_id = #{userId}
...
...
Write
Preview
Markdown
is supported
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