Эх сурвалжийг харах

将题目和测试结果放入redis

zsf 1 жил өмнө
parent
commit
eed9e1ad83

+ 2 - 0
src/main/java/com/rf/psychological/rest/ServerController.java

@@ -1211,6 +1211,7 @@ public class ServerController extends BaseController {
     @ApiOperation(value = "根据id查询测试详细信息")
     public Result getWeiboRecordById(String id) {
         try {
+            log.info("获取记录开始时间==========================="+DateUtil.current());
             //获取测试记录信息
             UserRecordEntity userRecordEntity = this.userRecordService.getUserRecordById(id);
             if (userRecordEntity == null){
@@ -1218,6 +1219,7 @@ public class ServerController extends BaseController {
             }
             JSONObject result = new JSONObject();
             result.put("userRecordEntity", userRecordEntity);
+            log.info("获取记录结束时间==========================="+DateUtil.current());
             return success(result);
         }catch (Exception e){
             log.error(e.getMessage());

+ 2 - 0
src/main/java/com/rf/psychological/scale/dao/repository/UserRecordRepository.java

@@ -113,6 +113,8 @@ public interface UserRecordRepository extends BaseRepository<UserRecordEntity, S
     @Query(value = "select id,flag,phone,test_date,file_name,test_result,type,name,img,test_record,test_results,institution_no,test_plan_id from t_user_record where id = :id ", nativeQuery = true)
     UserRecordEntity getUserRecordById(@Param("id") String id);
 
+    UserRecordEntity findUserRecordEntitiesById(String id);
+
     /**
      * 用户查询靶向神经振荡评估与训练记录
      *

+ 2 - 1
src/main/java/com/rf/psychological/scale/rest/WebScaleResultController.java

@@ -380,7 +380,8 @@ public class WebScaleResultController extends BaseController {
                 });
             }
         }
-
+        //获取下测试记录
+        userRecordService.getUserRecordById(userRecordEntity.getId());
         return success(userRecordEntity.getId(), "完成");
 
     }

+ 2 - 4
src/main/java/com/rf/psychological/scale/service/impl/ScaleServiceImpl.java

@@ -4,6 +4,7 @@ import com.rf.psychological.scale.dao.model.ScaleEntity;
 import com.rf.psychological.scale.dao.repository.ScaleRepository;
 import com.rf.psychological.scale.service.ScaleService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -59,11 +60,8 @@ public class ScaleServiceImpl implements ScaleService {
      * @return
      */
     @Override
+    @Cacheable(value = "scale", key = "#flag")
     public List<ScaleEntity> getScaleByFlag(String flag) {
-        //List<ScaleEntity> scaleByFlag = this.scaleRepository.getScaleByFlag(flag);
-        //for (ScaleEntity scaleEntity : scaleByFlag) {
-        //    scaleEntity.decrypt();
-        //}
         return this.scaleRepository.getScaleByFlag(flag);
     }
 

+ 3 - 1
src/main/java/com/rf/psychological/scale/service/impl/UserRecordServiceImpl.java

@@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.data.domain.*;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
@@ -281,8 +282,9 @@ public class UserRecordServiceImpl implements UserRecordService {
      * @return
      */
     @Override
+    @Cacheable(value = "record", key = "#id")
     public UserRecordEntity getUserRecordById(String id) {
-        return this.userRecordRepository.getUserRecordById(id);
+        return this.userRecordRepository.findUserRecordEntitiesById(id);
     }
 
     /**