| | |
| | | import io.swagger.annotations.Api; |
| | | |
| | | /** |
| | | * 练习题目控制 |
| | | * 练习题目控制 |
| | | * |
| | | * @author kevin |
| | | * @history 2018-03-11 create kevin |
| | | */ |
| | | |
| | | @Api(tags = "题库管理接口") |
| | | @Api(tags = "题库管理接口") |
| | | @Controller |
| | | @RequestMapping(value = "/exercise/group") |
| | | public class ExerciseGroupController { |
| | | |
| | | // 分页查询中,默认记录条数和页数 |
| | | // 分页查询中,默认记录条数和页数 |
| | | private static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE; |
| | | private static final int DEFAULT_PAGE_NUM = 1; |
| | | |
| | |
| | | ISubjectService subjectService; |
| | | |
| | | /** |
| | | * 题库列表 |
| | | * 题库列表 |
| | | */ |
| | | @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赋值 |
| | | // page赋值 |
| | | page.setTotalCount(totalCount); |
| | | page.setPageSize(pageSize != null && pageSize > 0 ? pageSize : DEFAULT_PAGE_SIZE); |
| | | 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){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 详情页面数据 |
| | | * 详情页面数据 |
| | | * |
| | | * @param exerciseGroupId |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 保存题库基本信息 |
| | | * 保存题库基本信息 |
| | | * |
| | | * @param exerciseGroup |
| | | * @return |
| | |
| | | public @ResponseBody Result save(@RequestBody ExerciseGroup exerciseGroup) { |
| | | Result result = null; |
| | | String exerciseGroupId = exerciseGroup.getGroupId(); |
| | | // 暂时题库类型配置为题库类型 |
| | | // 暂时题库类型配置为题库类型 |
| | | if(StringUtils.isEmpty(exerciseGroupId)){ |
| | | result = new Result(true); |
| | | exerciseGroup.setType(ExerciseGroup.TYPE_EXERCISE_GROUP_LIB); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | * 删除 |
| | | * |
| | | * @param exerciseGroupIds |
| | | * @return |
| | |
| | | |
| | | |
| | | /** |
| | | * 作业布置班级列表 |
| | | * 作业布置班级列表 |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/subject/list", method = RequestMethod.GET) |
| | | public @ResponseBody List<Map<String,Object>> subjectList(Integer subjectType) { |
| | | //判断是否是教师 |
| | | //判断是否是教师 |
| | | String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | |
| | | if(subjectType==null){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 作业布置班级列表 |
| | | * 作业布置班级列表 |
| | | * |
| | | * @param examId |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/class/list", method = RequestMethod.GET) |
| | | public @ResponseBody List<Map<String,Object>> classList(String subjectId) { |
| | | //判断是否是教师 |
| | | //判断是否是教师 |
| | | String teacherId = ClientUtils.isAdmin() ? null : teacherService.getTeacherIdByUserId(ClientUtils.getUserId()); |
| | | |
| | | return classService.queryAvailableClassIdAndName(teacherId,subjectId); |
| | | } |
| | | |
| | | /** |
| | | * 发布题库 |
| | | * 发布题库 |
| | | * |
| | | * @param exerciseIds |
| | | * @return |
| | |
| | | @RequestMapping(value = "/exerciselib/publish", method = RequestMethod.GET) |
| | | public @ResponseBody Result publishExerciseLib(String groupIds) { |
| | | if (StringUtils.isEmpty(groupIds)) { |
| | | return new Result(false, "参数错误"); |
| | | return new Result(false, "参数错误"); |
| | | } |
| | | return this.exerciseGroupService.doPublishExerciseLib(groupIds.split(",")); |
| | | } |
| | | |
| | | /** |
| | | * 撤回题库 |
| | | * 撤回题库 |
| | | * |
| | | * @param exerciseIds |
| | | * @return |
| | |
| | | @RequestMapping(value = "/exerciselib/revoke", method = RequestMethod.GET) |
| | | public @ResponseBody Result revokeExerciseLib(String groupIds) { |
| | | if (StringUtils.isEmpty(groupIds)) { |
| | | return new Result(false, "参数错误"); |
| | | return new Result(false, "参数错误"); |
| | | } |
| | | return this.exerciseGroupService.doRevokeExerciseLib(groupIds.split(",")); |
| | | } |
| | | |
| | | /** |
| | | * 题目统计 |
| | | * 题目统计 |
| | | * @param examPaperIds |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/item/statistics", method = RequestMethod.GET) |
| | | public @ResponseBody Result statisticsItem (String groupIds) { |
| | | if (StringUtils.isEmpty(groupIds)) { |
| | | return new Result(false, "参数错误"); |
| | | return new Result(false, "参数错误"); |
| | | } |
| | | |
| | | List<ExerciseGroup> lstGroupStatistics = this.exerciseGroupService.queryExerciseGroupItemsStatistic(groupIds.split(",")); |