AppAuthorizationCache.java
2.54 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
70
71
72
package com.zteits.pay.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.pay.AppOrgDTO;
import com.zteits.clouds.api.dto.pay.ThirdPartAuthorizationCacheDTO;
import com.zteits.pay.domain.AppOrg;
import com.zteits.pay.domain.AppOrgExample;
import com.zteits.pay.domain.TdCThirdPartAppAuthorization;
import com.zteits.pay.domain.TdCThirdPartAppAuthorizationExample;
import com.zteits.pay.mapper.AppOrgMapper;
import com.zteits.pay.mapper.TdCThirdPartAppAuthorizationMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* APP授权查询
* Copyright: Copyright (c) 2018
*
* @Description:
* @version: v1.0.0
* @author: xiejianpeng
* @date: 2020/12/8 16:18
* Modification History:
* Date Author Version Description
*---------------------------------------------------------*
* 2020/12/8 xiejianpeng v1.0.0 创建
*/
@Component
public class AppAuthorizationCache extends AbstractCache<HashCacheVO>{
@Autowired
private TdCThirdPartAppAuthorizationMapper thirdPartAppAuthorizationMapper;
@Override
protected List<HashCacheVO> getData(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
TdCThirdPartAppAuthorizationExample example = new TdCThirdPartAppAuthorizationExample();
example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
List<TdCThirdPartAppAuthorization> appOrgs = thirdPartAppAuthorizationMapper.selectByExample(example );
List<HashCacheVO> cacheVOs = Lists.newArrayList();
for (TdCThirdPartAppAuthorization item : appOrgs) {
ThirdPartAuthorizationCacheDTO dto = new ThirdPartAuthorizationCacheDTO();
BeanUtils.copyProperties(item, dto);
HashCacheVO vo = new HashCacheVO(item.getAppId(), dto);
cacheVOs.add(vo);
}
return cacheVOs;
}
@Override
protected long getTotalSize() {
TdCThirdPartAppAuthorizationExample example = new TdCThirdPartAppAuthorizationExample();
example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
return thirdPartAppAuthorizationMapper.countByExample(example );
}
@Override
protected String getKey() {
return RedisKeyEnum.APP_THIRD_AUTH.key();
}
}