Merge remote-tracking branch 'origin/new_3A' into planz
This commit is contained in:
commit
a450832f80
@ -1,5 +1,6 @@
|
|||||||
package cn.axzo.framework.auth.domain;
|
package cn.axzo.framework.auth.domain;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -7,8 +8,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,6 +268,51 @@ public class TerminalInfo {
|
|||||||
aliasMap.put(STR_TERMINAL_SCREEN, NT_SCREEN);
|
aliasMap.put(STR_TERMINAL_SCREEN, NT_SCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易业务投标
|
||||||
|
*/
|
||||||
|
public static final String NT_BID_WEB_LEADER = "NT_BID_WEB_LEADER";
|
||||||
|
static {
|
||||||
|
aliasMap.put(NT_BID_WEB_LEADER , NT_BID_WEB_LEADER );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 交易业务招标
|
||||||
|
*/
|
||||||
|
public static final String NT_BID_WEB_ENT = "NT_BID_WEB_ENT";
|
||||||
|
static {
|
||||||
|
aliasMap.put(NT_BID_WEB_ENT, NT_BID_WEB_ENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是招投标
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isBID_WEB() {
|
||||||
|
if (!StringUtils.hasText(newTerminalString)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return newTerminalString.startsWith("NT_BID_WEB_");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是投标
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isBID_WEB_LEADER() {
|
||||||
|
return NT_BID_WEB_LEADER .equals(newTerminalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否是招标
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isBID_WEB_ENT() {
|
||||||
|
return NT_BID_WEB_ENT.equals(newTerminalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Entry<String, String> entry : aliasMap.entrySet()) {
|
for (Entry<String, String> entry : aliasMap.entrySet()) {
|
||||||
String nt = entry.getValue();
|
String nt = entry.getValue();
|
||||||
@ -342,6 +387,7 @@ public class TerminalInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isOMS_WEB() {
|
public boolean isOMS_WEB() {
|
||||||
return NT_OMS_WEB.equals(newTerminalString);
|
return NT_OMS_WEB.equals(newTerminalString);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package cn.azxo.framework.common.annotation;
|
||||||
|
|
||||||
|
import cn.azxo.framework.common.spring.condition.PodsEnvironmentCondition;
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import org.springframework.context.annotation.Conditional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只对容器环境生效。可用于区分本地开发环境和容器环境(rancher metadata.namespace)
|
||||||
|
*
|
||||||
|
* @author xiajiafu
|
||||||
|
* @since 2022/8/17
|
||||||
|
*/
|
||||||
|
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Conditional(PodsEnvironmentCondition.class)
|
||||||
|
public @interface OnlyPodsEnvironment {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对指定容器命名空间(rancher metadata.namespace)生效,默认对所有命名空间生效。
|
||||||
|
* <p> optional value: java-dev/test/test1/pre/uat/pro
|
||||||
|
*/
|
||||||
|
String[] value() default "";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package cn.azxo.framework.common.spring.condition;
|
||||||
|
|
||||||
|
import cn.azxo.framework.common.annotation.OnlyPodsEnvironment;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.springframework.context.annotation.Condition;
|
||||||
|
import org.springframework.context.annotation.ConditionContext;
|
||||||
|
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前环境是否是容器环境
|
||||||
|
*
|
||||||
|
* @author xiajiafu
|
||||||
|
* @since 2022/8/17
|
||||||
|
*/
|
||||||
|
public class PodsEnvironmentCondition implements Condition {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||||
|
Map<String, String> env = System.getenv();
|
||||||
|
if (env != null) {
|
||||||
|
String podNamespace = env.get("MY_POD_NAMESPACE");
|
||||||
|
// 为空说明非容器环境
|
||||||
|
if (podNamespace == null || "".equals(podNamespace)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MultiValueMap<String, Object> attrs = metadata.getAllAnnotationAttributes(OnlyPodsEnvironment.class.getName());
|
||||||
|
if (attrs != null) {
|
||||||
|
for (Object value : attrs.get("value")) {
|
||||||
|
return Arrays.stream((String[]) value).anyMatch(o -> "".equals(o) || o.equals(podNamespace));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user