瀏覽代碼

缓存修改

wangliang 2 年之前
父節點
當前提交
43e1bc6ca7
共有 17 個文件被更改,包括 219 次插入60 次删除
  1. 1 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java
  2. 12 4
      themis-admin/src/main/java/com/qmth/themis/admin/api/TBOrgController.java
  3. 6 2
      themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java
  4. 117 3
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java
  5. 3 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamCourseController.java
  6. 7 2
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamPaperController.java
  7. 6 2
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamReexamController.java
  8. 6 2
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamStudentController.java
  9. 3 1
      themis-admin/src/main/java/com/qmth/themis/admin/api/TEStudentController.java
  10. 13 7
      themis-admin/src/main/resources/application-dev.properties
  11. 3 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/AuthInfoServiceImpl.java
  12. 10 10
      themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java
  13. 1 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEConfigServiceImpl.java
  14. 3 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java
  15. 16 18
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamCourseServiceImpl.java
  16. 6 2
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java
  17. 6 2
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java

+ 1 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/SysController.java

@@ -270,7 +270,7 @@ public class SysController {
     @ApiOperation(value = "角色查询接口")
     @ApiOperation(value = "角色查询接口")
     @RequestMapping(value = "/role/query", method = RequestMethod.POST)
     @RequestMapping(value = "/role/query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TBRole.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "角色信息", response = TBRole.class)})
-    @Cacheable(value = SystemConstant.roleCache, key = "methodName")
+    @Cacheable(value = SystemConstant.roleCache, key = "methodName", unless = "#result == null")
     public Result roleList() {
     public Result roleList() {
         QueryWrapper<TBRole> tbRoleQueryWrapper = new QueryWrapper<>();
         QueryWrapper<TBRole> tbRoleQueryWrapper = new QueryWrapper<>();
         tbRoleQueryWrapper.lambda().notIn(TBRole::getRoleCode, RoleEnum.SUPER_ADMIN.name(), RoleEnum.STUDENT.name());
         tbRoleQueryWrapper.lambda().notIn(TBRole::getRoleCode, RoleEnum.SUPER_ADMIN.name(), RoleEnum.STUDENT.name());

+ 12 - 4
themis-admin/src/main/java/com/qmth/themis/admin/api/TBOrgController.java

@@ -91,8 +91,12 @@ public class TBOrgController {
                 tbOrg.setUpdateId(tbUser.getId());
                 tbOrg.setUpdateId(tbUser.getId());
             }
             }
             tbOrgService.saveOrUpdate(tbOrg);
             tbOrgService.saveOrUpdate(tbOrg);
-            cacheService.updateOrgCache(tbOrg.getId());
-            cacheService.updateOrgCodeCache(tbOrg.getCode());
+            if (Objects.isNull(cacheService.updateOrgCache(tbOrg.getId()))) {
+                cacheService.removeOrgCache(tbOrg.getId());
+            }
+            if (Objects.isNull(cacheService.updateOrgCodeCache(tbOrg.getCode()))) {
+                cacheService.removeOrgCodeCache(tbOrg.getCode());
+            }
         } catch (Exception e) {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof DuplicateKeyException) {
             if (e instanceof DuplicateKeyException) {
@@ -131,8 +135,12 @@ public class TBOrgController {
         //保存机构
         //保存机构
         tbOrg.setEnable(enable);
         tbOrg.setEnable(enable);
         tbOrgService.updateById(tbOrg);
         tbOrgService.updateById(tbOrg);
-        cacheService.updateOrgCache(orgId);
-        cacheService.updateOrgCodeCache(tbOrg.getCode());
+        if (Objects.isNull(cacheService.updateOrgCache(orgId))) {
+            cacheService.removeOrgCache(orgId);
+        }
+        if (Objects.isNull(cacheService.updateOrgCodeCache(tbOrg.getCode()))) {
+            cacheService.removeOrgCodeCache(tbOrg.getCode());
+        }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
 }
 }

+ 6 - 2
themis-admin/src/main/java/com/qmth/themis/admin/api/TBUserController.java

@@ -679,7 +679,9 @@ public class TBUserController {
                 cacheService.removeAccountCache(tbUser.getId());
                 cacheService.removeAccountCache(tbUser.getId());
                 cacheService.removeAccountAuthCache(tbUser.getId());
                 cacheService.removeAccountAuthCache(tbUser.getId());
             } else {
             } else {
-                cacheService.updateAccountCache(tbUser.getId());
+                if (Objects.isNull(cacheService.updateAccountCache(tbUser.getId()))) {
+                    cacheService.removeAccountCache(tbUser.getId());
+                }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             log.error(SystemConstant.LOG_ERROR, e);
@@ -761,7 +763,9 @@ public class TBUserController {
             cacheService.removeAccountCache(tbUser.getId());
             cacheService.removeAccountCache(tbUser.getId());
             cacheService.removeAccountAuthCache(tbUser.getId());
             cacheService.removeAccountAuthCache(tbUser.getId());
         } else {
         } else {
-            cacheService.updateAccountCache(tbUser.getId());
+            if (Objects.isNull(cacheService.updateAccountCache(tbUser.getId()))) {
+                cacheService.removeAccountCache(tbUser.getId());
+            }
         }
         }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }

+ 117 - 3
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -1,11 +1,14 @@
 package com.qmth.themis.admin.api;
 package com.qmth.themis.admin.api;
 
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.admin.CountStopBean;
 import com.qmth.themis.business.bean.admin.CountStopBean;
+import com.qmth.themis.business.bean.cloudmark.FileUploadParams;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
+import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.ExamPropCountDto;
 import com.qmth.themis.business.dto.ExamPropCountDto;
@@ -15,11 +18,13 @@ import com.qmth.themis.business.entity.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.*;
 import com.qmth.themis.business.util.*;
+import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
+import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.dao.DuplicateKeyException;
@@ -27,11 +32,17 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.Min;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.net.URLDecoder;
 import java.util.*;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -223,7 +234,9 @@ public class TEExamController {
                     teExamActivity.setUpdateId(tbUser.getId());
                     teExamActivity.setUpdateId(tbUser.getId());
                 }
                 }
                 teExamActivityService.saveOrUpdate(teExamActivity);
                 teExamActivityService.saveOrUpdate(teExamActivity);
-                teExamActivityService.updateExamActivityCacheBean(teExamActivity.getId());
+                if (Objects.isNull(teExamActivityService.updateExamActivityCacheBean(teExamActivity.getId()))) {
+                    teExamActivityService.deleteExamActivityCacheBean(teExamActivity.getId());
+                }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             log.error(SystemConstant.LOG_ERROR, e);
@@ -247,7 +260,9 @@ public class TEExamController {
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
         }
         }
