TbAreaNameCache.java
1.87 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
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.HashCacheVO;
import com.clouds.common.constants.RedisKeyEnum;
import com.google.common.collect.Lists;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
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: TbAreaCache.java
* @Description:
* @version: v1.0.0
* @author: zhaowg
* @date: 2017年6月1日 下午4:30:11
* Modification History:
* Date Author Version Description
*---------------------------------------------------------*
* 2017年6月1日 zhaowg v1.0.0 创建
*/
@Component
public class TbAreaNameCache extends AbstractCache<HashCacheVO>{
@Autowired
private TbAreaDao tbAreaDao;
@Override
protected List<HashCacheVO> getData(int pageNum, int pageSize) {
TbArea tbArea = new TbArea();
tbArea.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
List<TbArea> areas = tbAreaDao.queryTbArea(tbArea );
if(CollectionUtils.isEmpty(areas)){
return null;
}
List<HashCacheVO> result = Lists.newArrayList();
for (TbArea area : areas) {
TbAreaDTO areaDto = new TbAreaDTO();
BeanUtils.copyProperties(area, areaDto);
HashCacheVO e = new HashCacheVO(area.getAreaName()+"", areaDto);
result.add(e );
}
return result;
}
@Override
protected long getTotalSize() {
return 1;
}
@Override
protected String getKey() {
return RedisKeyEnum.SYS_TB_AREA_NAME.key();
}
}