wangliang 5 жил өмнө
parent
commit
e706ff559f

+ 45 - 0
themis-backend/src/main/java/com/qmth/themis/backend/api/TBUserController.java

@@ -2,12 +2,16 @@ package com.qmth.themis.backend.api;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.backend.config.DictionaryConfig;
 import com.qmth.themis.backend.util.ServletUtil;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dao.TEExamActivityMapper;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TBUser;
+import com.qmth.themis.business.entity.TEExamActivity;
 import com.qmth.themis.business.enums.MqEnum;
 import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.enums.SystemOperationEnum;
@@ -31,6 +35,7 @@ import io.swagger.annotations.*;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -132,9 +137,49 @@ public class TBUserController {
         return ResultUtil.ok(map);
     }
 
+    @Resource
+    TEExamActivityMapper teExamActivityService;
+
+    @Value("${db.name}")
+    String dbName;
+
     @ApiOperation(value = "用户查询接口")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     public Result list() {
+        String tableName = "t_e_exam_activity_test1";
+        Integer count = teExamActivityService.existTable(tableName, dbName);
+        log.info("count:{}", count);
+        if (count == 0) {
+            teExamActivityService.createNewTable(tableName);
+            TEExamActivity teExamActivity = new TEExamActivity();
+            teExamActivity.setId(Constants.idGen.next());
+            teExamActivity.setExamId(123L);
+            teExamActivity.setCode("123");
+            teExamActivity.setName("123");
+            teExamActivity.setPrepareSeconds(30);
+            teExamActivity.setMinStartTime(new Date());
+            teExamActivity.setMaxStartTime(new Date());
+            teExamActivity.setMaxDurationSeconds(30);
+            teExamActivity.setMinDurationSeconds(30);
+            teExamActivity.setMaxFinishTime(new Date());
+            teExamActivity.setExamCount(1);
+            teExamActivity.setBreakExpireSeconds(1);
+            teExamActivity.setBreakResumeCount(1);
+            teExamActivity.setEntryFaceVerify(1);
+            teExamActivity.setEntryLivenessVerify(1);
+            teExamActivity.setConstantFaceVerify(1);
+            teExamActivity.setConstantLivenessVerifyCount(1);
+            teExamActivity.setClientVideoPush(1);
+            teExamActivity.setClientVideoRecord(1);
+            teExamActivity.setWxappPhotoUpload(1);
+            teExamActivity.setWxappVideoPush(1);
+            teExamActivity.setWxappVideoRecord(1);
+            teExamActivity.setCameraPhotoUpload(1);
+            teExamActivityService.insertInfo(tableName, teExamActivity);
+        }
+        IPage<Map> map = teExamActivityService.selectListPage(new Page<>(0, 10), tableName);
+        log.info("map:{}", JSONObject.toJSONString(map));
+//        teExamActivityService.dropTable(tableName);
         return ResultUtil.ok(SystemConstant.SUCCESS);
     }
 

+ 43 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamActivityMapper.java

@@ -1,8 +1,12 @@
 package com.qmth.themis.business.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.entity.TEExamActivity;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Map;
 
 /**
  * @Description: 考试场次 Mapper 接口
@@ -14,4 +18,43 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface TEExamActivityMapper extends BaseMapper<TEExamActivity> {
 
+    /**
+     * 表是否存在
+     *
+     * @param tableName
+     * @param schema
+     * @return
+     */
+    public Integer existTable(@Param("tableName") String tableName, @Param("schema") String schema);
+
+    /**
+     * 删除表
+     *
+     * @param tableName
+     */
+    public void dropTable(@Param("tableName") String tableName);
+
+    /**
+     * 创建表
+     *
+     * @param tableName
+     */
+    public void createNewTable(@Param("tableName") String tableName);
+
+    /**
+     * 新插数据
+     *
+     * @param tableName
+     * @param teExamActivity
+     */
+    public void insertInfo(@Param("tableName") String tableName, @Param("TEExamActivity") TEExamActivity teExamActivity);
+
+    /**
+     * 查询所有数据
+     *
+     * @param iPage
+     * @param tableName
+     * @return
+     */
+    public IPage<Map> selectListPage(IPage<Map> iPage, @Param("tableName") String tableName);
 }