-        teExamService.updateExamCacheBean(teExam.getId());
+        if (Objects.isNull(teExamService.updateExamCacheBean(teExam.getId()))) {
+            teExamService.deleteExamCacheBean(teExam.getId());
+        }
         examPaperService.disposeObjectiveAnswer(teExam.getId());
         examPaperService.disposeObjectiveAnswer(teExam.getId());
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
@@ -328,7 +343,9 @@ public class TEExamController {
         teExam.setEnable(enable);
         teExam.setEnable(enable);
         teExam.setUpdateId(tbUser.getId());
         teExam.setUpdateId(tbUser.getId());
         teExamService.updateById(teExam);
         teExamService.updateById(teExam);
-        teExamService.updateExamCacheBean(teExam.getId());
+        if (Objects.isNull(teExamService.updateExamCacheBean(teExam.getId()))) {
+            teExamService.deleteExamCacheBean(teExam.getId());
+        }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
 
 
@@ -672,4 +689,101 @@ public class TEExamController {
         }
         }
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.TASK_ID, tbTaskHistory.getId()));
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.TASK_ID, tbTaskHistory.getId()));
     }
     }
+
+    @Resource
+    CloudMarkUtil cloudMarkUtil;
+
+    @Resource
+    TEExamPaperService teExamPaperService;
+
+    @Resource
+    TEExamStudentService teExamStudentService;
+
+    @ApiOperation(value = "http测试发送接口")
+    @RequestMapping(value = "/http/test/send", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
+    public Result httpTestSend() throws IOException {
+        Long orgId = 240069373300576256L, examId = 307119709605072896L, paperId = 307120792277622784L,
+                examStudentId = 1574244332533293057L, examRecordId = 307148263382851584L;
+        TBOrg tbOrg = cacheService.addOrgCache(orgId);
+        ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
+
+//        //测试考试
+//        SaveExamParams saveExamParams = new SaveExamParams(orgId, examCacheBean.getId(), examCacheBean.getName(), DateUtil.format(new Date(examCacheBean.getStartTime()), Constants.DEFAULT_DATE_PATTERN));
+//        cloudMarkUtil.callExamSaveApi(saveExamParams);
+//
+//        //测试科目试卷
+//        ExamPaperCacheBean examPaperCacheBean = teExamPaperService.getExamPaperCacheBean(paperId);
+//        SaveSubjectParams saveSubjectParams = new SaveSubjectParams(orgId, examCacheBean.getId(), examPaperCacheBean.getCode(), examPaperCacheBean.getName());
+//        cloudMarkUtil.callSubjectSaveApi(saveSubjectParams);
+//
+//        //测试考生
+        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
+//        SaveStudentParams saveStudentParams = new SaveStudentParams(orgId, examId, String.valueOf(examRecordId),
+//                examStudentCacheBean.getIdentity(),
+//                examStudentCacheBean.getName(),
+//                tbOrg.getName(),
+//                examStudentCacheBean.getClassNo(), "#",
+//                examStudentCacheBean.getCourseCode(),
+//                examStudentCacheBean.getCourseName());
+//        cloudMarkUtil.callStudentSaveApi(saveStudentParams);
+
+//        //测试上传文件json
+//        File fileJson = new File("/Users/king/Downloads/41a9c68b71c9486db62de90980bd7e9a");
+//        FileUploadParams fileUploadParamsJson = new FileUploadParams(orgId, examId, String.valueOf(examRecordId), fileJson);
+//        fileUploadParamsJson.setFormat(CloudMarkFileUploadTypeEnum.JSON.getCode());
+//        cloudMarkUtil.callFileUploadApi(fileUploadParamsJson);
+//
+        File filePaper = new File("/Users/king/Downloads/1");
+        FileUploadParams fileUploadParamsPaper = new FileUploadParams(orgId, examId, examStudentCacheBean.getIdentity(), CloudMarkFileUploadTypeEnum.PAPER, filePaper);
+        cloudMarkUtil.callFileUploadApi(fileUploadParamsPaper);
+        return ResultUtil.ok(true);
+    }
+
+    @ApiOperation(value = "http测试考试接口")
+    @RequestMapping(value = "/http/test/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
+    public Result httpTestApiExamSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
+        Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
+        String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
+        log.info("httpTestApiExamSave,result:{}", decodeJson);
+        return ResultUtil.ok(Collections.singletonMap("id", 1L));
+    }
+
+    @ApiOperation(value = "http测试科目接口")
+    @RequestMapping(value = "/http/test/subject/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
+    public Result httpTestApiSubjectSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
+        Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
+        String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
+        log.info("httpTestApiSubjectSave,result:{}", JacksonUtil.parseJson(decodeJson));
+        return ResultUtil.ok(Collections.singletonMap("updateTime", DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN)));
+    }
+
+    @ApiOperation(value = "http测试考生接口")
+    @RequestMapping(value = "/http/test/student/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
+    public Result httpTestApiStudentSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
+        Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
+        String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
+        log.info("httpTestApiStudentSave,result:{}", decodeJson);
+        return ResultUtil.ok(Collections.singletonMap("updateTime", DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN)));
+    }
+
+    @ApiOperation(value = "http测试文件接口")
+    @RequestMapping(value = "/http/test/file/{type}/upload", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
+    public Result httpTestFileUpload(@PathVariable("type") String type,
+                                     @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
+                                     @ApiParam(value = "准考证号") @RequestParam(required = false) String examNumber,
+                                     @ApiParam(value = "科目编码") @RequestParam(required = false) String subjectCode,
+                                     @ApiParam(value = "格式") @RequestParam(required = false) String format,
+                                     @ApiParam(value = "文件", required = true) @RequestParam MultipartFile file,
+                                     @ApiParam(value = "文件md5", required = true) @RequestParam String md5) throws IOException {
+        if (Objects.nonNull(file)) {
+            File fileNew = new File("/Users/king/Downloads/41a9c68b71c9486db62de90980bd7e9a-new");
+            IOUtils.copy(file.getInputStream(), new FileOutputStream(fileNew));
+        }
+        return ResultUtil.ok(Collections.singletonMap("success", true));
+    }
 }
 }

