| | |
| | | */ |
| | | @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); |
| | |
| | | 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){ |