Browse Source

监考端接口

wangliang 4 năm trước cách đây
mục cha
commit
11731ffac2

+ 18 - 3
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java

@@ -205,9 +205,9 @@ public class TEExamController {
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
     @Transactional
     public Result examToggle(@ApiJsonObject(name = "examToggle", value = {
-                    @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考试批次ID"),
-                    @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")
-            }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+            @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考试批次ID"),
+            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")
+    }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
         if (Objects.isNull(mapParameter.get("id")) || Objects.equals(mapParameter.get("id"), "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
@@ -307,4 +307,19 @@ public class TEExamController {
         }
         return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
     }
+
+    @ApiOperation(value = "监考端获取考试批次接口")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
+    public Result list(@ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber, @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+        if (Objects.isNull(tbUser)) {
+            throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
+        }
+        IPage<TEExamQueryDto> teExamQueryDtoIPage = teExamService.examList(new Page<>(pageNumber, pageSize), tbUser.getOrgId());
+        BasePage basePage = new BasePage(teExamQueryDtoIPage.getRecords(), teExamQueryDtoIPage.getCurrent(), teExamQueryDtoIPage.getSize(), teExamQueryDtoIPage.getTotal());
+        Map map = new HashMap<>();
+        map.put(SystemConstant.RECORDS, basePage);
+        return ResultUtil.ok(map);
+    }
 }

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamMapper.java

@@ -50,4 +50,13 @@ public interface TEExamMapper extends BaseMapper<TEExam> {
 //     * @return
 //     */
 //    public List<Map> getWaitingExamForJob();
+
+    /**
+     * 监考端获取考试批次列表
+     *
+     * @param iPage
+     * @param orgId
+     * @return
+     */
+    public IPage<TEExamQueryDto> examList(IPage<Map> iPage, @Param("orgId") Long orgId);
 }

+ 9 - 1
themis-business/src/main/java/com/qmth/themis/business/service/TEExamService.java

@@ -7,6 +7,7 @@ import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.dto.response.TEExamDto;
 import com.qmth.themis.business.dto.response.TEExamQueryDto;
 import com.qmth.themis.business.entity.TEExam;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
@@ -164,5 +165,12 @@ public interface TEExamService extends IService<TEExam> {
      */
     public ExamResultBean result(Long recordId);
 
-
+    /**
+     * 监考端获取考试批次列表
+     *
+     * @param iPage
+     * @param orgId
+     * @return
+     */
+    public IPage<TEExamQueryDto> examList(IPage<Map> iPage, Long orgId);
 }

+ 12 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -855,6 +855,18 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         return ret;
     }
 
+    /**
+     * 监考端获取考试批次列表
+     *
+     * @param iPage
+     * @param orgId
+     * @return
+     */
+    @Override
+    public IPage<TEExamQueryDto> examList(IPage<Map> iPage, Long orgId) {
+        return teExamMapper.examList(iPage, orgId);
+    }
+
     /**
      * 缓存操作
      *

+ 23 - 0
themis-business/src/main/resources/mapper/TEExamMapper.xml

@@ -2,6 +2,29 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.themis.business.dao.TEExamMapper">
 
+    <select id="examList" resultType="com.qmth.themis.business.dto.response.TEExamQueryDto">
+        select
+        t.id,
+        t.code,
+        t.name,
+        t.tag,
+        t.mode,
+        t.enable,
+        t.start_time as startTime,
+        t.end_time as endTime,
+        t.progress
+        from
+        t_e_exam t
+        <where>
+            and t.start_time <![CDATA[ <= ]]> now()
+            and t.end_time <![CDATA[ >= ]]> now()
+            and t.enable = 1
+            <if test="orgId != null and orgId != ''">
+                and t.org_id = #{orgId}
+            </if>
+        </where>
+    </select>
+
     <select id="examQuery" resultType="com.qmth.themis.business.dto.response.TEExamQueryDto">
         select
         t.id,