+ 3 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamCourseController.java

@@ -70,7 +70,9 @@ public class TEExamCourseController {
                 throw new RuntimeException(e);
                 throw new RuntimeException(e);
             }
             }
         }
         }
-        teExamCourseService.updateExamCourseCacheBean(teExamCourse.getExamId(), teExamCourse.getCourseCode());
+        if (Objects.isNull(teExamCourseService.updateExamCourseCacheBean(teExamCourse.getExamId(), teExamCourse.getCourseCode()))) {
+            teExamCourseService.deleteExamCourseCacheBean(teExamCourse.getExamId(), teExamCourse.getCourseCode());
+        }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
 
 

+ 7 - 2
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamPaperController.java

@@ -5,7 +5,10 @@ import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.MqDto;
 import com.qmth.themis.business.dto.MqDto;
-import com.qmth.themis.business.entity.*;
+import com.qmth.themis.business.entity.TBAttachment;
+import com.qmth.themis.business.entity.TBTaskHistory;
+import com.qmth.themis.business.entity.TBUser;
+import com.qmth.themis.business.entity.TEExamPaper;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.MqUtil;
 import com.qmth.themis.business.util.MqUtil;
@@ -110,7 +113,9 @@ public class TEExamPaperController {
             }
             }
         }
         }
         teExamPaperList.forEach(s -> {
         teExamPaperList.forEach(s -> {
-            teExamPaperService.updateExamPaperCacheBean(s.getId());
+            if (Objects.isNull(teExamPaperService.updateExamPaperCacheBean(s.getId()))) {
+                teExamPaperService.deleteExamPaperCacheBean(s.getId());
+            }
             ExamPaperCacheBean paper = teExamPaperService.getExamPaperCacheBean(s.getId());
             ExamPaperCacheBean paper = teExamPaperService.getExamPaperCacheBean(s.getId());
             examCourseService.deleteExamCourseCacheBean(paper.getExamId(), paper.getCourseCode());
             examCourseService.deleteExamCourseCacheBean(paper.getExamId(), paper.getCourseCode());
         });
         });

