From 0e62c15e4b010ffa2d5cff9474f3fd389e369338 Mon Sep 17 00:00:00 2001 From: EricsHu <hrr145632> Date: 星期五, 24 十一月 2023 14:31:46 +0800 Subject: [PATCH] 优化作业、考试、试卷、题库 --- src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java b/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java index 15fcc9a..2226669 100644 --- a/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java +++ b/src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java @@ -63,17 +63,27 @@ */ @RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody Result pageList(String keyword,Short status, Integer pageSize, Integer pageNum) { + //鍒ゆ柇鏄惁鏄暀甯� +// String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); + String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId(); + Result result = new Result(Boolean.TRUE); Pager page = new Pager(); List<ExerciseGroup> listResult = null; List<Object> queryParam = null; // 鏌ヨ璁板綍鏁� - String hqlCount = "from ExerciseGroup where createId=? and type=? and name like ? and deleteFlag is false "; + String hqlCount = "from ExerciseGroup where type=? and name like ? and deleteFlag is false "; + + if(status!=null){ hqlCount = hqlCount.concat(" and status = ?"); - queryParam = CollectionUtils.newList(ClientUtils.getUserId(), ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%',status); + queryParam = CollectionUtils.newList(ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%',status); }else{ - queryParam = CollectionUtils.newList(ClientUtils.getUserId(), ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%'); + queryParam = CollectionUtils.newList( ExerciseGroup.TYPE_EXERCISE_GROUP_LIB,'%'+(keyword==null?"":keyword.trim())+'%'); + } + if (StringUtils.isNotBlank(teacherId)) { + hqlCount = hqlCount.concat(" and createId=?"); + queryParam.add(teacherId); } int totalCount = commonDAO.findCount(hqlCount,queryParam); @@ -83,10 +93,14 @@ page.setPageNum(pageNum != null && pageNum > 0 ? pageNum : DEFAULT_PAGE_NUM); StringBuffer hqlBuffer = new StringBuffer(500); - hqlBuffer.append("select g,s.name from ExerciseGroup g,Subject s where g.subjectId=s.subjectId and g.createId=? and g.type=? and g.name like ? and g.deleteFlag is false "); + hqlBuffer.append("select g,s.name from ExerciseGroup g,Subject s where g.subjectId=s.subjectId and g.type=? and g.name like ? and g.deleteFlag is false "); if(status!=null){ hqlBuffer.append(" and g.status = ? "); } + if (StringUtils.isNotBlank(teacherId)) { + hqlBuffer.append(" and g.createId=?"); + } + hqlBuffer.append(" order by g.createTime DESC"); List<Object[]> list = commonDAO.findList(hqlBuffer.toString(), page,queryParam,Object[].class); if(list!=null&& list.size()>0){ -- Gitblit v1.8.0