commit | author | age
|
a18bfa
|
1 |
package com.changhong.epc.rely.api.tool; |
Z |
2 |
|
|
3 |
import com.changhong.epc.constter.base.BaseConst; |
|
4 |
import com.iemsoft.framework.cloud.core.tools.ObjectUtil; |
|
5 |
import com.iemsoft.framework.cloud.redis.service.CacheUtils; |
|
6 |
import lombok.extern.slf4j.Slf4j; |
|
7 |
import org.springframework.stereotype.Service; |
|
8 |
|
|
9 |
/** |
|
10 |
* 版本号过滤器 |
|
11 |
*/ |
|
12 |
@Service |
|
13 |
@Slf4j |
|
14 |
public class VersionFilterApi implements BaseConst { |
|
15 |
|
|
16 |
public static void filter(String defineCode, Object tenantId, Object companyId) { |
|
17 |
String key; |
|
18 |
if(ObjectUtil.notEmpty(tenantId) && ObjectUtil.notEmpty(companyId)){ |
|
19 |
CacheUtils.del(key = getKey(defineCode, tenantId, companyId)); |
|
20 |
}else { |
|
21 |
key = String.format("version:master:%s:********************************", getDefineCode(defineCode)); |
|
22 |
CacheUtils.del(CacheUtils.keys(key).stream().toArray(String[]::new)); |
|
23 |
} |
|
24 |
log.debug("更新缓存版本号:{}", key); |
|
25 |
} |
|
26 |
|
|
27 |
public static String getKey(String defineCode, Object tenantId, Object companyId){ |
|
28 |
return String.format("version:master:%s:%s", getDefineCode(defineCode), MD5.GetMD5Code(tenantId+""+companyId)); |
|
29 |
} |
|
30 |
|
|
31 |
public static String getDefineCode(String defineCode){ |
|
32 |
int size = 10 - defineCode.length(); |
|
33 |
StringBuilder res = new StringBuilder(); |
|
34 |
for (int i = 0; i < size; i++) { |
|
35 |
res.append('0'); |
|
36 |
} |
|
37 |
res.append(defineCode); |
|
38 |
return res.toString(); |
|
39 |
} |
|
40 |
|
|
41 |
public static void main(String[] args) { |
|
42 |
for (int i = 0; i < 32; i++) { |
|
43 |
System.out.print('*'); |
|
44 |
} |
|
45 |
} |
|
46 |
|
|
47 |
} |