+ 42 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamActivityService.java

@@ -1,8 +1,11 @@
 package com.qmth.themis.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TEExamActivity;
 
+import java.util.Map;
+
 /**
  * @Description: 考试场次 服务类
  * @Param:
@@ -12,4 +15,43 @@ import com.qmth.themis.business.entity.TEExamActivity;
  */
 public interface TEExamActivityService extends IService<TEExamActivity> {
 
+    /**
+     * 表是否存在
+     *
+     * @param tableName
+     * @param schema
+     * @return
+     */
+    public Integer existTable(String tableName, String schema);
+
+    /**
+     * 删除表
+     *
+     * @param tableName
+     */
+    public void dropTable(String tableName);
+
+    /**
+     * 创建表
+     *
+     * @param tableName
+     */
+    public void createNewTable(String tableName);
+
+    /**
+     * 新插数据
+     *
+     * @param tableName
+     * @param teExamActivity
+     */
+    public void insertInfo(String tableName, TEExamActivity teExamActivity);
+
+    /**
+     * 查询所有数据
+     *
+     * @param iPage
+     * @param tableName
+     * @return
+     */
+    public IPage<Map> selectListPage(IPage<Map> iPage, String tableName);
 }

+ 61 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -1,11 +1,15 @@
 package com.qmth.themis.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.dao.TEExamActivityMapper;
 import com.qmth.themis.business.entity.TEExamActivity;
 import com.qmth.themis.business.service.TEExamActivityService;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.Map;
+
 /**
  * @Description: 考试场次 服务实现类
  * @Param:
@@ -16,4 +20,61 @@ import org.springframework.stereotype.Service;
 @Service
 public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper, TEExamActivity> implements TEExamActivityService {
 
+    @Resource
+    TEExamActivityMapper teExamActivityMapper;
+
+    /**
+     * 表是否存在
+     *
+     * @param tableName
+     * @param schema
+     * @return
+     */
+    @Override
+    public Integer existTable(String tableName, String schema) {
+        return teExamActivityMapper.existTable(tableName, schema);
+    }
+
+    /**
+     * 删除表
+     *
+     * @param tableName
+     */
+    @Override
+    public void dropTable(String tableName) {
+        teExamActivityMapper.dropTable(tableName);
+    }
+
+    /**
+     * 创建表
+     *
+     * @param tableName
+     */
+    @Override
+    public void createNewTable(String tableName) {
+        teExamActivityMapper.createNewTable(tableName);
+    }
+
+    /**
+     * 新插数据
+     *
+     * @param tableName
+     * @param teExamActivity
+     */
+    @Override
+    public void insertInfo(String tableName, TEExamActivity teExamActivity) {
+        teExamActivityMapper.insertInfo(tableName, teExamActivity);
+    }
+
+    /**
+     * 查询所有数据
+     *
+     * @param iPage
+     * @param tableName
+     * @return
+     */
+    @Override
+    public IPage<Map> selectListPage(IPage<Map> iPage, String tableName) {
+        return teExamActivityMapper.selectListPage(iPage, tableName);
+    }
 }

+ 76 - 0
themis-business/src/main/resources/mapper/TEExamActivityMapper.xml

@@ -2,4 +2,80 @@
 <!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.TEExamActivityMapper">
 
