wangliang il y a 5 ans
Parent
commit
4ebc2039aa

+ 8 - 2
themis-backend/src/main/java/com/qmth/themis/backend/api/TBOrgController.java

@@ -7,11 +7,11 @@ import com.qmth.themis.business.entity.TBOrg;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.service.TBOrgService;
 import com.qmth.themis.business.util.JacksonUtil;
+import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
-import org.springframework.cache.CacheManager;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -36,8 +36,11 @@ public class TBOrgController {
     @Resource
     TBOrgService tbOrgService;
 
+//    @Resource
+//    private CacheManager cacheManager;
+
     @Resource
-    private CacheManager cacheManager;
+    RedisUtil redisUtil;
 
     //    @CachePut(value = "org_cache", key = "'orgCacheQuery'")
 //    @Cacheable(value = "org_cache", key = "#p0")
@@ -74,6 +77,9 @@ public class TBOrgController {
             tbOrg.setId(Constants.idGen.next());
             tbOrg.setCreateId(tbUser.getId());
         } else {
+            if (Objects.nonNull(redisUtil.getOrg(tbOrg.getId()))) {
+                redisUtil.setOrg(tbOrg.getId(), tbOrg);
+            }
             tbOrg.setUpdateId(tbUser.getId());
         }
         tbOrgService.saveOrUpdate(tbOrg);

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

@@ -170,6 +170,7 @@ public class TBUserController {
             orgMap.put("logo", authDto.getTbOrg().getLogo());
             orgMap.put("enableVideoRecord", authDto.getTbOrg().getEnableVideoRecord());
             map.put(SystemConstant.ORG_INFO, orgMap);
+            redisUtil.setOrg(authDto.getTbOrg().getId(), authDto.getTbOrg());
         }
         return ResultUtil.ok(map);
     }

+ 30 - 1
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java

@@ -1,9 +1,24 @@
 package com.qmth.themis.backend.api;
 
