给渗流设备接口增加redis key
parent
2466d6c469
commit
a167b6bd38
|
|
@ -9,5 +9,6 @@ public class Constants {
|
|||
|
||||
|
||||
public static final String CACHE_NAME = "DeviceInfoListAll";
|
||||
public static final String CACHE_NAME_SL = "DeviceSLInfoListAll";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, Dev
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
@CacheEvict(Constants.CACHE_NAME_SL)
|
||||
public boolean save(DeviceSLInfo entity) {
|
||||
if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) {
|
||||
throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
|
|
@ -67,7 +67,7 @@ public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, Dev
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
@CacheEvict(Constants.CACHE_NAME_SL)
|
||||
public boolean updateById(DeviceSLInfo entity) {
|
||||
DeviceSLInfo old = baseMapper.checkValidStationCode(entity.getStationCode());
|
||||
if (old == null) {
|
||||
|
|
@ -89,24 +89,24 @@ public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, Dev
|
|||
entity.setLatestReportingTime(new Date(defaultTimeStamp));
|
||||
deviceDataMapper.clearByDeviceId(entity.getDeviceId(), entity.getChannelNum());
|
||||
}
|
||||
redisTemplate.delete(Constants.CACHE_NAME);
|
||||
redisTemplate.delete(Constants.CACHE_NAME_SL);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
@CacheEvict(Constants.CACHE_NAME_SL)
|
||||
public boolean updateByIdInternal(DeviceSLInfo entity) {
|
||||
DeviceSLInfo old = baseMapper.checkValidStationCode(entity.getStationCode());
|
||||
if (old != null && !old.getId().equals(entity.getId())) {
|
||||
throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
}
|
||||
entity.setModificationTime(new Date());
|
||||
redisTemplate.delete(Constants.CACHE_NAME);
|
||||
redisTemplate.delete(Constants.CACHE_NAME_SL);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
@CacheEvict(Constants.CACHE_NAME_SL)
|
||||
public boolean removeById(Serializable id) {
|
||||
DeviceSLInfo entity = baseMapper.selectById(id);
|
||||
entity.setDel(1);
|
||||
|
|
@ -114,7 +114,7 @@ public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, Dev
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
@CacheEvict(Constants.CACHE_NAME_SL)
|
||||
public boolean restore(Integer id) {
|
||||
DeviceSLInfo entity = baseMapper.selectById(id);
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, Dev
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(Constants.CACHE_NAME)
|
||||
@Cacheable(Constants.CACHE_NAME_SL)
|
||||
public List<DeviceSLInfo> listAll() {
|
||||
return baseMapper.listAll();
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, Dev
|
|||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
Set<String> keys = redisTemplate.keys(Constants.CACHE_NAME + "*");
|
||||
Set<String> keys = redisTemplate.keys(Constants.CACHE_NAME_SL + "*");
|
||||
for (String k : keys) {
|
||||
redisTemplate.delete(k);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue