派生自 projectDept/qhighschool

EricsHu
2023-11-26 bf13676673e9f0f090a68bd8cfbaefbf0d696d32
src/main/java/com/qxueyou/scc/exercise/action/ExerciseGroupController.java
@@ -62,18 +62,32 @@
    * 题库列表
    */
   @RequestMapping(value = "/list", method = RequestMethod.GET)
   public @ResponseBody Result pageList(String keyword,Short status, Integer pageSize, Integer pageNum) {
   public @ResponseBody Result pageList(String keyword,Short status, Integer pageSize, Integer pageNum,String typeStatus) {
      //判断是否是教师
//      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);
      }
      if (StringUtils.isNotBlank(typeStatus)) {
         hqlCount = hqlCount.concat("  and typeStatus=?");
         queryParam.add(typeStatus);
      }
      
      int totalCount = commonDAO.findCount(hqlCount,queryParam);
@@ -83,10 +97,17 @@
      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=?");
      }
      if (StringUtils.isNotBlank(typeStatus)) {
         hqlBuffer.append(" and g.typeStatus=?");
      }
      hqlBuffer.append(" order by g.createTime DESC");
      List<Object[]> list = commonDAO.findList(hqlBuffer.toString(), page,queryParam,Object[].class);
      if(list!=null&& list.size()>0){