diff --git a/src/main/java/club/joylink/rtss/controller/publish/ExamController.java b/src/main/java/club/joylink/rtss/controller/publish/ExamController.java index 8d3adffce..d6d54c99f 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/ExamController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/ExamController.java @@ -64,8 +64,8 @@ public class ExamController { *查询试题列表信息 */ @GetMapping(path = "/list") - public PageVO queryExamInfoList(ExamDefinitionQueryVO queryVO) { - return iExamService.queryExamInfoList(queryVO); + public PageVO queryExamInfoList(ExamDefinitionQueryVO queryVO, @RequestAttribute LoginUserInfoVO loginInfo) { + return iExamService.queryExamInfoList(queryVO, loginInfo); } /** diff --git a/src/main/java/club/joylink/rtss/controller/publish/LessonController.java b/src/main/java/club/joylink/rtss/controller/publish/LessonController.java index 2cfee9f12..a15964501 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/LessonController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/LessonController.java @@ -56,8 +56,8 @@ public class LessonController { * 根据条件获取课程列表 */ @GetMapping(path = "") - public List queryLessons(LessonQueryVO lessonQueryVO) { - return this.iLessonService.queryValidLessons(lessonQueryVO); + public List queryLessons(LessonQueryVO lessonQueryVO, @RequestAttribute LoginUserInfoVO loginInfo) { + return this.iLessonService.queryValidLessons(lessonQueryVO, loginInfo); } /** diff --git a/src/main/java/club/joylink/rtss/services/ExamService.java b/src/main/java/club/joylink/rtss/services/ExamService.java index e1ce53431..e2c78d405 100644 --- a/src/main/java/club/joylink/rtss/services/ExamService.java +++ b/src/main/java/club/joylink/rtss/services/ExamService.java @@ -234,14 +234,16 @@ public class ExamService implements IExamService { * 查询试题列表信息 */ @Override - public PageVO queryExamInfoList(ExamDefinitionQueryVO queryVO) { + public PageVO queryExamInfoList(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo) { //查询试题列表 ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample(); - ExamDefinitionExample.Criteria criteria = examDefinitionExample.createCriteria(); examDefinitionExample.setOrderByClause(" create_time DESC "); + ExamDefinitionExample.Criteria criteria = examDefinitionExample.createCriteria(); + ExamDefinitionExample.Criteria orCriteria = examDefinitionExample.createCriteria(); //根据课程ID查询考试 if (Objects.nonNull(queryVO.getLessonId())) { criteria.andLessonIdEqualTo(queryVO.getLessonId()); + orCriteria.andLessonIdEqualTo(queryVO.getLessonId()); } else if (Objects.nonNull(queryVO.getMapId())) { // 地图id查询 List lessonList = this.iLessonService.queryValidLessonsOfMap(queryVO.getMapId()); @@ -250,6 +252,7 @@ public class ExamService implements IExamService { .map(LessonVO::getId) .collect(Collectors.toList()); criteria.andLessonIdIn(lessonIdList); + orCriteria.andLessonIdIn(lessonIdList); } else { // 返回null return new PageVO<>(); @@ -257,10 +260,12 @@ public class ExamService implements IExamService { } if (StringUtils.hasText(queryVO.getStatus())) { criteria.andStatusEqualTo(queryVO.getStatus()); + orCriteria.andStatusEqualTo(queryVO.getStatus()); } //根据考试名称模糊匹配 if (StringUtils.hasText(queryVO.getName())) { criteria.andNameLike(String.format("%%%s%%", queryVO.getName())); + orCriteria.andNameLike(String.format("%%%s%%", queryVO.getName())); } //根据创建人名称模糊匹配 if (StringUtils.hasText(queryVO.getCreatorName())) { @@ -273,7 +278,16 @@ public class ExamService implements IExamService { creatorIdList.add(null); } criteria.andCreatorIdIn(creatorIdList); + orCriteria.andCreatorIdIn(creatorIdList); } + //公开数据和组织内数据 + criteria.andOrgIdIsNull(); + Org topOrg = iOrgService.findTopOrgOfUser(loginInfo.getAccountVO().getId()); + if (topOrg != null) { + orCriteria.andOrgIdEqualTo(topOrg.getId()); + examDefinitionExample.or(orCriteria); + } + PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); Page examDefinitionList = (Page) examDefinitionDAO.selectByExample(examDefinitionExample); diff --git a/src/main/java/club/joylink/rtss/services/IExamService.java b/src/main/java/club/joylink/rtss/services/IExamService.java index 00238fa42..5df984875 100644 --- a/src/main/java/club/joylink/rtss/services/IExamService.java +++ b/src/main/java/club/joylink/rtss/services/IExamService.java @@ -41,7 +41,7 @@ public interface IExamService { /** * 查询试题列表信息 */ - PageVO queryExamInfoList(ExamDefinitionQueryVO queryVO); + PageVO queryExamInfoList(ExamDefinitionQueryVO queryVO, LoginUserInfoVO loginInfo); /** * 删除指定ID的考试信息 diff --git a/src/main/java/club/joylink/rtss/services/ILessonService.java b/src/main/java/club/joylink/rtss/services/ILessonService.java index ded7af8f0..2468f02cb 100644 --- a/src/main/java/club/joylink/rtss/services/ILessonService.java +++ b/src/main/java/club/joylink/rtss/services/ILessonService.java @@ -1,6 +1,5 @@ package club.joylink.rtss.services; -import club.joylink.rtss.constants.Project; import club.joylink.rtss.entity.LsLesson; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.LoginUserInfoVO; @@ -50,7 +49,7 @@ public interface ILessonService { /** * 查询有效的课程列表 */ - List queryValidLessons(LessonQueryVO lessonQueryVO); + List queryValidLessons(LessonQueryVO lessonQueryVO, LoginUserInfoVO loginInfo); /** * 查询课程列表(无视状态) diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index 256632b95..01bb0c947 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -253,15 +253,27 @@ public class LessonService implements ILessonService { return new LessonVO(lessonList.get(0)); } + /** + * 查询有效的、公开的、属于自己组织的数据 + */ @Override - public List queryValidLessons(LessonQueryVO lessonQueryVO) { + public List queryValidLessons(LessonQueryVO lessonQueryVO, LoginUserInfoVO loginInfo) { LsLessonExample example = new LsLessonExample(); example.setOrderByClause("id desc"); Criteria criteria = example.createCriteria() - .andStatusEqualTo(MapStatus.Online.getCode()); + .andStatusEqualTo(MapStatus.Online.getCode()) + .andOrgIdIsNull(); if (Objects.nonNull(lessonQueryVO.getMapId())) { criteria.andMapIdEqualTo(lessonQueryVO.getMapId()); } + Org topOrg = iOrgService.findTopOrgOfUser(loginInfo.getAccountVO().getId()); + if (topOrg != null) { + Criteria orCriteria = example.or().andStatusEqualTo(MapStatus.Online.getCode()) + .andOrgIdEqualTo(topOrg.getId()); + if (Objects.nonNull(lessonQueryVO.getMapId())) { + orCriteria.andMapIdEqualTo(lessonQueryVO.getMapId()); + } + } List list = this.lessonDAO.selectByExample(example); return LessonVO.convert(list); }