+ 6 - 2
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamReexamController.java

@@ -152,7 +152,9 @@ public class TEExamReexamController {
                             teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getAlreadyExamCount, alreadyExamCount)
                             teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getAlreadyExamCount, alreadyExamCount)
                                     .eq(TEExamStudent::getId, s);
                                     .eq(TEExamStudent::getId, s);
                             teExamStudentService.update(teExamStudentUpdateWrapper);
                             teExamStudentService.update(teExamStudentUpdateWrapper);
-                            teExamStudentService.updateExamStudentCacheBean(s);
+                            if (Objects.isNull(teExamStudentService.updateExamStudentCacheBean(s))) {
+                                teExamStudentService.deleteExamStudentCacheBean(s);
+                            }
                         }
                         }
                     }
                     }
                 });
                 });
@@ -214,7 +216,9 @@ public class TEExamReexamController {
                                             teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getAlreadyExamCount, alreadyExamCount)
                                             teExamStudentUpdateWrapper.lambda().set(TEExamStudent::getAlreadyExamCount, alreadyExamCount)
                                                     .eq(TEExamStudent::getId, teExamReexam.getExamStudentId());
                                                     .eq(TEExamStudent::getId, teExamReexam.getExamStudentId());
                                             teExamStudentService.update(teExamStudentUpdateWrapper);
                                             teExamStudentService.update(teExamStudentUpdateWrapper);
-                                            teExamStudentService.updateExamStudentCacheBean(teExamReexam.getExamStudentId());
+                                            if (Objects.isNull(teExamStudentService.updateExamStudentCacheBean(teExamReexam.getExamStudentId()))) {
+                                                teExamStudentService.deleteExamStudentCacheBean(teExamReexam.getExamStudentId());
+                                            }
                                         }
                                         }
                                     }
                                     }
                                 }
                                 }

+ 6 - 2
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamStudentController.java

@@ -227,7 +227,9 @@ public class TEExamStudentController {
         }
         }
         teExamStudentService.updateBatchById(teExamStudentList);
         teExamStudentService.updateBatchById(teExamStudentList);
         teExamStudentList.forEach(s -> {
         teExamStudentList.forEach(s -> {
-            teExamStudentService.updateExamStudentCacheBean(s.getId());
+            if (Objects.isNull(teExamStudentService.updateExamStudentCacheBean(s.getId()))) {
+                teExamStudentService.deleteExamStudentCacheBean(s.getId());
+            }
         });
         });
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
@@ -300,7 +302,9 @@ public class TEExamStudentController {
             teExamStudentService.saveOrUpdate(s);
             teExamStudentService.saveOrUpdate(s);
         });
         });
         for (TEExamStudent es : teExamStudentList) {
         for (TEExamStudent es : teExamStudentList) {
-            teExamStudentService.updateExamStudentCacheBean(es.getId());
+            if (Objects.isNull(teExamStudentService.updateExamStudentCacheBean(es.getId()))) {
+                teExamStudentService.deleteExamStudentCacheBean(es.getId());
+            }
         }
         }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }

