ParkingLotExtendAdapterCache.java
2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.zteits.park.cache;
import com.clouds.common.cache.base.AbstractCache;
import com.clouds.common.cache.base.HashCacheVO;
import com.clouds.common.constants.RedisKeyEnum;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.park.dto.ParkingLotExtendAdapterDTO;
import com.zteits.park.domain.ParkingLotExtendAdapter;
import com.zteits.park.domain.ParkingLotExtendAdapterExample;
import com.zteits.park.mapper.ParkingLotExtendAdapterMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* parking_lot_extend_adapter
* 停车场上传使用的车场编号
* 是要hash类型,hkey为停车场编号,value为停车场上传信息
* @author: wx
* @createdate: 2022年6月24日
*/
@Component
public class ParkingLotExtendAdapterCache extends AbstractCache<HashCacheVO>{
@Autowired
private ParkingLotExtendAdapterMapper parkingLotExtendAdapterMapper;
@Override
protected List<HashCacheVO> getData(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
ParkingLotExtendAdapterExample example = new ParkingLotExtendAdapterExample();
example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
List<ParkingLotExtendAdapter> parkingLots = parkingLotExtendAdapterMapper.selectByExample(example);
List<HashCacheVO> cacheVOs = Lists.newArrayList();
for (ParkingLotExtendAdapter item : parkingLots) {
ParkingLotExtendAdapterDTO dto = new ParkingLotExtendAdapterDTO();
BeanUtils.copyProperties(item, dto);
HashCacheVO vo = new HashCacheVO(item.getPlNo(), dto);
cacheVOs.add(vo);
}
return cacheVOs;
}
@Override
protected long getTotalSize() {
ParkingLotExtendAdapterExample example = new ParkingLotExtendAdapterExample();
example.createCriteria().andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
return parkingLotExtendAdapterMapper.countByExample(example);
}
@Override
protected String getKey() {
return RedisKeyEnum.PARK_PARKING_LOT_EXTEND_ADAPTER.key();
}
}