TbAreaProvinceCache.java
1.72 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
61
62
63
64
65
66
67
68
69
package com.zteits.sys.cache;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import com.clouds.common.cache.base.AbstractCache;
import com.clouds.common.cache.base.CacheType;
import com.clouds.common.constants.RedisKeyEnum;
import com.google.common.collect.Lists;
import com.zteits.clouds.api.dto.sys.TbAreaDTO;
import com.zteits.sys.dao.TbAreaDao;
import com.zteits.sys.domain.TbArea;
/**
* 省缓存
*
* Copyright: Copyright (c) 2017 zteits
*
* @ClassName: TbAreaProvinceCache.java
* @Description:
* @version: v1.0.0
* @author: langlw
* @date: 2017年8月15日 上午9:57:10
* Modification History:
* Date Author Version Description
*---------------------------------------------------------*
* 2017年8月15日 langlw v1.0.0 创建
*/
@Component
public class TbAreaProvinceCache extends AbstractCache<TbAreaDTO>{
@Autowired
private TbAreaDao tbAreaDao;
@Override
protected List<TbAreaDTO> getData(int pageNum, int pageSize) {
List<TbArea> areas = tbAreaDao.queryProvince();
if(CollectionUtils.isEmpty(areas)){
return null;
}
List<TbAreaDTO> result = Lists.newArrayList();
for (TbArea area : areas) {
TbAreaDTO areaDto = new TbAreaDTO();
BeanUtils.copyProperties(area, areaDto);
result.add(areaDto);
}
return result;
}
@Override
protected long getTotalSize() {
return 1;
}
@Override
protected String getKey() {
return RedisKeyEnum.SYS_TB_AREA_PROVINCE_ID.key();
}
@Override
protected CacheType getCacheType() {
return CacheType.STRING;
}
}