游戏角标-百顺-替换域名
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.accompany.common.constant;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author: chucheng
|
||||
* @Date: 2019/7/25 14:41
|
||||
@@ -8,8 +11,11 @@ package com.accompany.common.constant;
|
||||
*/
|
||||
public enum AppEnum {
|
||||
|
||||
youmi("youmi", "molistar ios马甲包", "api.hfighting.com", "image.molistar.xyz", "api.hfighting.com", "molistar"),
|
||||
molistar("molistar", "molistar google马甲包", "api.molistar.xyz", "image.molistar.xyz", "api.molistar.xyz", "molistar"),
|
||||
other("other", "other", "api.pekolive.com", "image.pekolive.com", "api.pekolive.com", "pekolive", Map.of()),
|
||||
youmi("youmi", "molistar ios马甲包", "api.hfighting.com", "image.molistar.xyz", "api.hfighting.com", "molistar",
|
||||
Map.of(Pattern.compile("baishun.minigame.*"), "baishun.minigame.molistar.xyz")),
|
||||
molistar("molistar", "molistar google马甲包", "api.molistar.xyz", "image.molistar.xyz", "api.molistar.xyz", "molistar",
|
||||
Map.of(Pattern.compile("baishun.minigame.*"), "baishun.minigame.molistar.xyz")),
|
||||
;
|
||||
|
||||
public static AppEnum getCurApp(){
|
||||
@@ -24,17 +30,20 @@ public enum AppEnum {
|
||||
private String resourceDomain;
|
||||
private String h5Domain;
|
||||
private String h5RootDir;
|
||||
private Map<Pattern, String> patternMap;
|
||||
|
||||
AppEnum(String value, String desc,
|
||||
String apiDomain,
|
||||
String resourceDomain,
|
||||
String h5Domain, String h5RootDir) {
|
||||
String h5Domain, String h5RootDir,
|
||||
Map<Pattern, String> patternMap) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
this.apiDomain = apiDomain;
|
||||
this.resourceDomain = resourceDomain;
|
||||
this.h5Domain = h5Domain;
|
||||
this.h5RootDir = h5RootDir;
|
||||
this.patternMap = patternMap;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
@@ -60,4 +69,9 @@ public enum AppEnum {
|
||||
public String getH5RootDir() {
|
||||
return h5RootDir;
|
||||
}
|
||||
|
||||
public Map<Pattern, String> getPatternMap() {
|
||||
return patternMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ public class ReplaceAppDomainUtils {
|
||||
|
||||
//todo 动态
|
||||
private static final List<String> EXCLUDE_HOST_List = Lists.newArrayList("image.hfighting.com", "img.hfighting.com",
|
||||
"lh3.googleusercontent.com", "",
|
||||
"lh3.googleusercontent.com", "baishun.minigame.moliparty.com",
|
||||
"baishun.minigame.molistar.xyz", "img.molistar.xyz", "www.ptpay.com.tw", "cdn-molistar.leadercc.com", "joysdk.com","cdn-5uavs0xy.quantum-nexus.net");
|
||||
|
||||
public static String replaceUrl(String str){
|
||||
|
@@ -17,7 +17,8 @@ import com.accompany.business.service.resource.GamePlayDisplayToRechargeUserServ
|
||||
import com.accompany.business.service.resource.ResourceService;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.common.annotation.Authorization;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.constant.AppEnum;
|
||||
import com.accompany.common.constant.GameConstant;
|
||||
import com.accompany.common.device.DeviceInfo;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.core.base.UidContextHolder;
|
||||
@@ -30,13 +31,16 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.accompany.common.constant.ApplicationConstant.PublicParameters.PUB_UID;
|
||||
|
||||
/**
|
||||
* @author: liaozetao
|
||||
* @date: 2023/11/16 14:41
|
||||
@@ -93,16 +97,17 @@ public class ResourceController {
|
||||
@GetMapping("gamePlay")
|
||||
@Authorization
|
||||
public BusiResult<List<Resource>> gamePlay(DeviceInfo deviceInfo,
|
||||
@RequestParam(value = "roomUid", required = false) Long roomUid,
|
||||
@RequestHeader(value = PUB_UID) Long pubUid) {
|
||||
Long roomUid) {
|
||||
List<Resource> resources = resourceService.resources(ResourceTypeEnum.GAMEPLAY.ordinal());
|
||||
if (CollectionUtil.isEmpty(resources)) {
|
||||
return BusiResult.success(resources);
|
||||
}
|
||||
resources = resources.stream().peek(v -> {
|
||||
resources = resources.stream()
|
||||
.peek(v -> {
|
||||
covertGameVo(v, deviceInfo.getOs());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
Long pubUid = UidContextHolder.get();
|
||||
Users u = usersService.getNotNullUsersByUid(pubUid);
|
||||
|
||||
List<Long> giveUidList = giveUserService.getGiveUidList();
|
||||
@@ -117,6 +122,26 @@ public class ResourceController {
|
||||
|
||||
private void covertGameVo(Resource v, String os) {
|
||||
try {
|
||||
// 在这里转换域名
|
||||
if (GameConstant.GameChannel.BAISHUN.name().equals(v.getCode())
|
||||
&& StringUtils.hasText(v.getSkipContent())){
|
||||
URL url = new URL(v.getSkipContent());
|
||||
String host = url.getHost();
|
||||
|
||||
AppEnum appEnum = AppEnum.getCurApp();
|
||||
for (Map.Entry<Pattern, String> entry : appEnum.getPatternMap().entrySet()){
|
||||
Matcher matcher = entry.getKey().matcher(host);
|
||||
if (matcher.matches()){
|
||||
if (host.equals(entry.getValue())){
|
||||
break;
|
||||
}
|
||||
String newUrl = v.getSkipContent().replaceFirst(url.getHost(), entry.getValue());
|
||||
v.setSkipContent(newUrl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String ruleValue = v.getRuleValue();
|
||||
if(StrUtil.isEmpty(ruleValue)
|
||||
|| !ruleValue.startsWith(StrUtil.DELIM_START)
|
||||
|
Reference in New Issue
Block a user