Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skboot-zhongye
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
1c8fa252
由
张雷
编写于
2024-10-31 12:10:37 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
角色权限修改
1 个父辈
280a35af
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
65 行增加
和
16 行删除
sk-module-system/src/main/java/com/skua/modules/system/controller/SysRoleController.java
sk-module-system/src/main/java/com/skua/modules/system/entity/SysRole.java
sk-module-system/src/main/java/com/skua/modules/system/mapper/SysUserMapper.java
sk-module-system/src/main/java/com/skua/modules/system/mapper/xml/SysUserMapper.xml
sk-module-system/src/main/java/com/skua/modules/system/service/impl/SysUserDepartServiceImpl.java
sk-module-system/src/main/java/com/skua/modules/system/service/impl/SysUserServiceImpl.java
sk-module-system/src/main/java/com/skua/modules/system/controller/SysRoleController.java
查看文件 @
1c8fa25
...
...
@@ -13,15 +13,14 @@ import com.skua.core.context.BaseContextHandler;
import
com.skua.core.entity.SysPermissionDataRule
;
import
com.skua.core.query.QueryGenerator
;
import
com.skua.core.util.ConvertUtils
;
import
com.skua.modules.system.entity.SysDepart
;
import
com.skua.modules.system.entity.SysPermission
;
import
com.skua.modules.system.entity.SysRole
;
import
com.skua.modules.system.entity.SysRolePermission
;
import
com.skua.modules.system.model.TreeModel
;
import
com.skua.modules.system.service.ISysPermissionDataRuleService
;
import
com.skua.modules.system.service.ISysPermissionService
;
import
com.skua.modules.system.service.ISysRolePermissionService
;
import
com.skua.modules.system.service.ISysRoleService
;
import
com.skua.modules.system.service.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.jeecgframework.poi.excel.ExcelImportUtil
;
import
org.jeecgframework.poi.excel.def.NormalExcelConstants
;
...
...
@@ -51,6 +50,9 @@ public class SysRoleController {
private
ISysRoleService
sysRoleService
;
@Autowired
private
ISysDepartService
sysDepartService
;
@Autowired
private
ISysPermissionDataRuleService
sysPermissionDataRuleService
;
@Autowired
...
...
@@ -75,9 +77,14 @@ public class SysRoleController {
Result
<
IPage
<
SysRole
>>
result
=
new
Result
<
IPage
<
SysRole
>>();
QueryWrapper
<
SysRole
>
queryWrapper
=
QueryGenerator
.
initQueryWrapper
(
role
,
req
.
getParameterMap
());
Page
<
SysRole
>
page
=
new
Page
<
SysRole
>(
pageNo
,
pageSize
);
// if(!BaseContextHandler.getUserId().equals("admin")){
// queryWrapper.notLike("role_code","admin");
// }
if
(
StringUtils
.
isNotEmpty
(
BaseContextHandler
.
getDeparts
())){
SysDepart
sysDepart
=
sysDepartService
.
getById
(
BaseContextHandler
.
getDeparts
());
if
(
sysDepart
!=
null
){
if
(!
"A01"
.
equals
(
sysDepart
.
getOrgCode
())){
queryWrapper
.
notLike
(
"role_type"
,
"group"
);
}
}
}
IPage
<
SysRole
>
pageList
=
sysRoleService
.
page
(
page
,
queryWrapper
);
result
.
setSuccess
(
true
);
result
.
setResult
(
pageList
);
...
...
@@ -195,6 +202,14 @@ public class SysRoleController {
if
(!
BaseContextHandler
.
getUserLoginName
().
equals
(
"admin"
)){
queryWrapper
.
notLike
(
"role_code"
,
"admin"
);
}
if
(
StringUtils
.
isNotEmpty
(
BaseContextHandler
.
getDeparts
())){
SysDepart
sysDepart
=
sysDepartService
.
getById
(
BaseContextHandler
.
getDeparts
());
if
(
sysDepart
!=
null
){
if
(!
"A01"
.
equals
(
sysDepart
.
getOrgCode
())){
queryWrapper
.
notLike
(
"role_type"
,
"group"
);
}
}
}
queryWrapper
.
orderByDesc
(
"create_time"
);
List
<
SysRole
>
list
=
sysRoleService
.
list
(
queryWrapper
);
if
(
list
==
null
||
list
.
size
()<=
0
)
{
...
...
sk-module-system/src/main/java/com/skua/modules/system/entity/SysRole.java
查看文件 @
1c8fa25
...
...
@@ -4,6 +4,7 @@ import java.io.Serializable;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
com.skua.core.aspect.annotation.Dict
;
import
org.jeecgframework.poi.excel.annotation.Excel
;
import
org.springframework.format.annotation.DateTimeFormat
;
...
...
@@ -44,6 +45,13 @@ public class SysRole implements Serializable {
private
String
roleCode
;
/**
* 角色编码
*/
@Excel
(
name
=
"角色类型"
,
width
=
15
)
@Dict
(
dicCode
=
"role_type"
)
private
String
roleType
;
/**
* 所属机构
*/
/*@Excel(name="所属机构",width=15)*/
...
...
sk-module-system/src/main/java/com/skua/modules/system/mapper/SysUserMapper.java
查看文件 @
1c8fa25
...
...
@@ -34,10 +34,11 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
*
* @param
* @param page
* @param
orgCode
* @param
roleId
* @return
*/
IPage
<
SysUser
>
getUserByRoleId
(
Page
page
,
@Param
(
"roleId"
)
String
roleId
,
@Param
(
"username"
)
String
username
);
IPage
<
SysUser
>
getUserByRoleId
(
Page
page
,
@Param
(
"roleId"
)
String
roleId
,
@Param
(
"username"
)
String
username
,
@Param
(
"departId"
)
String
departId
);
/**
* 根据用户名设置部门ID
...
...
@@ -74,4 +75,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
List
<
SysUser
>
getUserByUserIds
(
@Param
(
"userIds"
)
String
userIds
);
List
<
SysUser
>
operationUserList
(
@Param
(
"departId"
)
String
departId
);
String
queryDepartIdsByUserId
(
@Param
(
"userId"
)
String
userId
);
}
...
...
sk-module-system/src/main/java/com/skua/modules/system/mapper/xml/SysUserMapper.xml
查看文件 @
1c8fa25
...
...
@@ -17,13 +17,35 @@
<!-- 根据角色Id查询 -->
<select
id=
"getUserByRoleId"
resultType=
"com.skua.modules.system.entity.SysUser"
>
select * from sys_user where del_flag = '0' and is_system_user = '0'
and id in (select user_id from sys_user_role where role_id=#{roleId})
SELECT
u.*
FROM
sys_user u
LEFT JOIN sys_user_depart d ON u.id = d.user_id
WHERE
u.del_flag = '0'
AND u.is_system_user = '0'
AND u.id IN ( SELECT user_id FROM sys_user_role WHERE role_id = #{roleId} )
<if
test=
"username!=null and username!=''"
>
and (username like concat('%',#{username},'%') or realname like concat('%',#{username},'%'))
AND (u.username LIKE CONCAT('%',#{username},'%') or u.realname LIKE CONCAT('%',#{username},'%'))
</if>
<if
test=
"departId!=null and departId!=''"
>
AND d.dep_id IN
<foreach
item=
"item"
index=
"index"
collection=
"departId.split(',')"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</if>
</select>
<select
id=
"queryDepartIdsByUserId"
resultType=
"java.lang.String"
>
SELECT
CONCAT( dep_id, ',', dep_ids ) AS departs
FROM
sys_user_depart
WHERE
user_id = #{userId}
</select>
<!-- 修改用户部门code -->
<update
id=
"updateUserDepart"
>
UPDATE sys_user SET org_code = #{orgCode} where username = #{username}
...
...
sk-module-system/src/main/java/com/skua/modules/system/service/impl/SysUserDepartServiceImpl.java
查看文件 @
1c8fa25
...
...
@@ -114,6 +114,7 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
}
}
}
@Override
public
List
<
String
>
queryDepartIdsOfUserId
(
String
userId
)
{
List
<
String
>
departByUserId
=
baseMapper
.
getDepartByUserId
(
userId
);
...
...
sk-module-system/src/main/java/com/skua/modules/system/service/impl/SysUserServiceImpl.java
查看文件 @
1c8fa25
...
...
@@ -14,6 +14,7 @@ import com.skua.core.context.BaseContextHandler;
import
com.skua.core.util.ConvertUtils
;
import
com.skua.modules.system.entity.*
;
import
com.skua.modules.system.mapper.*
;
import
com.skua.modules.system.service.ISysUserDepartService
;
import
com.skua.modules.system.service.ISysUserService
;
import
com.skua.modules.system.vo.SysUserVO
;
import
com.skua.modules.websocket.WebSocket
;
...
...
@@ -24,6 +25,7 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -136,8 +138,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// SysUser user = userMapper.getUserByName(username);
// info.setSysUserCode(user.getUsername());
// info.setSysUserName(user.getRealname());
LoginUser
user
=
sysBaseAPI
.
getUserByName
(
username
);
if
(
user
!=
null
)
{
info
.
setSysUserCode
(
user
.
getUsername
());
...
...
@@ -170,11 +170,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return
userMapper
.
getUserByDepId
(
page
,
departId
,
username
);
}
// 根据角色Id查询
@Override
public
IPage
<
SysUser
>
getUserByRoleId
(
Page
<
SysUser
>
page
,
String
roleId
,
String
username
)
{
return
userMapper
.
getUserByRoleId
(
page
,
roleId
,
username
);
String
departIds
=
userMapper
.
queryDepartIdsByUserId
(
BaseContextHandler
.
getUserId
());
return
userMapper
.
getUserByRoleId
(
page
,
roleId
,
username
,
departIds
);
}
//获取登录人所属集团
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论