派生自 projectDept/qhighschool

yn147
2023-11-24 26780c533f2c2af6b9216306f649c1bcede94e4a
src/main/java/com/qxueyou/scc/exam/action/ExamPaperController.java
@@ -33,11 +33,11 @@
 * @history 2018-03-11 create kevin
 * 
 */
@Api(tags="试卷管理接口")
@Api(tags="试卷管理接口")
@Controller
@RequestMapping(value = "/exam/paper")
public class ExamPaperController {
   //分页查询中,默认记录条数和页数
   //分页查询中,默认记录条数和页数
   private static final int DEFAULT_PAGE_SIZE=Integer.MAX_VALUE;
   private static final int DEFAULT_PAGE_NUM=1;
   
@@ -56,32 +56,42 @@
   
   
   /**
    * 试卷列表
    * 试卷列表
    * */
   @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赋值
        // page赋值
        pager.setTotalCount(totalCount);
        pager.setPageSize(pageSize!=null&&pageSize>0?pageSize:DEFAULT_PAGE_SIZE);
        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");
        
@@ -99,7 +109,7 @@
   }
   
   /**
    * 详情页面数据
    * 详情页面数据
    * @param examPaperId
    * @return
    */
@@ -111,7 +121,7 @@
   }
   
   /**
    * 保存
    * 保存
    * 
    * @param examInfo
    * @return
@@ -129,7 +139,7 @@
   }
   
   /**
    * 删除
    * 删除
    * @param examPaperIds
    * @return
    */
@@ -178,7 +188,7 @@
   
   
   /**
    * 发布试卷
    * 发布试卷
    * 
    * @param exerciseIds
    * @return
@@ -186,13 +196,13 @@
   @RequestMapping(value = "/publish", method = RequestMethod.GET)
   public @ResponseBody Result publishExamPaper(String examPaperIds) {
      if (StringUtils.isEmpty(examPaperIds)) {
         return new Result(false, "参数错误");
         return new Result(false, "参数错误");
      }
      return this.examPaperService.doPublishExamPaper(examPaperIds.split(","));
   }
   /**
    * 撤回试卷
    * 撤回试卷
    * 
    * @param exerciseIds
    * @return
@@ -200,7 +210,7 @@
   @RequestMapping(value = "/revoke", method = RequestMethod.GET)
   public @ResponseBody Result revokeExamPaper(String examPaperIds) {
      if (StringUtils.isEmpty(examPaperIds)) {
         return new Result(false, "参数错误");
         return new Result(false, "参数错误");
      }
      return this.examPaperService.doRevokeExamPaper(examPaperIds.split(","));
   }