|
@@ -48,6 +48,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
|
|
|
|
private final RedisService<String> redisService;
|
|
private final RedisService<String> redisService;
|
|
|
|
|
|
|
|
+ private String keyPrefix = "device:history:";
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@ApiOperation("对象查询")
|
|
@ApiOperation("对象查询")
|
|
public R<DeviceInfoDto.Vo> obj(DeviceInfoDto.Obj obj) {
|
|
public R<DeviceInfoDto.Vo> obj(DeviceInfoDto.Obj obj) {
|
|
@@ -85,7 +87,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
SysDictRedis sysDictRedis = SysDictUtils.get(DeviceEnum.DATA_CLEAR_SIZE.getKey(), "device_history_twig");
|
|
SysDictRedis sysDictRedis = SysDictUtils.get(DeviceEnum.DATA_CLEAR_SIZE.getKey(), "device_history_twig");
|
|
Integer value = Integer.valueOf(sysDictRedis.getValue());
|
|
Integer value = Integer.valueOf(sysDictRedis.getValue());
|
|
//获取redis
|
|
//获取redis
|
|
- String key = "device:history:" + AuthorizeUtils.getLoginId(Long.class);
|
|
|
|
|
|
+ String key = keyPrefix + AuthorizeUtils.getLoginId(Long.class);
|
|
List<String> list = redisService.getList(key);
|
|
List<String> list = redisService.getList(key);
|
|
list.add(0, String.valueOf(obj.getDeviceId()));
|
|
list.add(0, String.valueOf(obj.getDeviceId()));
|
|
//去重
|
|
//去重
|
|
@@ -103,6 +105,20 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @PostMapping("historyList")
|
|
|
|
+ @ApiOperation("设备访问历史查询")
|
|
|
|
+ public R<List<DeviceInfoDto.Vo>> historyList() {
|
|
|
|
+ //获取redis
|
|
|
|
+ String key = keyPrefix + AuthorizeUtils.getLoginId(Long.class);
|
|
|
|
+ List<String> deviceIds = redisService.getList(key);
|
|
|
|
+ if (!Emptys.check(deviceIds)) {
|
|
|
|
+ return R.ok();
|
|
|
|
+ }
|
|
|
|
+ //查询数据库
|
|
|
|
+ List<DeviceInfo> list = list(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceIds));
|
|
|
|
+ return R.ok(copy(DeviceInfoDto.Vo.class, list));
|
|
|
|
+ }
|
|
|
|
+
|
|
@ApiOperation("修改")
|
|
@ApiOperation("修改")
|
|
@PostMapping("update")
|
|
@PostMapping("update")
|
|
public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
|
|
public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
|