| | |
| | | @RequestMapping(value = "/list", method = RequestMethod.GET) |
| | | public @ResponseBody Result pageList(String keyword,Short status, Integer pageSize,Integer pageNum){ |
| | | Result result = new Result(Boolean.TRUE); |
| | | //判断是否是教师 |
| | | String teacherId = ClientUtils.isAdmin() ? null : ClientUtils.getUserId(); |
| | | Pager pager = new Pager(); |
| | | List<Object> queryParamLst = null; |
| | | // 查询记录数 |
| | | String hqlCount="from ExamPaperInfo where createId=? and examPaperName like ? and deleteFlag is false"; |
| | | String hqlCount="from ExamPaperInfo where examPaperName like ? and deleteFlag is false"; |
| | | if(status!=null){ |
| | | hqlCount = hqlCount.concat(" and paperStatus = ?"); |
| | | queryParamLst = CollectionUtils.newList(ClientUtils.getUserId(),'%'+(keyword==null?"":keyword.trim())+'%',status); |
| | | queryParamLst = CollectionUtils.newList('%'+(keyword==null?"":keyword.trim())+'%',status); |
| | | }else{ |
| | | queryParamLst = CollectionUtils.newList(ClientUtils.getUserId(),'%'+(keyword==null?"":keyword.trim())+'%'); |
| | | queryParamLst = CollectionUtils.newList('%'+(keyword==null?"":keyword.trim())+'%'); |
| | | } |
| | | if (StringUtils.isNotBlank(teacherId)) { |
| | | hqlCount = hqlCount.concat(" and createId=?"); |
| | | queryParamLst.add(teacherId); |
| | | } |
| | | |
| | | int totalCount = commonDAO.findCount(hqlCount,queryParamLst); |
| | | |
| | | // page赋值 |
| | |
| | | pager.setPageNum (pageNum!=null&&pageNum>0?pageNum:DEFAULT_PAGE_NUM); |
| | | |
| | | StringBuffer hqlBuffer = new StringBuffer(500); |
| | | hqlBuffer.append("from ExamPaperInfo where createId=? and examPaperName like ? and deleteFlag is false "); |
| | | hqlBuffer.append("from ExamPaperInfo where examPaperName like ? and deleteFlag is false "); |
| | | if(status!=null){ |
| | | hqlBuffer.append(" and paperStatus = ? "); |
| | | } |
| | | if (StringUtils.isNotBlank(teacherId)) { |
| | | hqlBuffer.append(" and createId=?"); |
| | | } |
| | | hqlBuffer.append(" order by createTime DESC"); |
| | | |
| | | List<ExamPaperInfo> list = commonDAO.findList(hqlBuffer.toString(), pager,queryParamLst, ExamPaperInfo.class); |