优化工作日志查看权限
- 移除了基于角色ID列表的动态查询,改为固定排除特定角色ID(1, 101, 162) -简化了查询参数,移除了不再使用的角色ID集合 - 增加了异常捕获和日志记录,以提高系统稳定性 - 注释了原来的动态查询逻辑,以便未来可能的恢复或调整
This commit is contained in:
parent
e204668d09
commit
0e303652fa
@ -98,7 +98,7 @@ public interface LogInstanceMapper extends BaseMapperX<LogInstanceDO> {
|
|||||||
@Param("userId") Long userId);
|
@Param("userId") Long userId);
|
||||||
|
|
||||||
@DataPermission(enable = false)
|
@DataPermission(enable = false)
|
||||||
List<LogReadUserRespDTO> selectRaedUser(@Param("userId")Long userId, @Param("deptId")Long deptId, @Param("roleIds")Collection<Long> roleIds);
|
List<LogReadUserRespDTO> selectRaedUser(@Param("userId")Long userId, @Param("deptId")Long deptId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取上一篇下一篇
|
* 获取上一篇下一篇
|
||||||
|
@ -24,6 +24,7 @@ import cn.iocoder.yudao.module.system.service.worklog.dto.LogReadUserRespDTO;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.mapstruct.ap.internal.util.Strings;
|
import org.mapstruct.ap.internal.util.Strings;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -48,6 +49,7 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
|
@Slf4j
|
||||||
public class LogInstanceServiceImpl implements LogInstanceService {
|
public class LogInstanceServiceImpl implements LogInstanceService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -137,23 +139,29 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
|||||||
//创建日志时,查询可以查看发起人日志的用户组 用线程控制
|
//创建日志时,查询可以查看发起人日志的用户组 用线程控制
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
||||||
List<Long> roleIds = Arrays.asList(1L,101L);
|
try {
|
||||||
String roleId = configApi.getConfigKey("system_work_log_role_id").getCheckedData();
|
// List<Long> roleIds = Arrays.asList(1L,101L);
|
||||||
if (Strings.isNotEmpty(roleId)) {
|
// String roleId = configApi.getConfigKey("system_work_log_role_id").getCheckedData();
|
||||||
roleIds = Arrays.stream(roleId.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
//
|
||||||
}
|
// if (Strings.isNotEmpty(roleId)) {
|
||||||
List<LogReadUserRespDTO> respDTOS = logInstanceMapper.selectRaedUser(userId, adminUserDO.getDeptId(), roleIds);
|
// roleIds = Arrays.stream(roleId.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
||||||
|
// }
|
||||||
|
List<LogReadUserRespDTO> respDTOS = logInstanceMapper.selectRaedUser(userId, adminUserDO.getDeptId());
|
||||||
|
|
||||||
//特殊情况, 日志发起人为研发部时 手动添加查看者
|
//特殊情况, 日志发起人为研发部时 手动添加查看者
|
||||||
if (adminUserDO.getDeptId() == 128L && adminUserDO.getId() != 126L) {
|
if (adminUserDO.getDeptId() == 128L && adminUserDO.getId() != 126L) {
|
||||||
|
|
||||||
LogReadUserRespDTO dto = new LogReadUserRespDTO();
|
LogReadUserRespDTO dto = new LogReadUserRespDTO();
|
||||||
dto.setUserId(126L);
|
dto.setUserId(126L);
|
||||||
dto.setDeptId(128L);
|
dto.setDeptId(128L);
|
||||||
respDTOS.add(dto);
|
respDTOS.add(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
logReadService.createLogRule(respDTOS, logInstance.getId(), logInstance.getStartUserId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取日志查看用户失败", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
logReadService.createLogRule(respDTOS, logInstance.getId(), logInstance.getStartUserId());
|
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
|
@ -71,12 +71,13 @@
|
|||||||
WHERE
|
WHERE
|
||||||
role.permission = 'system:view-log:query'
|
role.permission = 'system:view-log:query'
|
||||||
AND a.deleted = 0
|
AND a.deleted = 0
|
||||||
<if test="roleIds != null and roleIds.size() > 0">
|
AND a.role_id NOT IN (1,101,162)
|
||||||
AND a.role_id NOT IN
|
<!-- <if test="roleIds != null and roleIds.size() > 0">-->
|
||||||
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
|
<!-- AND a.role_id NOT IN-->
|
||||||
#{roleId}
|
<!-- <foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">-->
|
||||||
</foreach>
|
<!-- #{roleId}-->
|
||||||
</if>
|
<!-- </foreach>-->
|
||||||
|
<!-- </if>-->
|
||||||
) menu
|
) menu
|
||||||
LEFT JOIN system_role role on role.id = menu.role_id
|
LEFT JOIN system_role role on role.id = menu.role_id
|
||||||
) role_id ON u_role.role_id = role_id.id
|
) role_id ON u_role.role_id = role_id.id
|
||||||
|
Loading…
Reference in New Issue
Block a user