commit message:```
实现系统日志模块的日志查询和配置调整 对系统日志模块的日志查询功能进行了优化,通过动态SQL查询条件实现更灵活的数据权限管理。同时,通过调用配置API,实现了对日志查询角色配置的可配置化,增强了系统的灵活性和可维护性。 ```
This commit is contained in:
parent
ef83474112
commit
c3ec095212
@ -2,14 +2,12 @@ package cn.iocoder.yudao.module.infra.api.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
||||
import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.infra.service.config.ConfigService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@ -26,9 +24,7 @@ public class ConfigApiImpl implements ConfigApi{
|
||||
if (config == null) {
|
||||
return success(null);
|
||||
}
|
||||
if (!config.getVisible()) {
|
||||
throw exception(ErrorCodeConstants.CONFIG_GET_VALUE_ERROR_IF_VISIBLE);
|
||||
}
|
||||
|
||||
return success(config.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -97,7 +98,7 @@ public interface LogInstanceMapper extends BaseMapperX<LogInstanceDO> {
|
||||
@Param("userId") Long userId);
|
||||
|
||||
@DataPermission(enable = false)
|
||||
List<LogReadUserRespDTO> selectRaedUser(@Param("userId")Long userId, @Param("deptId")Long deptId);
|
||||
List<LogReadUserRespDTO> selectRaedUser(@Param("userId")Long userId, @Param("deptId")Long deptId, @Param("roleIds")Collection<Long> roleIds);
|
||||
|
||||
/**
|
||||
* 获取上一篇下一篇
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.framework.rpc.config;
|
||||
import cn.iocoder.yudao.module.bpm.api.model.BpmModelApi;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAEntryApi;
|
||||
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAGoOutApi;
|
||||
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||
import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.factoryInfo.FactoryInfoApi;
|
||||
@ -10,6 +11,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, FactoryInfoApi.class, BpmModelApi.class, BpmOAGoOutApi.class, BpmOAEntryApi.class})
|
||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, FactoryInfoApi.class, BpmModelApi.class, BpmOAGoOutApi.class, BpmOAEntryApi.class, ConfigApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceNextOrUpVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstancePageReqVO;
|
||||
@ -23,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.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.mapstruct.ap.internal.util.Strings;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -73,6 +75,9 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
||||
@Lazy
|
||||
private LogStatisticsService logStatisticsService;
|
||||
|
||||
@Resource
|
||||
private ConfigApi configApi;
|
||||
|
||||
|
||||
@Override
|
||||
public Long createLogInstance(LogInstanceSaveReqVO createReqVO) {
|
||||
@ -132,7 +137,12 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
||||
//创建日志时,查询可以查看发起人日志的用户组 用线程控制
|
||||
new Thread(() -> {
|
||||
|
||||
List<LogReadUserRespDTO> respDTOS = logInstanceMapper.selectRaedUser(userId, adminUserDO.getDeptId());
|
||||
List<Long> roleIds = Arrays.asList(1L,101L);
|
||||
String roleId = configApi.getConfigKey("system_work_log_role_id").getCheckedData();
|
||||
if (Strings.isNotEmpty(roleId)) {
|
||||
roleIds = Arrays.stream(roleId.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
||||
}
|
||||
List<LogReadUserRespDTO> respDTOS = logInstanceMapper.selectRaedUser(userId, adminUserDO.getDeptId(), roleIds);
|
||||
|
||||
//特殊情况, 日志发起人为研发部时 手动添加查看者
|
||||
if (adminUserDO.getDeptId() == 128L && adminUserDO.getId() != 126L) {
|
||||
|
@ -70,9 +70,13 @@
|
||||
LEFT JOIN system_menu role ON a.menu_id = role.id
|
||||
WHERE
|
||||
role.permission = 'system:view-log:query'
|
||||
AND a.role_id != 1
|
||||
AND a.role_id != 101
|
||||
AND a.deleted = 0
|
||||
<if test="roleIds != null and roleIds.size() > 0">
|
||||
AND a.role_id NOT IN
|
||||
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</if>
|
||||
) menu
|
||||
LEFT JOIN system_role role on role.id = menu.role_id
|
||||
) role_id ON u_role.role_id = role_id.id
|
||||
|
Loading…
Reference in New Issue
Block a user