package com.changhong.epc.zuul.filter.version;
|
|
import com.changhong.epc.constter.base.Context;
|
import com.changhong.epc.rely.api.epc.tenant.MasterApi;
|
import com.changhong.epc.rely.api.tool.MD5;
|
import com.changhong.epc.rely.api.tool.VersionFilterApi;
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import com.iemsoft.framework.cloud.zuul.tool.RequestContextTool;
|
import lombok.extern.slf4j.Slf4j;
|
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.Map;
|
import java.util.Set;
|
import java.util.stream.Collectors;
|
|
@Slf4j
|
public class MasterVersion implements Version{
|
|
@Override
|
public String getUpdateUrl() {
|
return "epc/epc-tenant-api/json/pushMasDataValue";
|
}
|
|
@Override
|
public String getUpdateKey() {
|
return getUpdateKey(RequestContextTool.getCurrentContext().getRequest());
|
}
|
|
protected String getUpdateKey(HttpServletRequest request) {
|
Map<String, Object> data = JSONTool.toObj(request.getParameter("data"), Map.class);
|
if(ObjectUtil.empty(data)){
|
return "";
|
}
|
String key = String.format("version:master:%s:%s:%s", data.get("masDataDefCode"), data.get("tenantId"), "");
|
return key;
|
}
|
|
@Override
|
public String getCacheKey(HttpServletRequest request, String key) {
|
String cacheKey = String.format("version:master:%s:%s:%s"
|
, key
|
, Context.getTenantId()
|
, Context.getCompanyId());
|
return VersionFilterApi.getKey(key, Context.getTenantId(), Context.getCompanyId());
|
}
|
|
|
@Override
|
public Set<String> getKeys() {
|
return SpringUtil.getBean(MasterApi.class).getMasterDefs().stream().map(def -> def.getCode()).collect(Collectors.toSet());
|
}
|
|
}
|