commit | author | age
|
a18bfa
|
1 |
package com.changhong.epc.zuul.filter.version; |
Z |
2 |
|
|
3 |
import com.changhong.epc.constter.base.Context; |
|
4 |
import com.changhong.epc.rely.api.epc.tenant.MasterApi; |
|
5 |
import com.changhong.epc.rely.api.tool.MD5; |
|
6 |
import com.changhong.epc.rely.api.tool.VersionFilterApi; |
|
7 |
import com.iemsoft.framework.cloud.core.tools.JSONTool; |
|
8 |
import com.iemsoft.framework.cloud.core.tools.ObjectUtil; |
|
9 |
import com.iemsoft.framework.cloud.core.tools.SpringUtil; |
|
10 |
import com.iemsoft.framework.cloud.zuul.tool.RequestContextTool; |
|
11 |
import lombok.extern.slf4j.Slf4j; |
|
12 |
|
|
13 |
import javax.servlet.http.HttpServletRequest; |
|
14 |
import java.util.Map; |
|
15 |
import java.util.Set; |
|
16 |
import java.util.stream.Collectors; |
|
17 |
|
|
18 |
@Slf4j |
|
19 |
public class MasterVersion implements Version{ |
|
20 |
|
|
21 |
@Override |
|
22 |
public String getUpdateUrl() { |
|
23 |
return "epc/epc-tenant-api/json/pushMasDataValue"; |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
public String getUpdateKey() { |
|
28 |
return getUpdateKey(RequestContextTool.getCurrentContext().getRequest()); |
|
29 |
} |
|
30 |
|
|
31 |
protected String getUpdateKey(HttpServletRequest request) { |
|
32 |
Map<String, Object> data = JSONTool.toObj(request.getParameter("data"), Map.class); |
|
33 |
if(ObjectUtil.empty(data)){ |
|
34 |
return ""; |
|
35 |
} |
|
36 |
String key = String.format("version:master:%s:%s:%s", data.get("masDataDefCode"), data.get("tenantId"), ""); |
|
37 |
return key; |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public String getCacheKey(HttpServletRequest request, String key) { |
|
42 |
String cacheKey = String.format("version:master:%s:%s:%s" |
|
43 |
, key |
|
44 |
, Context.getTenantId() |
|
45 |
, Context.getCompanyId()); |
|
46 |
return VersionFilterApi.getKey(key, Context.getTenantId(), Context.getCompanyId()); |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
@Override |
|
51 |
public Set<String> getKeys() { |
|
52 |
return SpringUtil.getBean(MasterApi.class).getMasterDefs().stream().map(def -> def.getCode()).collect(Collectors.toSet()); |
|
53 |
} |
|
54 |
|
|
55 |
} |