Przeglądaj źródła

2024/1/5 预警记录添加权限过滤查询

chaiyunlong 2 lat temu
rodzic
commit
9e1bb340d4

+ 20 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/WarningNoticeLogController.java

@@ -9,10 +9,12 @@ import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.web.controller.AbstractController;
 import com.zd.laboratory.api.dto.WarningNoticeLogDto;
+import com.zd.laboratory.domain.LabSubject;
 import com.zd.laboratory.domain.WarningNoticeLog;
 import com.zd.laboratory.domain.dto.QueryAppWarningLogParam;
 import com.zd.laboratory.domain.dto.QueryWarningLogParam;
 import com.zd.laboratory.domain.vo.WarningNoticeLogVO;
+import com.zd.laboratory.mapper.LabSubjectMapper;
 import com.zd.laboratory.service.WarningNoticeLogService;
 import com.zd.model.domain.ResultData;
 import io.swagger.annotations.ApiOperation;
@@ -47,6 +49,9 @@ public class WarningNoticeLogController extends AbstractController {
     @Autowired
     private TokenService tokenService;
 
+    @Autowired
+    private LabSubjectMapper labSubjectMapper;
+
     @PostMapping("/add")
     @ApiOperation("新增报警记录日志")
     public ResultData add(@RequestBody WarningNoticeLogDto warningNoticeLogDto){
@@ -128,9 +133,24 @@ public class WarningNoticeLogController extends AbstractController {
     @PostMapping("/appList")
     @ApiOperation("小程序查询预警通知列表")
     public ResultData appList(@RequestBody QueryAppWarningLogParam queryAppWarningLogParam){
+        //查询登录人管理的实验室列表
+        LabSubject labSubject = new LabSubject();
+        if(!tokenService.getLoginUser().getUsername().equals("admin")){
+            labSubject.setLoginUserId(tokenService.getLoginUser().getUserid());
+        }
+        List<LabSubject> labSubjectList = labSubjectMapper.selectLabSubjectList(labSubject);
+        List<Long> subIds = Optional.ofNullable(labSubjectList).orElseGet(Collections::emptyList)
+                .stream()
+                .map(a->a.getId())
+                .collect(Collectors.toList());
+        if(subIds.size()==0){
+            subIds.add(-99L);
+        }
+
         Page<WarningNoticeLogVO> VOPage = new Page<>();
         LambdaQueryWrapper<WarningNoticeLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
         lambdaQueryWrapper.eq(WarningNoticeLog::getIsDeleted,Boolean.FALSE);
+        lambdaQueryWrapper.in(WarningNoticeLog::getSubId,subIds);
         if(Objects.nonNull(queryAppWarningLogParam.getCollegeId())){
             lambdaQueryWrapper.eq(WarningNoticeLog::getCollegeId,queryAppWarningLogParam.getCollegeId());
         }

+ 3 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml

@@ -320,6 +320,9 @@
             <if test="adminId != null ">and admin_id = #{adminId}</if>
             <if test="isDel != null ">and is_del = #{isDel}</if>
             <if test="userId != null ">and user_id = #{userId}</if>
+            <if test="loginUserId != null ">
+                (`admin_id` = #{loginUserId} or find_in_set(#{loginUserId},`safe_user_id`))
+            </if>
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>