游戏角标-过滤规则-版本号

This commit is contained in:
2025-08-19 18:44:35 +08:00
parent c8442b06d4
commit fe5120740b
3 changed files with 20 additions and 17 deletions

View File

@@ -40,17 +40,14 @@ public class AppVersionUtil {
return diff;
}
public static Integer getAppVersion() {
public static String getAppVersion() {
String APP_VERSION = "appVersion";
try {
//获取当前版本号
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (requestAttributes != null) {
HttpServletRequest request = requestAttributes.getRequest();
String appVersion = request.getParameter(APP_VERSION);
if (StrUtil.isNotBlank(appVersion)) {
return getAppVersion(appVersion);
}
return request.getParameter(APP_VERSION);
}
} catch (Exception ignored) {
}
@@ -58,7 +55,7 @@ public class AppVersionUtil {
}
public static Integer getAppVersion(String appVersion) {
return NumberUtil.parseInt(appVersion.replaceAll("\\.", String.valueOf(0)));
return NumberUtil.parseInt(appVersion.replaceAll("\\.", ""));
}
/**

View File

@@ -26,22 +26,22 @@ public class ResourceContext {
/**
* android
*/
private Integer androidHighVersion;
private String androidHighVersion;
/**
* android
*/
private Integer androidLowVersion;
private String androidLowVersion;
/**
* ios
*/
private Integer iosHighVersion;
private String iosHighVersion;
/**
* ios
*/
private Integer iosLowVersion;
private String iosLowVersion;
/**
* 渠道

View File

@@ -21,7 +21,6 @@ import com.accompany.common.enums.OperateType;
import com.accompany.common.utils.AppVersionUtil;
import com.accompany.core.base.DeviceInfoContextHolder;
import com.accompany.core.base.UidContextHolder;
import com.accompany.core.enumeration.PartitionEnum;
import com.accompany.core.model.Users;
import com.accompany.core.service.user.UsersBaseService;
import com.accompany.core.vo.SplashVo;
@@ -79,7 +78,7 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
DeviceInfo deviceInfo = DeviceInfoContextHolder.get();
String os = deviceInfo.getOs();
String channel = deviceInfo.getChannel();
Integer appVersion = AppVersionUtil.getAppVersion();
String appVersion = AppVersionUtil.getAppVersion();
//封装参数
ResourceContext context = new ResourceContext();
context.setUid(uid.toString());
@@ -166,9 +165,6 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
if (ruleValue == null || StrUtil.isEmpty(ruleValue.toString())) {
continue;
}
if (ruleValue.toString().contains(StrUtil.DOT) && !ruleValue.toString().startsWith(StrUtil.DELIM_START) && !ruleValue.toString().startsWith(StrUtil.DELIM_END)) {
ruleValue = AppVersionUtil.getAppVersion(ruleValue.toString());
}
Optional<ResourceRule> any = rules.stream().filter(v -> v.getRuleCode().equals(key)).findAny();
if (any.isPresent()) {
ResourceRule rule = any.get();
@@ -195,9 +191,19 @@ public class ResourceServiceImpl extends ServiceImpl<ResourceMapper, Resource> i
continue;
}
if (OperateType.LE.name().equals(kind)) {
isSkip = Integer.parseInt(val1) > Integer.parseInt(val2);
//版本号
if (targetValue.toString().contains(StrUtil.DOT) && !targetValue.toString().startsWith(StrUtil.DELIM_START) && !targetValue.toString().startsWith(StrUtil.DELIM_END)){
isSkip = AppVersionUtil.compareVersion(val1, val2) > 0;
} else {
isSkip = Integer.parseInt(val1) > Integer.parseInt(val2);
}
} else if (OperateType.GE.name().equals(kind)) {
isSkip = Integer.parseInt(val1) < Integer.parseInt(val2);
//版本号
if (targetValue.toString().contains(StrUtil.DOT) && !targetValue.toString().startsWith(StrUtil.DELIM_START) && !targetValue.toString().startsWith(StrUtil.DELIM_END)){
isSkip = AppVersionUtil.compareVersion(val1, val2) < 0;
} else {
isSkip = Integer.parseInt(val1) < Integer.parseInt(val2);
}
} else if (OperateType.LEFT_LIKE.name().equals(kind)) {
if (StrUtil.isNotEmpty(val1) && StrUtil.isNotEmpty(description) && val2.equals(YES_ZH)) {
isSkip = val1.startsWith(description);