+ 3 - 1
themis-admin/src/main/java/com/qmth/themis/admin/api/TEStudentController.java

@@ -106,7 +106,9 @@ public class TEStudentController {
         teStudent.setEnable(enable);
         teStudent.setEnable(enable);
         teStudent.setUpdateId(tbUser.getId());
         teStudent.setUpdateId(tbUser.getId());
         teStudentService.updateById(teStudent);
         teStudentService.updateById(teStudent);
-        cacheService.updateStudentAccountCache(teStudent.getId());
+        if (Objects.isNull(cacheService.updateStudentAccountCache(teStudent.getId()))) {
+            cacheService.removeStudentAccountCache(teStudent.getId());
+        }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }
 
 

+ 13 - 7
themis-admin/src/main/resources/application-dev.properties

@@ -157,12 +157,18 @@ sys.config.adminLogoUrl=http://qmth-test.oss-cn-shenzhen.aliyuncs.com/frontend/w
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 
 #\u4E91\u9605\u5377\u540C\u6B65\u914D\u7F6E
 #\u4E91\u9605\u5377\u540C\u6B65\u914D\u7F6E
-cloud.mark.url=http://192.168.10.224:80
-cloud.mark.studentScoreApi=/api/exam/student/score
-cloud.mark.examSaveApi=/api/exam/save
-cloud.mark.subjectSaveApi=/api/exam/subject/save
-cloud.mark.studentSaveApi=/api/exam/student/save
-cloud.mark.fileUploadApi=/api/file/{type}/upload
+#cloud.mark.url=http://192.168.10.224:80
+#cloud.mark.studentScoreApi=/api/exam/student/score
+#cloud.mark.examSaveApi=/api/exam/save
+#cloud.mark.subjectSaveApi=/api/exam/subject/save
+#cloud.mark.studentSaveApi=/api/exam/student/save
+#cloud.mark.fileUploadApi=/api/file/{type}/upload
+cloud.mark.url=http://127.0.0.1:6001
+cloud.mark.studentScoreApi=/api/admin/exam/http/test/student/score
+cloud.mark.examSaveApi=/api/admin/exam/http/test/save
+cloud.mark.subjectSaveApi=/api/admin/exam/http/test/subject/save
+cloud.mark.studentSaveApi=/api/admin/exam/http/test/student/save
+cloud.mark.fileUploadApi=/api/admin/exam/http/test/file/{type}/upload
 
 
 #============================================================================
 #============================================================================
 # \u914D\u7F6Erocketmq
 # \u914D\u7F6Erocketmq
@@ -223,5 +229,5 @@ com.qmth.solar.access-key=8134f6aae0134770b8618913705d3667
 com.qmth.solar.access-secret=s1NENpvc8Jq5evcE0B7GfLmoQOvwmlCy
 com.qmth.solar.access-secret=s1NENpvc8Jq5evcE0B7GfLmoQOvwmlCy
 
 
 #\u65E0\u9700\u9274\u6743\u7684url
 #\u65E0\u9700\u9274\u6743\u7684url
