Commit d1e4d2c9 by wangchunyang

人员权限管理设置功能,增加人员选择组件

parent d0ced848
......@@ -73,5 +73,39 @@ public class KeyDmUserCategoryServiceImpl {
}
return SUCCESS;
}
@ApiOperation(value = "获取人员权限配置列表", desc = "从字典获取权限并关联用户")
public List<Map<String, Object>> selectPermissionConfigList() {
return commonService.findList(namespace + "selectPermissionConfigList", null);
}
@ApiOperation(value = "保存权限用户配置", desc = "保存权限对应的用户配置")
public String savePermissionUsers(Map<String, Object> map) {
if (map == null || map.get("permission_code") == null) {
throw new CustomException("参数缺失");
}
String permissionCode = map.get("permission_code").toString();
@SuppressWarnings("unchecked")
List<String> userIds = (List<String>) map.get("user_ids");
// 先删除原有配置
Map<String, Object> deleteParam = new HashMap<>();
deleteParam.put("permission_code", permissionCode);
commonService.delete(namespace + "deletePermissionUsers", deleteParam);
// 再插入新配置
if (userIds != null && !userIds.isEmpty()) {
for (String userId : userIds) {
Map<String, Object> insertParam = new HashMap<>();
insertParam.put("permission_code", permissionCode);
insertParam.put("user_id", userId);
commonService.insert(namespace + "insertPermissionUser", insertParam);
}
}
return SUCCESS;
}
}
......@@ -5,6 +5,7 @@ import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import com.scpyun.platform.jilinsscgsdp.utils.DataScopeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -86,6 +87,23 @@ public class KeyDmUserServiceImpl {
}
return SUCCESS;
}
@ApiOperation(value = "人员选择器列表查询", desc = "根据机构和权限过滤人员")
public Page<Map<String, Object>> selectUserSelectorList(Page<Map<String, Object>> map) {
if (map == null) map = new Page<>();
return commonService.findPage(namespace + "selectUserSelectorList", map);
}
@ApiOperation(value = "人员多选器列表查询", desc = "所有在职人员")
public Page<Map<String, Object>> selectUserMultiSelectorList(Page<Map<String, Object>> map) {
if (map == null) map = new Page<>();
Map<String, Object> user = (Map<String, Object>) map.getParams().get("_user");
// if (user != null) {
// Map<String, String> pos = DataScopeUtil.getPosition(user);
// map.getParams().put("orgId", pos.get("area_id"));
// }
return commonService.findPage(namespace + "selectUserMultiSelectorList", map);
}
}
......@@ -88,5 +88,69 @@
update_time = NOW()
WHERE id = #{id}
</update>
<!-- 获取人员权限配置列表(从字典获取权限并关联用户) -->
<select id="selectPermissionConfigList" resultType="map">
SELECT
d.value AS permission_code,
d.label AS permission_name,
GROUP_CONCAT(CONCAT(u.name) SEPARATOR ',') AS user_names,
JSON_ARRAYAGG(
JSON_OBJECT(
'user_id', pu.user_id,
'user_name', u.name
)
) AS users
FROM sys_dict d
LEFT JOIN jl_key_dm_permission_user pu ON pu.permission_code = d.value
LEFT JOIN jl_key_dm_user u ON u.id = pu.user_id AND u.is_used = 1 AND u.is_leave = 0
WHERE d.type = 'daily_manage_dict_permission'
AND d.del_flag = '0'
GROUP BY d.value, d.label
ORDER BY d.sort ASC
<!-- SELECT-->
<!-- d.value AS permission_code,-->
<!-- d.label AS permission_name,-->
<!-- GROUP_CONCAT(CONCAT(u.name, '(', u.gh, ')') SEPARATOR '; ') AS user_names,-->
<!-- JSON_ARRAYAGG(-->
<!-- JSON_OBJECT(-->
<!-- 'user_id', pu.user_id,-->
<!-- 'user_name', u.name,-->
<!-- 'gh', u.gh-->
<!-- )-->
<!-- ) AS users-->
<!-- FROM sys_dict d-->
<!-- LEFT JOIN jl_key_dm_permission_user pu ON pu.permission_code = d.value-->
<!-- LEFT JOIN jl_key_dm_user u ON u.Id = pu.user_id AND u.is_used = 1 AND u.is_leave = 0-->
<!-- WHERE d.type = 'daily_manage_dict_permission'-->
<!-- AND d.del_flag = '0'-->
<!-- GROUP BY d.value, d.label-->
<!-- ORDER BY d.sort ASC-->
</select>
<!-- 删除权限用户配置 -->
<delete id="deletePermissionUsers" parameterType="map">
DELETE FROM jl_key_dm_permission_user
WHERE permission_code = #{permission_code}
</delete>
<!-- 插入权限用户配置 -->
<insert id="insertPermissionUser" parameterType="map">
INSERT INTO jl_key_dm_permission_user(
id,
permission_code,
user_id,
create_by,
create_time,
order_no
) VALUES (
UUID(),
#{permission_code},
#{user_id},
#{_user.id},
NOW(),
0
)
</insert>
</mapper>
......@@ -5,7 +5,7 @@
<!-- 分页查询日常人员(可按姓名过滤) -->
<select id="selectList" parameterType="page" resultType="map">
SELECT
u.Id,
u.id,
u.is_ext,
u.is_leave,
u.rc_role_id,
......@@ -50,13 +50,13 @@
<!-- 根据 id 获取日常人员 -->
<select id="getById" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_user WHERE Id = #{id} LIMIT 1
SELECT * FROM jl_key_dm_user WHERE id = #{id} LIMIT 1
</select>
<!-- 插入 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_user(
Id, is_ext, is_leave, rc_role_id, office_id, name, gh, email, phone, mobile,
id, is_ext, is_leave, rc_role_id, office_id, name, gh, email, phone, mobile,
birthday, in_work_time, leader, leader_name, is_used, create_by, create_time, order_no
) VALUES (
#{id},
......@@ -97,9 +97,79 @@
update_by = #{_user.id},
update_time = NOW()
</set>
WHERE Id = #{id}
WHERE id = #{id}
</update>
<!-- 人员选择器列表查询(根据机构和权限过滤) -->
<select id="selectUserSelectorList" parameterType="page" resultType="map">
SELECT
u.id,
u.name,
u.gh,
u.email,
u.phone,
u.mobile,
o.name AS office_name,
GROUP_CONCAT(DISTINCT c.catgory_name SEPARATOR ', ') AS category_names
FROM jl_key_dm_user u
LEFT JOIN sys_office o ON o.id = u.office_id
LEFT JOIN jl_key_dm_user_catgory c ON FIND_IN_SET(c.id, u.rc_role_id) > 0
<where>
AND u.is_used = 1
AND u.is_leave = 0
<if test="params.office_code != null and params.office_code != ''">
AND u.office_id IN (
SELECT so.id FROM sys_office so
WHERE so.parent_ids LIKE CONCAT('%', #{params.office_code}, '%')
OR so.code = #{params.office_code}
)
</if>
<if test="params.permission != null and params.permission != ''">
AND EXISTS (
SELECT 1 FROM jl_key_dm_user_qx qx
WHERE qx.catgory_id = c.id
AND qx.permission_mark = #{params.permission}
AND qx.is_used = 1
)
</if>
<if test="params.name != null and params.name != ''">
AND u.name LIKE CONCAT('%', #{params.name}, '%')
</if>
</where>
GROUP BY u.id, u.name, u.gh, u.email, u.phone, u.mobile, o.name
ORDER BY u.name ASC
</select>
<!-- 人员多选器列表查询(所有在职人员) -->
<select id="selectUserMultiSelectorList" parameterType="page" resultType="map">
SELECT
u.id,
u.name,
u.gh,
u.email,
u.phone,
u.mobile,
u.office_id,
o.name AS office_name
FROM jl_key_dm_user u
LEFT JOIN sys_office o ON o.id = u.office_id
<where>
AND u.is_used = 1
AND IFNULL(u.is_leave, 0) = 0
<if test="params.name != null and params.name != ''">
AND u.name LIKE CONCAT('%', #{params.name}, '%')
</if>
<if test="params.orgId != null and params.orgId != ''">
AND (o.office_id = #{params.orgId} or o.parent_id = #{params.orgId})
</if>
<if test="params.pcode != null and params.pcode != ''">
AND NOT EXISTS (SELECT id from jl_key_dm_permission_user where u.id=user_id is null and permission_code=#{params.params.pcode})
</if>
</where>
ORDER BY o.grade, o.sort
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论