|
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.core.JsonEncoding;
|
|
|
import lombok.NonNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.env.Environment;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
@@ -471,18 +472,27 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
*/
|
|
|
public static boolean isVersion(@NonNull com.chelvc.framework.base.annotation.Version... versions) {
|
|
|
return ObjectUtils.notEmpty(versions) && Stream.of(versions).anyMatch(version -> {
|
|
|
+ String value = version.value();
|
|
|
+ if (StringUtils.isEmpty(value)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Environment environment = ApplicationContextHolder.getEnvironment(false);
|
|
|
+ if (environment != null) {
|
|
|
+ value = environment.resolvePlaceholders(value);
|
|
|
+ }
|
|
|
+ value = ApplicationContextHolder.getProperty(value, value);
|
|
|
if (version.compare() == Compare.EQ) {
|
|
|
- return isVersion(version.terminal(), version.value());
|
|
|
+ return isVersion(version.terminal(), value);
|
|
|
} else if (version.compare() == Compare.NE) {
|
|
|
- return !isVersion(version.terminal(), version.value());
|
|
|
+ return !isVersion(version.terminal(), value);
|
|
|
} else if (version.compare() == Compare.GT) {
|
|
|
- return isAfterVersion(version.terminal(), version.value());
|
|
|
+ return isAfterVersion(version.terminal(), value);
|
|
|
} else if (version.compare() == Compare.GE) {
|
|
|
- return isAfterVersion(version.terminal(), version.value(), true);
|
|
|
+ return isAfterVersion(version.terminal(), value, true);
|
|
|
} else if (version.compare() == Compare.LT) {
|
|
|
- return isBeforeVersion(version.terminal(), version.value());
|
|
|
+ return isBeforeVersion(version.terminal(), value);
|
|
|
} else if (version.compare() == Compare.LE) {
|
|
|
- return isBeforeVersion(version.terminal(), version.value(), true);
|
|
|
+ return isBeforeVersion(version.terminal(), value, true);
|
|
|
}
|
|
|
return false;
|
|
|
});
|