-no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/admin/client/save,/api/admin/client/upload,/api/admin/client/query,/api/admin/app/save,/api/admin/app/query,/api/notify/monitor/record/tencent,/api/notify/monitor/status/tencent
+no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/admin/user/login/account,/api/admin/sys/org/queryByOrgCode,/file/**,/upload/**,/client/**,/base_photo/**,/frontend/**,/api/admin/client/save,/api/admin/client/upload,/api/admin/client/query,/api/admin/app/save,/api/admin/app/query,/api/notify/monitor/record/tencent,/api/notify/monitor/status/tencent,/api/admin/exam/http/test/send,/api/admin/exam/http/test/save,/api/admin/exam/http/test/student/score,/api/admin/exam/http/test/subject/save,/api/admin/exam/http/test/student/save,/api/admin/exam/http/test/file/{type}/upload
 common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env,/api/admin/sys/file/upload,/api/admin/sys/file/download,/api/admin/sys/org/query,/api/admin/sys/role/query,/api/admin/sys/examActivity/query,/api/admin/sys/exam/query,/api/admin/sys/examRoom/query,/api/admin/sys/exam/privilegeQuery,/api/admin/student/photo/upload,/api/admin/sys/getPlayUrls,/api/admin/sys/exam/finish/query,/api/admin/sys/get_tencent_video
 common.system.urls=/api/admin/sys/getMenu,/api/admin/user/logout,/api/admin/sys/env,/api/admin/sys/file/upload,/api/admin/sys/file/download,/api/admin/sys/org/query,/api/admin/sys/role/query,/api/admin/sys/examActivity/query,/api/admin/sys/exam/query,/api/admin/sys/examRoom/query,/api/admin/sys/exam/privilegeQuery,/api/admin/student/photo/upload,/api/admin/sys/getPlayUrls,/api/admin/sys/exam/finish/query,/api/admin/sys/get_tencent_video

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/AuthInfoServiceImpl.java

@@ -187,7 +187,9 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             } else {
             } else {
                 tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
                 tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
             }
             }
-            cacheService.updateAuthInfoCache(o.getCode());
+            if (Objects.isNull(cacheService.updateAuthInfoCache(o.getCode()))) {
+                cacheService.removeAuthInfoCache(o.getCode());
+            }
 
 
             QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
             QueryWrapper<TBOrg> tbOrgQueryWrapper = new QueryWrapper<>();
             tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, o.getCode());
             tbOrgQueryWrapper.lambda().eq(TBOrg::getCode, o.getCode());

+ 10 - 10
themis-business/src/main/java/com/qmth/themis/business/service/impl/CacheServiceImpl.java

@@ -77,7 +77,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.orgCache, key = "#p0")
+    @Cacheable(value = SystemConstant.orgCache, key = "#p0", unless = "#result == null")
     public TBOrg addOrgCache(Long orgId) {
     public TBOrg addOrgCache(Long orgId) {
         return tbOrgService.getById(orgId);
         return tbOrgService.getById(orgId);
     }
     }
@@ -101,7 +101,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.orgCodeCache, key = "#p0")
+    @Cacheable(value = SystemConstant.orgCodeCache, key = "#p0", unless = "#result == null")
     public TBOrg addOrgCodeCache(String code) {
     public TBOrg addOrgCodeCache(String code) {
         TBOrg tbOrg = tbOrgService.getOne(new QueryWrapper<TBOrg>().lambda().eq(TBOrg::getCode, code));
         TBOrg tbOrg = tbOrgService.getOne(new QueryWrapper<TBOrg>().lambda().eq(TBOrg::getCode, code));
         if (Objects.isNull(tbOrg)) {
         if (Objects.isNull(tbOrg)) {
@@ -171,7 +171,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.userOauth, key = "#p0")
+    @Cacheable(value = SystemConstant.userOauth, key = "#p0", unless = "#result == null")
     public AuthDto addAccountAuthCache(Long userId) {
     public AuthDto addAccountAuthCache(Long userId) {
         AuthDto authDto = null;
         AuthDto authDto = null;
         try {
         try {
@@ -222,7 +222,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.userAccount, key = "#p0")
+    @Cacheable(value = SystemConstant.userAccount, key = "#p0", unless = "#result == null")
     public TBUser addAccountCache(Long userId) {
     public TBUser addAccountCache(Long userId) {
         return tbUserService.getById(userId);
         return tbUserService.getById(userId);
     }
     }
@@ -257,7 +257,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.studentOauth, key = "#p0")
+    @Cacheable(value = SystemConstant.studentOauth, key = "#p0", unless = "#result == null")
     public AuthDto addStudentAuthCache(Long studentId) {
     public AuthDto addStudentAuthCache(Long studentId) {
         AuthDto authDto = null;
         AuthDto authDto = null;
         try {
         try {
@@ -303,7 +303,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.studentAccount, key = "#p0")
+    @Cacheable(value = SystemConstant.studentAccount, key = "#p0", unless = "#result == null")
     public TEStudentCacheDto addStudentAccountCache(Long studentId) {
     public TEStudentCacheDto addStudentAccountCache(Long studentId) {
         TEStudent teStudent = teStudentService.getById(studentId);
         TEStudent teStudent = teStudentService.getById(studentId);
         Gson gson = new Gson();
         Gson gson = new Gson();
@@ -342,7 +342,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.sysConfigCache, key = "#p0")
+    @Cacheable(value = SystemConstant.sysConfigCache, key = "#p0", unless = "#result == null")
     public SysConfig addSysConfigCache(String key) {
     public SysConfig addSysConfigCache(String key) {
         return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
         return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
     }
     }
@@ -385,7 +385,7 @@ public class CacheServiceImpl implements CacheService {
     }
     }
 
 
     @Override
     @Override
-    @CachePut(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", unless = "#result == null")
+    @CachePut(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", condition = "#result != null")
     public AuthOrgInfoDto updateAuthInfoCache(String code) {
     public AuthOrgInfoDto updateAuthInfoCache(String code) {
         AppInfo appInfo = solarService.getAppInfo();
         AppInfo appInfo = solarService.getAppInfo();
         AuthOrgInfoDto authOrgInfoDto = null;
         AuthOrgInfoDto authOrgInfoDto = null;
@@ -423,7 +423,7 @@ public class CacheServiceImpl implements CacheService {
 //     * @return
 //     * @return
 //     */
 //     */
 //    @Override
 //    @Override
