Blame view

parking-module-system/src/main/java/com/zteits/sys/cache/SysOrgAndAppIdCache.java 2.36 KB
55f68655   王彪总   新项目
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
  package com.zteits.sys.cache;
  
  import org.apache.commons.collections4.CollectionUtils;
  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.google.common.collect.Maps;
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  import com.zteits.clouds.api.dto.park.dto.ParkingLotExtendDTO;
  import com.zteits.clouds.api.dto.sys.SysCodeValueDTO;
  import com.zteits.clouds.api.dto.sys.SysOrgAppIdCacheDTO;
  import com.zteits.sys.domain.SysCodeDef;
  import com.zteits.sys.domain.SysCodeValue;
  import com.zteits.sys.domain.SysOrgAppId;
  import com.zteits.sys.domain.SysOrgAppIdExample;
  import com.zteits.sys.mapper.SysOrgAppIdMapper;
  import com.zteits.sys.mapper.smapper.SysCodeDefSMapper;
  import com.zteits.sys.mapper.smapper.SysCodeValueSMapper;
  import org.springframework.beans.BeanUtils;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import java.util.List;
  import java.util.Map;
  
  /**
   * 组织和appId对应关系
   */
  @Component
  public class SysOrgAndAppIdCache extends AbstractCache<HashCacheVO>{
  	@Autowired
  	private SysOrgAppIdMapper sysOrgAppIdMapper;
  
  	@Override
  	protected List<HashCacheVO> getData(int pageNum, int pageSize) {
  		PageHelper.startPage(pageNum, pageSize);
  		SysOrgAppIdExample example = new SysOrgAppIdExample();
  		example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
  		List<SysOrgAppId> sysOrgAppIds = sysOrgAppIdMapper.selectByExample(example );
  		List<HashCacheVO> cacheVOs = Lists.newArrayList();
  
  		for (SysOrgAppId item : sysOrgAppIds) {
  			SysOrgAppIdCacheDTO sysOrgAppIdCacheDTO = new SysOrgAppIdCacheDTO();
  			BeanUtils.copyProperties(item, sysOrgAppIdCacheDTO);
  			String hkey = sysOrgAppIdCacheDTO.getOrgId()+"_"+sysOrgAppIdCacheDTO.getPayType();
  			HashCacheVO vo = new HashCacheVO(hkey, sysOrgAppIdCacheDTO);
  			cacheVOs.add(vo);
  		}
  		return cacheVOs;
  	}
  
  	@Override
  	protected long getTotalSize() {
  		SysOrgAppIdExample example = new SysOrgAppIdExample();
  		example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
  		return sysOrgAppIdMapper.countByExample(example );
  	}
  
  	@Override
  	protected String getKey() {
  		return RedisKeyEnum.SYS_ORG_APPID.key();
  	}
  
  }