diff --git a/couplet-common/couplet-common-redis/pom.xml b/couplet-common/couplet-common-redis/pom.xml index 1994df3..6fb7805 100644 --- a/couplet-common/couplet-common-redis/pom.xml +++ b/couplet-common/couplet-common-redis/pom.xml @@ -28,6 +28,10 @@ com.couplet couplet-common-core + + com.couplet + couplet-common-business + diff --git a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java index 51d55e3..3db9232 100644 --- a/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java +++ b/couplet-common/couplet-common-redis/src/main/java/com/couplet/common/redis/service/RedisService.java @@ -1,5 +1,6 @@ package com.couplet.common.redis.service; +import com.couplet.common.domain.CoupletVehicleData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.*; import org.springframework.stereotype.Component; @@ -19,6 +20,12 @@ public class RedisService { @Resource public RedisTemplate redisTemplate; + + public List getList () { + return redisTemplate.opsForList().range("coupletMsgData", 0, -1); + } + + /** * 缓存基本的对象,Integer、String、实体类等 * diff --git a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java index d167260..c3115e8 100644 --- a/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java +++ b/couplet-modules/couplet-business/src/main/java/com/couplet/business/server/controller/VehicleDetectionController.java @@ -5,6 +5,7 @@ import com.couplet.common.core.domain.Result; import com.couplet.common.domain.CoupletVehicleData; import com.couplet.common.domain.Vehicle; import com.couplet.common.domain.request.RealTimeDataRequest; +import com.couplet.common.redis.service.RedisService; import com.couplet.common.security.utils.SecurityUtils; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +32,8 @@ public class VehicleDetectionController { private VehicleDetectionService vehicleDetectionService; @Autowired private RabbitTemplate rabbitTemplate; + @Autowired + private RedisService redisService; private final String REDIS_LIST_KEY = "coupletMsgData"; /* * @param : @@ -65,7 +68,11 @@ public class VehicleDetectionController { - - + @PostMapping("realData") + public Result> realData(){ + List list = redisService.getList(); + Result> success = Result.success(list); + return success; + } }