-//    @CachePut(value = SystemConstant.EXAM_AUDIO_CACHE, key = "#p0", unless = "#result == null")
+//    @CachePut(value = SystemConstant.EXAM_AUDIO_CACHE, key = "#p0", condition = "#result != null")
 //    public TEAudio updateExamAudioCache(Long id) {
 //    public TEAudio updateExamAudioCache(Long id) {
 //        return teAudioService.getById(id);
 //        return teAudioService.getById(id);
 //    }
 //    }
@@ -458,7 +458,7 @@ public class CacheServiceImpl implements CacheService {
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @CachePut(value = SystemConstant.ATTACHMENT_CACHE, key = "#p0", unless = "#result == null")
+    @CachePut(value = SystemConstant.ATTACHMENT_CACHE, key = "#p0", condition = "#result != null")
     public TBAttachment updateAttachmentCache(Long id) {
     public TBAttachment updateAttachmentCache(Long id) {
         return tbAttachmentService.getById(id);
         return tbAttachmentService.getById(id);
     }
     }

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEConfigServiceImpl.java

@@ -27,7 +27,7 @@ public class TEConfigServiceImpl extends ServiceImpl<TEConfigMapper, TEConfig> i
      * @return
      * @return
      */
      */
     @Override
     @Override
-    @Cacheable(value = SystemConstant.configCache, key = "methodName")
+    @Cacheable(value = SystemConstant.configCache, key = "methodName", unless = "#result == null")
     public TEConfig getGlobalConfig() {
     public TEConfig getGlobalConfig() {
         List<TEConfig> teConfigList = this.list();
         List<TEConfig> teConfigList = this.list();
         return Objects.isNull(teConfigList) || teConfigList.size() == 0 ? null : teConfigList.get(0);
         return Objects.isNull(teConfigList) || teConfigList.size() == 0 ? null : teConfigList.get(0);

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -423,7 +423,9 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
             teExamActivityService.saveOrUpdateBatch(teExamActivityList);
             teExamActivityService.saveOrUpdateBatch(teExamActivityList);
 
 
             for (TEExamActivity ac : teExamActivityList) {
             for (TEExamActivity ac : teExamActivityList) {
-                teExamActivityService.updateExamActivityCacheBean(ac.getId());
+                if (Objects.isNull(teExamActivityService.updateExamActivityCacheBean(ac.getId()))) {
+                    teExamActivityService.deleteExamActivityCacheBean(ac.getId());
+                }
             }
             }
 
 
             if (!CollectionUtils.isEmpty(teAudioList)) {
             if (!CollectionUtils.isEmpty(teAudioList)) {

+ 16 - 18
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamCourseServiceImpl.java

@@ -1,17 +1,5 @@
 package com.qmth.themis.business.service.impl;
 package com.qmth.themis.business.service.impl;
 
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.stereotype.Service;
-
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,6 +12,16 @@ import com.qmth.themis.business.entity.TEExamCourse;
 import com.qmth.themis.business.entity.TEExamPaper;
 import com.qmth.themis.business.entity.TEExamPaper;
 import com.qmth.themis.business.service.TEExamCourseService;
 import com.qmth.themis.business.service.TEExamCourseService;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.exception.BusinessException;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.CachePut;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * @Description: 考试科目 服务实现类
  * @Description: 考试科目 服务实现类
@@ -138,10 +136,10 @@ public class TEExamCourseServiceImpl extends ServiceImpl<TEExamCourseMapper, TEE
         }
         }
         return ret;
         return ret;
     }
     }
-    
-	@Override
-	public IPage<OpenExamCourseBean> examCourseQueryForOpen(Page<OpenExamCourseBean> ipage, Long examId,
-			String courseCode, Boolean hasPaper) {
-		return teExamCourseMapper.examCourseQueryForOpen(ipage, examId, courseCode, hasPaper);
-	}
+
+    @Override
+    public IPage<OpenExamCourseBean> examCourseQueryForOpen(Page<OpenExamCourseBean> ipage, Long examId,
+                                                            String courseCode, Boolean hasPaper) {
+        return teExamCourseMapper.examCourseQueryForOpen(ipage, examId, courseCode, hasPaper);
+    }
 }
 }