+    <select id="existTable" resultType="java.lang.Integer">
+        select
+            count(*)
+        from
+            information_schema.TABLES
+        where
+            LCASE(TABLE_NAME)= #{tableName}
+        and TABLE_SCHEMA = #{schema};
+    </select>
+
+    <update id="dropTable">
+        DROP TABLE IF EXISTS ${tableName}
+    </update>
+
+    <update id="createNewTable">
+        CREATE TABLE ${tableName} (
+          `id` bigint NOT NULL COMMENT '主键',
+          `exam_id` bigint NOT NULL COMMENT '批次id',
+          `code` varchar(50) NOT NULL COMMENT '场次代码',
+          `name` varchar(100) NOT NULL COMMENT '场次名称',
+          `prepare_seconds` int NOT NULL COMMENT '提前多长时间开始候考(秒)',
+          `min_start_time` datetime NOT NULL COMMENT '最早开考时间',
+          `max_start_time` datetime NOT NULL COMMENT '最晚开考时间,相当于迟到时间',
+          `max_duration_seconds` int DEFAULT NULL COMMENT '最大考试时长',
+          `min_duration_seconds` int DEFAULT NULL COMMENT '最短考试时间,相当于考试冻结时间(秒)',
+          `max_finish_time` datetime DEFAULT NULL COMMENT '集中收卷时间',
+          `exam_count` int DEFAULT NULL COMMENT '允许考试次数',
+          `break_expire_seconds` int DEFAULT NULL COMMENT '断点失效时间(秒)',
+          `break_resume_count` int DEFAULT NULL COMMENT '断点续考次数',
+          `entry_face_verify` tinyint DEFAULT NULL COMMENT '是否开启/强制开考人脸识别',
+          `entry_liveness_verify` tinyint DEFAULT NULL COMMENT '是否开启/强制开考活体检测',
+          `constant_face_verify` tinyint DEFAULT NULL COMMENT '考试过程中人脸检测是否开启',
+          `constant_liveness_verify_count` int DEFAULT NULL COMMENT '考试过程中随机活体验证次数',
+          `client_video_push` tinyint DEFAULT NULL COMMENT '是否开启/强制客户端视频监控',
+          `client_video_record` tinyint DEFAULT NULL COMMENT '是否开启客户端视频转录',
+          `wxapp_video_push` tinyint DEFAULT NULL COMMENT '是否开启/强制微信小程序监控',
+          `wxapp_video_record` tinyint DEFAULT NULL COMMENT '是否开启微信小程序视频转录',
+          `camera_photo_upload` tinyint DEFAULT NULL COMMENT '是否允许使用摄像头拍照答题',
+          `wxapp_photo_upload` tinyint DEFAULT NULL COMMENT '是否允许使用微信拍照答题',
+          PRIMARY KEY (`id`),
+          UNIQUE KEY `${tableName}_code_Idx` (`code`)
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='考试场次'
+    </update>
+
+    <insert id="insertInfo" parameterType="com.qmth.themis.business.entity.TEExamActivity">
+        INSERT INTO ${tableName}
+            (id, exam_id, code, name, prepare_seconds, min_start_time, max_start_time, max_duration_seconds, min_duration_seconds, max_finish_time, exam_count, break_expire_seconds, break_resume_count, entry_face_verify, entry_liveness_verify, constant_face_verify, constant_liveness_verify_count, client_video_push, client_video_record, wxapp_video_push, wxapp_video_record, camera_photo_upload, wxapp_photo_upload)
+            VALUES(
+            #{TEExamActivity.id},
+            #{TEExamActivity.examId},
+            #{TEExamActivity.code},
+            #{TEExamActivity.name},
+            #{TEExamActivity.prepareSeconds},
+            #{TEExamActivity.minStartTime},
+            #{TEExamActivity.maxStartTime},
+            #{TEExamActivity.maxDurationSeconds},
+            #{TEExamActivity.minDurationSeconds},
+            #{TEExamActivity.maxFinishTime},
+            #{TEExamActivity.examCount},
+            #{TEExamActivity.breakExpireSeconds},
+            #{TEExamActivity.breakResumeCount},
+            #{TEExamActivity.entryFaceVerify},
+            #{TEExamActivity.entryLivenessVerify},
+            #{TEExamActivity.constantFaceVerify},
+            #{TEExamActivity.constantLivenessVerifyCount},
+            #{TEExamActivity.clientVideoPush},
+            #{TEExamActivity.clientVideoRecord},
+            #{TEExamActivity.wxappVideoPush},
+            #{TEExamActivity.wxappVideoRecord},
+            #{TEExamActivity.cameraPhotoUpload},
+            #{TEExamActivity.wxappPhotoUpload});
+    </insert>
+
+    <select id="selectListPage" resultType="java.util.Map">
+        select * from ${tableName}
+    </select>
 </mapper>