-import io.swagger.annotations.Api;
+import com.qmth.themis.backend.util.ServletUtil;
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TBUser;
+import com.qmth.themis.business.entity.TEExam;
+import com.qmth.themis.business.service.TEExamService;
+import com.qmth.themis.business.util.JacksonUtil;
+import com.qmth.themis.common.util.Result;
+import com.qmth.themis.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Objects;
+
 /**
  * @Description: 考试批次 前端控制器
  * @Param:
@@ -16,4 +31,18 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/${prefix.url.admin}/exam")
 public class TEExamController {
 
+    @Resource
+    TEExamService teExamService;
+
+    @ApiOperation(value = "考试批次修改/新增接口")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result save(@ApiParam(value = "考试批次信息", required = true) @RequestBody TEExam teExam, HttpServletRequest request) throws NoSuchAlgorithmException {
+        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount(request);
+        if (Objects.nonNull(teExam.getId())) {
+            teExam.setUpdateId(tbUser.getId());
+        }
+        teExamService.saveOrUpdate(teExam);
+        return ResultUtil.ok(JacksonUtil.parseJson(SystemConstant.SUCCESS));
+    }
 }

+ 3 - 4
themis-backend/src/main/java/com/qmth/themis/backend/interceptor/AuthInterceptor.java

@@ -93,15 +93,14 @@ public class AuthInterceptor implements HandlerInterceptor {
                     userId = Long.parseLong(tbSession.getIdentity());
                     Date expireTime = tbSession.getExpireTime();
                     //手机端的token时长为一个月,所以会出现缓存没有的情况
+                    if (expireTime.getTime() <= System.currentTimeMillis()) {//先判断时间是否过期
+                        throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
+                    }
                     TBUser tbUser = (TBUser) redisUtil.getUser(userId);
                     if (Objects.isNull(tbUser)) {
                         tbUser = tbUserService.getById(userId);
                         redisUtil.setUser(tbUser.getId(), tbUser);
                     }
-                    //还剩5分钟刷新会话缓存
-                    if (Objects.nonNull(expireTime) && (expireTime.getTime() - System.currentTimeMillis()) <= SystemConstant.REFRESH_EXPIRE_TIME) {
-                        redisUtil.refreshUserSession(sessionId);
-                    }
 
                     request.setAttribute(SystemConstant.SESSION, tbSession);
                     request.setAttribute(SystemConstant.ACCOUNT, tbUser);

+ 1 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -36,6 +36,7 @@ public class SystemConstant {
     public static final String RECORDS = "records";
     public static final String USER = "user:";
     public static final String SESSION = "session:";
+    public static final String ORG = "org:";
     public static final String LINK = "LINK";
     public static final String MENU = "MENU";
     public static final String AUTH_CACHE = "auth_cache";

+ 1 - 13
themis-business/src/main/java/com/qmth/themis/business/entity/TOeExamRecord.java

@@ -43,10 +43,6 @@ public class TOeExamRecord implements Serializable {
     @TableField(value = "answer_path")
     private String answerPath;
 
-    @ApiModelProperty(value = "第几次考试")
-    @TableField(value = "order_number")
-    private Integer orderNumber;
-
     @ApiModelProperty(value = "当前状态")
     @TableField(value = "status")
     private Integer status;
@@ -159,7 +155,7 @@ public class TOeExamRecord implements Serializable {
     @TableField(value = "paper_struct")
     private String paperStruct;
 
-    @ApiModelProperty(value = "个人试卷结构是否已上传")
+    @ApiModelProperty(value = "个人试卷结构是否已上传,0:未上传,1:已上传")
     @TableField(value = "paper_struct_upload")
     private Integer paperStructUpload;
 
@@ -243,14 +239,6 @@ public class TOeExamRecord implements Serializable {
         this.answerPath = answerPath;
     }
 
-    public Integer getOrderNumber() {
-        return orderNumber;
-    }
-
-    public void setOrderNumber(Integer orderNumber) {
-        this.orderNumber = orderNumber;
-    }
-
     public Integer getStatus() {
         return status;
     }

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TOeFaceVerifyHistory.java

@@ -44,7 +44,7 @@ public class TOeFaceVerifyHistory implements Serializable {
     @TableField(value = "update_time", fill = FieldFill.UPDATE)
     private Date updateTime;
 
-    @ApiModelProperty(value = "初次开考、恢复开考、过程中")
+    @ApiModelProperty(value = "0:初次开考,1:恢复开考,2:过程中")
     @TableField(value = "type")
     private Integer type;
 
@@ -52,7 +52,7 @@ public class TOeFaceVerifyHistory implements Serializable {
     @TableField(value = "photo_url")
     private String photoUrl;
 
-    @ApiModelProperty(value = "本地验证是否通过")
+    @ApiModelProperty(value = "本地验证是否通过,0:不通过,1:通过")
     @TableField(value = "pass")
     private Integer pass;
 

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TOeLivenessVerifyHistory.java

@@ -27,7 +27,7 @@ public class TOeLivenessVerifyHistory implements Serializable {
     @TableField(value = "exam_record_id")
     private Long examRecordId;
 
-    @ApiModelProperty(value = "开考还是过程中")
+    @ApiModelProperty(value = "0:初次开考,1:恢复开考,2:过程中")
     @TableField(value = "type")
     private Integer type;
 
@@ -43,7 +43,7 @@ public class TOeLivenessVerifyHistory implements Serializable {
     @TableField(value = "retry")
     private Integer retry;
 
-    @ApiModelProperty(value = "本地验证是否通过")
+    @ApiModelProperty(value = "本地验证是否通过,0:不通过,1:通过")
     @TableField(value = "pass")
     private Integer pass;
 

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/TOeTaskHistory.java

@@ -24,7 +24,7 @@ public class TOeTaskHistory implements Serializable {
     @TableId(value = "id")
     private Long id;
 
-    @ApiModelProperty(value = "任务类型: calculate_exam_score: 考试重新算分 import_exam_student: 导入考生 import_exam_paper: 导入试卷 import_invigilate_user: 导入监考员 export_invigilate_user: 导出监考员")
+    @ApiModelProperty(value = "任务类型,0:考试重新算分,1:导入考生,2:导入试卷,3:导入监考员,4:导出监考员")
     @TableField("type")
     private Integer type;
 
@@ -32,7 +32,7 @@ public class TOeTaskHistory implements Serializable {
     @TableField("entity_id")
     private Long entityId;
 
-    @ApiModelProperty(value = "任务状态: init: 未开始 running: 开始执行 finish: 执行结束")
+    @ApiModelProperty(value = "任务状态,0:未开始,1:开始执行,2:执行结束")
     @TableField("status")
     private Integer status;
 

+ 18 - 18
themis-business/src/main/java/com/qmth/themis/business/entity/common/Exam.java

@@ -82,35 +82,35 @@ public class Exam extends BaseEntity {
     @TableField(value = "break_resume_count")
     private Integer breakResumeCount;
 
-    @ApiModelProperty(value = "是否开启/强制客户端视频监控")
+    @ApiModelProperty(value = "是否开启/强制客户端视频监控,0:不开启,1:开启,2:强制开启")
     @TableField(value = "client_video_push")
     private Integer clientVideoPush;
 
-    @ApiModelProperty(value = "是否开启客户端视频转录")
+    @ApiModelProperty(value = "是否开启客户端视频转录,0:不开启,1:开启")
     @TableField(value = "client_video_record")
     private Integer clientVideoRecord;
 
-    @ApiModelProperty(value = "是否开启/强制微信小程序监控")
+    @ApiModelProperty(value = "是否开启/强制微信小程序监控,0:不开启,1:开启,2:强制开启")
     @TableField(value = "wxapp_video_push")
     private Integer wxappVideoPush;
 
-    @ApiModelProperty(value = "是否开启微信小程序视频转录")
+    @ApiModelProperty(value = "是否开启微信小程序视频转录,0:不开启,1:开启")
     @TableField(value = "wxapp_video_record")
     private Integer wxappVideoRecord;
 
-    @ApiModelProperty(value = "是否允许使用摄像头拍照答题")
+    @ApiModelProperty(value = "是否允许使用摄像头拍照答题,0:不允许,1:允许")
     @TableField(value = "camera_photo_upload")
     private Integer cameraPhotoUpload;
 
-    @ApiModelProperty(value = "是否允许使用微信拍照答题")
+    @ApiModelProperty(value = "是否允许使用微信拍照答题,0:不允许,1:允许")
     @TableField(value = "wxapp_photo_upload")
     private Integer wxappPhotoUpload;
 
-    @ApiModelProperty(value = "重考是否审批")
+    @ApiModelProperty(value = "重考是否审批,0:不审批,1:审批")
     @TableField(value = "reexam_auditing")
     private Integer reexamAuditing;
 
-    @ApiModelProperty(value = "交卷后是否显示客观得分")
+    @ApiModelProperty(value = "交卷后是否显示客观得分,0:不显示,1:显示")
     @TableField(value = "show_objective_score")
     private Integer showObjectiveScore;
 
@@ -122,7 +122,7 @@ public class Exam extends BaseEntity {
     @TableField(value = "enable")
     private Integer enable;
 
-    @ApiModelProperty(value = "是否归档")
+    @ApiModelProperty(value = "是否归档,0:不归档,1:归档")
     @TableField(value = "archived")
     private Integer archived;
 
@@ -134,23 +134,23 @@ public class Exam extends BaseEntity {
     @TableField(value = "max_duration_seconds")
     private Integer maxDurationSeconds;
 
-    @ApiModelProperty(value = "是否在结束时间集中强制收卷")
+    @ApiModelProperty(value = "是否在结束时间集中强制收卷,0:不强制,1:强制")
     @TableField(value = "force_finish")
     private Integer forceFinish;
 
-    @ApiModelProperty(value = "开考身份验证策略")
+    @ApiModelProperty(value = "开考身份验证策略,0:关闭,1:非强制人脸验证,2:强制人脸验证,3:活体验证")
     @TableField(value = "entry_authentication_policy")
     private Integer entryAuthenticationPolicy;
 
-    @ApiModelProperty(value = "考试过程中人脸检测是否开启")
+    @ApiModelProperty(value = "考试过程中人脸检测是否开启,0:不开启,1:开启")
     @TableField(value = "in_process_face_verify")
     private Integer inProcessFaceVerify;
 
-    @ApiModelProperty(value = "考试过程中人脸检测是否忽略陌生人")
+    @ApiModelProperty(value = "考试过程中人脸检测是否忽略陌生人 ,0:不忽略,1:忽略")
     @TableField(value = "in_process_face_stranger_ignore")
     private Integer inProcessFaceStrangerIgnore;
 
-    @ApiModelProperty(value = "考试过程中是否启用活体检测")
+    @ApiModelProperty(value = "考试过程中是否启用活体检测 ,0:不启用,1:启用")
     @TableField(value = "in_process_liveness_verify")
     private Integer inProcessLivenessVerify;
 
@@ -162,15 +162,15 @@ public class Exam extends BaseEntity {
     @TableField(value = "in_process_liveness_retry_count")
     private Integer inProcessLivenessRetryCount;
 
-    @ApiModelProperty(value = "考试过程中活体检测结果判定规则")
+    @ApiModelProperty(value = "考试过程中活体检测结果判定规则,0:任意一次通过,1:全部都要通过,2:通过次数大于失败次数")
     @TableField(value = "in_process_liveness_judge_policy")
     private Integer inProcessLivenessJudgePolicy;
 
-    @ApiModelProperty(value = "多次考试记录的选择逻辑")
+    @ApiModelProperty(value = "多次考试记录的选择逻辑,0:全部阅卷后取最高分,1:客观分最高,3:最后一次提交")
     @TableField(value = "record_select_strategy")
     private Integer recordSelectStrategy;
 
-    @ApiModelProperty(value = "是否IP段限制")
+    @ApiModelProperty(value = "是否IP段限制,0:不允许,1:允许")
     @TableField(value = "enable_ip_limit")
     private Integer enableIpLimit;
 
@@ -178,7 +178,7 @@ public class Exam extends BaseEntity {
     @TableField(value = "ip_allow")
     private String ipAllow;
 
-    @ApiModelProperty(value = "算分状态")
+    @ApiModelProperty(value = "算分状态,0:从未算分,1:正在算分,2:算分完成")
     @TableField(value = "score_status")
     private Integer scoreStatus;
 

+ 3 - 3
themis-business/src/main/java/com/qmth/themis/business/entity/common/ExamCourse.java

@@ -32,11 +32,11 @@ public class ExamCourse implements Serializable {
     @TableField(value = "course_name")
     private String courseName;
 
-    @ApiModelProperty(value = "是否开启客观题乱序")
+    @ApiModelProperty(value = "是否开启客观题乱序,0:不开启,1:开启")
     @TableField(value = "objective_shuffle")
     private Integer objectiveShuffle;
 
-    @ApiModelProperty(value = "是否选项乱序,针对一个科目进行设置")
+    @ApiModelProperty(value = "是否选项乱序,针对一个科目进行设置,0:不开启,1:开启")
     @TableField(value = "option_shuffle")
     private Integer optionShuffle;
 
@@ -44,7 +44,7 @@ public class ExamCourse implements Serializable {
     @TableField(value = "paper_count")
     private Integer paperCount;
 
-    @ApiModelProperty(value = "是否已补齐标答")
+    @ApiModelProperty(value = "是否已补齐标答,0:否,1:是")
     @TableField(value = "has_answer")
     private Integer hasAnswer;
 

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/entity/common/ExamPaper.java

@@ -29,11 +29,11 @@ public class ExamPaper extends BaseEntity {
     @TableField(value = "decrypt_secret")
     private String decryptSecret;
 
-    @ApiModelProperty(value = "自动、手动、不加密")
+    @ApiModelProperty(value = "0:自动,1:手动,2:不加密")
     @TableField(value = "encrypt_mode")
     private Integer encryptMode;
 
-    @ApiModelProperty(value = "是否需要语音作答")
+    @ApiModelProperty(value = "是否需要语音作答,0:不需要,1:需要")
     @TableField(value = "need_voice_answer")
     private Integer needVoiceAnswer;
 

+ 29 - 0
themis-business/src/main/java/com/qmth/themis/business/util/RedisUtil.java

@@ -23,6 +23,35 @@ public class RedisUtil {
     @Resource
     RedisTemplate redisTemplate;
 
+    /**
+     * 获取机构信息
+     *
+     * @param orgId
+     * @return
+     */
+    public Object getOrg(Long orgId) {
+        return redisTemplate.opsForValue().get(SystemConstant.ORG + orgId);
+    }
+
+    /**
+     * 设置机构信息
+     *
+     * @param orgId
+     * @param o
+     */
+    public void setOrg(Long orgId, Object o) {
+        redisTemplate.opsForValue().set(SystemConstant.ORG + orgId, o, SystemConstant.REDIS_EXPIRE_TIME, TimeUnit.SECONDS);
+    }
+
+    /**
+     * 删除机构缓存
+     *
+     * @param orgId
+     */
+    public void deleteOrg(Long orgId) {
+        redisTemplate.delete(SystemConstant.ORG + orgId);
+    }
+
     /**
      * 获取用户信息
      *