+ 6 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java

@@ -1501,7 +1501,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             TEExamService examService = SpringContextHolder.getBean(TEExamService.class);
             TEExamService examService = SpringContextHolder.getBean(TEExamService.class);
             teExamMapper.updateScoreStatus(ScoreStatusEnum.CALCULATING, examId);
             teExamMapper.updateScoreStatus(ScoreStatusEnum.CALCULATING, examId);
             teExamMapper.updateScoreProgress(0.0, examId);
             teExamMapper.updateScoreProgress(0.0, examId);
-            examService.updateExamCacheBean(examId);
+            if (Objects.isNull(examService.updateExamCacheBean(examId))) {
+                examService.deleteExamCacheBean(examId);
+            }
             task = tbTaskHistoryService.getById(taskId);
             task = tbTaskHistoryService.getById(taskId);
             task.setStatus(TaskStatusEnum.RUNNING);
             task.setStatus(TaskStatusEnum.RUNNING);
             tbTaskHistoryService.saveOrUpdate(task);
             tbTaskHistoryService.saveOrUpdate(task);
@@ -1530,7 +1532,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
             }
             }
             teExamMapper.updateScoreStatus(ScoreStatusEnum.FINISH, examId);
             teExamMapper.updateScoreStatus(ScoreStatusEnum.FINISH, examId);
             teExamMapper.updateScoreProgress(100.0, examId);
             teExamMapper.updateScoreProgress(100.0, examId);
-            examService.updateExamCacheBean(examId);
+            if (Objects.isNull(examService.updateExamCacheBean(examId))) {
+                examService.deleteExamCacheBean(examId);
+            }
             task.setSummary("处理成功");
             task.setSummary("处理成功");
             task.setProgress(100.0);
             task.setProgress(100.0);
             task.setStatus(TaskStatusEnum.FINISH);
             task.setStatus(TaskStatusEnum.FINISH);

+ 6 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEStudentServiceImpl.java

@@ -113,7 +113,9 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
         try {
         try {
             student.setBasePhotoPath(filePath);
             student.setBasePhotoPath(filePath);
             this.saveOrUpdate(student);
             this.saveOrUpdate(student);
-            cacheService.updateStudentAccountCache(student.getId());
+            if (Objects.isNull(cacheService.updateStudentAccountCache(student.getId()))) {
+                cacheService.removeStudentAccountCache(student.getId());
+            }
             in = file.getInputStream();
             in = file.getInputStream();
             ossUtil.upload(true, filePath, in, BinaryUtil.toBase64String(HexUtils.decodeHex(md5)));
             ossUtil.upload(true, filePath, in, BinaryUtil.toBase64String(HexUtils.decodeHex(md5)));
             String url = ossUtil.getAliYunOssPublicDomain().getPublicUrl() + File.separator + filePath;
             String url = ossUtil.getAliYunOssPublicDomain().getPublicUrl() + File.separator + filePath;
@@ -146,7 +148,9 @@ public class TEStudentServiceImpl extends ServiceImpl<TEStudentMapper, TEStudent
         teStudent.setPassword(studentParams.getPassword());
         teStudent.setPassword(studentParams.getPassword());
         teStudent.setUpdateId(Objects.nonNull(tbUser) ? tbUser.getId() : -1);
         teStudent.setUpdateId(Objects.nonNull(tbUser) ? tbUser.getId() : -1);
         this.updateById(teStudent);
         this.updateById(teStudent);
-        cacheService.updateStudentAccountCache(teStudent.getId());
+        if (Objects.isNull(cacheService.updateStudentAccountCache(teStudent.getId()))) {
+            cacheService.removeStudentAccountCache(teStudent.getId());
+        }
     }
     }
 
 
     /**
     /**