diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java index 490c66db..9fa61f17 100644 --- a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonClientConfig.java @@ -1,6 +1,7 @@ package com.ccsens.cloudutil.ribbon; import org.springframework.cloud.netflix.ribbon.RibbonClient; +import org.springframework.cloud.netflix.ribbon.RibbonClients; import org.springframework.context.annotation.Configuration; /** diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java index 55cf1d2c..0de727dd 100644 --- a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/RibbonConfiguration.java @@ -14,10 +14,6 @@ import org.springframework.context.annotation.Configuration; * @create: 2019/11/26 12:04 */ @Configuration -//@RibbonClients(value = { -// @RibbonClient(name = "tall",configuration = WpsBalanceRule.class) -//},defaultConfiguration = RibbonConfiguration.class) -@RibbonClient(name = "tall",configuration= WpsBalanceRule.class) public class RibbonConfiguration { /**根据响应时间加权,响应时间越长,权重越小,被选中的可能性越低*/ // @Bean diff --git a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java index ce27f0ef..569c13b6 100644 --- a/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java +++ b/cloudutil/src/main/java/com/ccsens/cloudutil/ribbon/WpsBalanceRule.java @@ -1,28 +1,28 @@ -package com.ccsens.cloudutil.ribbon; - -import com.netflix.client.config.IClientConfig; -import com.netflix.loadbalancer.AbstractLoadBalancerRule; -import com.netflix.loadbalancer.ILoadBalancer; -import com.netflix.loadbalancer.Server; -import org.springframework.context.annotation.Primary; - -@Primary -public class WpsBalanceRule extends AbstractLoadBalancerRule { - - @Override - public void initWithNiwsConfig(IClientConfig clientConfig) { - - } - - @Override - public Server choose(Object key) { - return choose(getLoadBalancer(), key); - } - - private Server choose(ILoadBalancer loadBalancer, Object key) { - System.out.println(key); - return null; - } - - -} +//package com.ccsens.cloudutil.ribbon; +// +//import com.netflix.client.config.IClientConfig; +//import com.netflix.loadbalancer.AbstractLoadBalancerRule; +//import com.netflix.loadbalancer.ILoadBalancer; +//import com.netflix.loadbalancer.Server; +//import org.springframework.context.annotation.Primary; +// +////@Primary +//public class WpsBalanceRule extends AbstractLoadBalancerRule { +// +// @Override +// public void initWithNiwsConfig(IClientConfig clientConfig) { +// +// } +// +// @Override +// public Server choose(Object key) { +// return choose(getLoadBalancer(), key); +// } +// +// private Server choose(ILoadBalancer loadBalancer, Object key) { +// System.out.println(key); +// return null; +// } +// +// +//} diff --git a/game/src/main/java/com/ccsens/game/service/ScreenService.java b/game/src/main/java/com/ccsens/game/service/ScreenService.java index d06d028a..835a3af5 100644 --- a/game/src/main/java/com/ccsens/game/service/ScreenService.java +++ b/game/src/main/java/com/ccsens/game/service/ScreenService.java @@ -156,6 +156,10 @@ public class ScreenService implements IScreenService { }else if( GameConstant.GAME_TYPE_BH.equalsIgnoreCase(memberGame.getGameType())){ businessType = 10; } + Map map = new HashMap<>(); + map.put("businessId",memberGame.getTaskId()); + map.put("businessType",businessType); +// String wpsFilePath = (String)RestTemplateUtil.getForEntity(PropUtil.gatewayUrl + PropUtil.getWpsFilePath, map, String.class); String wpsFilePath = tallFeignClient.getWpsFilePath(memberGame.getTaskId(),businessType); log.info("游戏配置表的路径:{}",wpsFilePath); if(StrUtil.isNotEmpty(wpsFilePath)){ @@ -350,118 +354,6 @@ public class ScreenService implements IScreenService { return gameUserPay; } -// @Override -// public ScreenVo.UrlVo getScreenUrl(QueryDto params) throws Exception { -// ScreenDto.MemberGame memberGame = params.getParam(); -// //查找游戏 -// GameType gameType = null; -// GameTypeExample gameTypeExample = new GameTypeExample(); -// gameTypeExample.createCriteria().andCodeEqualTo(memberGame.getGameType()); -// List gameTypeList = gameTypeDao.selectByExample(gameTypeExample); -// if (CollectionUtil.isNotEmpty(gameTypeList)) { -// gameType = gameTypeList.get(0); -// } -// if (ObjectUtil.isNull(gameType)) { -// throw new BaseException(CodeEnum.NOT_GAME_TYPE); -// } -// //2、查找此用户购买的此游戏的信息,若没有则添加一条记录,默认已付款,结束时间为添加后的一个月,默认次数为10次 -// GameUserPay gameUserPay = null; -// GameUserPayExample gameUserPayExample = new GameUserPayExample(); -// gameUserPayExample.createCriteria().andUserIdEqualTo(params.getUserId()).andGameTypeIdEqualTo(gameType.getId()); -// List gameUserPayList = gameUserPayDao.selectByExample(gameUserPayExample); -// if (CollectionUtil.isNotEmpty(gameUserPayList)) { -// gameUserPay = gameUserPayList.get(0); -// } else { -// gameUserPay = new GameUserPay(); -// gameUserPay.setId(snowflake.nextId()); -// gameUserPay.setUserId(params.getUserId()); -// gameUserPay.setGameTypeId(gameType.getId()); -// gameUserPay.setTotalCount(10); -// gameUserPay.setUsedCount(0); -// gameUserPay.setCreatedTime(System.currentTimeMillis()); -// gameUserPay.setDueTime(gameUserPay.getCreatedTime() + (3600 * 24 * 30)); -// gameUserPayDao.insertSelective(gameUserPay); -// } -// //查询该任务下的游戏记录信息 -// if (ObjectUtil.isNotNull(memberGame.getTaskId())) { -// GameRecordExample recordExample = new GameRecordExample(); -// recordExample.createCriteria().andTaskIdEqualTo(memberGame.getTaskId()); -// recordExample.setOrderByClause("created_at DESC"); -// List recordList = gameRecordDao.selectByExample(recordExample); -// if (CollectionUtil.isNotEmpty(recordList)) { -// GameRecord record = recordList.get(0); -// if(record.getGameStatus() == GameConstant.GAME_PREPARATION || -// record.getGameStatus() == GameConstant.GAME_PROCESSING){ -// throw new BaseException(CodeEnum.GAME_NO_END); -// } -// if(record.getGameStatus() == GameConstant.GAME_PENDING){ -// record.setGameStatus(GameConstant.GAME_COMPLETED); -// gameRecordDao.updateByPrimaryKeySelective(record); -// } -// } -// } -// -// //3、根据用户购买的记录,添加一场新的游戏记录 -// GameRecord gameRecord = new GameRecord(); -// gameRecord.setId(snowflake.nextId()); -// gameRecord.setUserPayId(gameUserPay.getId()); -// gameRecord.setTaskId(memberGame.getTaskId()); -// //添加路径 -// String gameUrl = WebConstant.TEST_URL_GAME_SQ; -// switch (gameType.getCode()){ -// case GameConstant.GAME_TYPE_SQ: break; -// case GameConstant.GAME_TYPE_SP: gameUrl = WebConstant.TEST_URL_GAME_SP; break; -// case GameConstant.GAME_TYPE_BH: gameUrl = WebConstant.TEST_URL_GAME_BH; break; -// default:break; -// } -// gameRecord.setUrl(gameUrl + gameType.getScreenUrl() + "?id=" + gameRecord.getId()); -// gameRecord.setQrCodeUrl(gameUrl + gameRecord.getId() + File.separator + gameType.getClientUrl()); -// gameRecordDao.insertSelective(gameRecord); -// //4、 判断是否有分组,如果是分组游戏,添加两条分组信息 -// if (gameType.getIsGroup() == 1) { -// GameGroup gameGroupRed = new GameGroup(); -// gameGroupRed.setId(snowflake.nextId()); -// gameGroupRed.setRecordId(gameRecord.getId()); -// gameGroupRed.setName(memberGame.getFirstTeam()); -// gameGroupRed.setCode(GameConstant.FIRST_GROUP); -// gameGroupDao.insertSelective(gameGroupRed); -// GameGroup gameGroupBlue = new GameGroup(); -// gameGroupBlue.setId(snowflake.nextId()); -// gameGroupBlue.setRecordId(gameRecord.getId()); -// gameGroupBlue.setName(memberGame.getSecondTeam()); -// gameGroupBlue.setCode(GameConstant.SECOND_GROUP); -// gameGroupDao.insertSelective(gameGroupBlue); -// } -// -// //5、查询该游戏的规则 -// List ruleList = getGameActivityRule(gameType.getId()); -// //6、返回 -// ScreenVo.UrlVo urlVo = new ScreenVo.UrlVo(); -// urlVo.setId(gameRecord.getId()); -// urlVo.setUrl(gameRecord.getUrl()); -// urlVo.setRuleList(ruleList); -// -// //路径(添加项目id) -// String url = gameRecord.getUrl() + "&projectId=" + memberGame.getProjectId(); -// //给所有人发送消息发送消息 -// ChromeMessageDto chromeMessageDto = new ChromeMessageDto(url, gameRecord.getId(), memberGame.getProjectId(),gameType.getCode()); -// BaseMessageDto.MessageUser messageUser = null; -// List messageUserList = new ArrayList<>(); -// //获取项目下所有成员 -// List memberIdList = tallFeignClient.getMemberIdListByProject(memberGame.getProjectId()); -// if (CollectionUtil.isNotEmpty(memberIdList)) { -// for (Long memberId : memberIdList) { -// messageUser = new BaseMessageDto.MessageUser(); -// messageUser.setUserId(memberId); -// messageUserList.add(messageUser); -// } -// } -// chromeMessageDto.setReceivers(messageUserList); -// messageService.sendGameMessageWithGetUrl(chromeMessageDto); -// -// return urlVo; -// } - /** * 获取游戏基本信息 * @return 返回游戏基本信息 @@ -1384,11 +1276,19 @@ public class ScreenService implements IScreenService { businessType = 10; } //查询该任务是否已有创建的游戏配置 - List wpsPath; + List wpsPath = new ArrayList<>(); WpsDto.VisitWpsUrl visitWpsUrl = new WpsDto.VisitWpsUrl(); visitWpsUrl.setBusinessId(getConfig.getTaskId()); visitWpsUrl.setBusinessType(businessType); visitWpsUrl.setUserId(params.getUserId()); + +// String result = RestTemplateUtil.postBody(PropUtil.gatewayUrl + PropUtil.queryVisitUrls, visitWpsUrl); +// log.info("调用tall查看游戏已有配置表:{}",result); +// if(StrUtil.isNotEmpty(result)){ +// JSONObject json = JSONObject.parseObject(result); +// wpsPath.add(result); +//// wpsPath = (List) json; +// } wpsPath = tallFeignClient.queryVisitUrls(visitWpsUrl); log.info("是否已有创建的游戏配置:{}",wpsPath); //有配置直接返回 @@ -1434,7 +1334,13 @@ public class ScreenService implements IScreenService { business.setFileSize(tmpFile.length()); business.setOperation(WebConstant.Wps.USER_OPERATION_NEW); business.setPrivilege(WebConstant.Wps.PROJECT_PRIVILEGE_WRITE); +// RestTemplateUtil.postBody(PropUtil.gatewayUrl + PropUtil.saveWpsFile, business); tallFeignClient.saveWpsFile(business); +// String s = RestTemplateUtil.postBody(PropUtil.gatewayUrl + PropUtil.queryVisitUrls, visitWpsUrl); +// if(StrUtil.isNotEmpty(s)){ +// JSONObject json = JSONObject.parseObject(s); +// wpsPath = (List) json; +// } wpsPath = tallFeignClient.queryVisitUrls(visitWpsUrl); return wpsPath; } diff --git a/game/src/main/resources/application-dev.yml b/game/src/main/resources/application-dev.yml index fbf23059..25841a55 100644 --- a/game/src/main/resources/application-dev.yml +++ b/game/src/main/resources/application-dev.yml @@ -30,6 +30,9 @@ swagger: gatewayUrl: https://test.tall.wiki/gateway/ notGatewayUrl: https://test.tall.wiki/ gameMqName: game_status_dev +saveWpsFile: tall/v1.0/wps/saveWps +queryVisitUrls: tall/v1.0/wps/visitUrls +getWpsFilePath: tall/v1.0/v1/3rd/getFilePath file: qrCode: https://test.tall.wiki/gateway/tall/uploads/ openWX: 0 diff --git a/game/src/main/resources/application-prod.yml b/game/src/main/resources/application-prod.yml index 2fd95e7f..25d923e2 100644 --- a/game/src/main/resources/application-prod.yml +++ b/game/src/main/resources/application-prod.yml @@ -37,6 +37,9 @@ eureka: gatewayUrl: https://www.tall.wiki/gateway/ notGatewayUrl: https://www.tall.wiki/ gameMqName: game_status_www +saveWpsFile: tall/v1.0/wps/saveWps +queryVisitUrls: tall/v1.0/wps/visitUrls +getWpsFilePath: tall/v1.0/v1/3rd/getFilePath file: qrCode: https://www.tall.wiki/gateway/tall/v1.0/uploads/ openWX: 1 \ No newline at end of file diff --git a/game/src/main/resources/application-prodsd.yml b/game/src/main/resources/application-prodsd.yml index 820e1cda..ebd7485c 100644 --- a/game/src/main/resources/application-prodsd.yml +++ b/game/src/main/resources/application-prodsd.yml @@ -36,6 +36,9 @@ eureka: gatewayUrl: https://www.tall.wiki/gateway/ notGatewayUrl: https://www.tall.wiki/ gameMqName: game_status_sd +saveWpsFile: tall/v1.0/wps/saveWps +queryVisitUrls: tall/v1.0/wps/visitUrls +getWpsFilePath: tall/v1.0/v1/3rd/getFilePath file: qrCode: https://www.tall.wiki/gateway/tall/v1.0/uploads/ openWX: 1 \ No newline at end of file diff --git a/game/src/main/resources/application-test.yml b/game/src/main/resources/application-test.yml index 1b3de44e..4cf07cc1 100644 --- a/game/src/main/resources/application-test.yml +++ b/game/src/main/resources/application-test.yml @@ -32,6 +32,10 @@ eureka: gatewayUrl: https://test.tall.wiki/gateway/ notGatewayUrl: https://test.tall.wiki/ +gameMqName: game_status_sd +saveWpsFile: tall/v1.0/wps/saveWps +queryVisitUrls: tall/v1.0/wps/visitUrls +getWpsFilePath: tall/v1.0/v1/3rd/getFilePath file: qrCode: https://test.tall.wiki/gateway/tall/v1.0/uploads/ openWX: 0 diff --git a/game/src/main/resources/application.yml b/game/src/main/resources/application.yml index 5c2cd5c4..d082c0ea 100644 --- a/game/src/main/resources/application.yml +++ b/game/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: dev - include: common, util-dev \ No newline at end of file + active: prod + include: common, util-prod \ No newline at end of file diff --git a/tall/src/main/java/com/ccsens/tall/TallApplication.java b/tall/src/main/java/com/ccsens/tall/TallApplication.java index 398c6320..290d270e 100644 --- a/tall/src/main/java/com/ccsens/tall/TallApplication.java +++ b/tall/src/main/java/com/ccsens/tall/TallApplication.java @@ -1,6 +1,5 @@ package com.ccsens.tall; -import com.ccsens.cloudutil.ribbon.WpsBalanceRule; import com.ccsens.util.WebConstant; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.CommandLineRunner; @@ -8,7 +7,6 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; -import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; diff --git a/tall/src/main/java/com/ccsens/tall/web/DebugController.java b/tall/src/main/java/com/ccsens/tall/web/DebugController.java index 8ce4801f..ef1de5d3 100644 --- a/tall/src/main/java/com/ccsens/tall/web/DebugController.java +++ b/tall/src/main/java/com/ccsens/tall/web/DebugController.java @@ -43,10 +43,10 @@ public class DebugController { }) @RequestMapping(value="",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"}) public JsonResponse getSmsCode(HttpServletRequest request) throws Exception { - redisUtil.set("wps_tall_appId","d12722a7d28e430c889309fa4754aaba"); - redisUtil.set("wps_tall_appKey","f273e717247947ba8942a2373b6896c7"); +// redisUtil.set("wps_tall_appId","d12722a7d28e430c889309fa4754aaba"); +// redisUtil.set("wps_tall_appKey","f273e717247947ba8942a2373b6896c7"); - return JsonResponse.newInstance().ok(redisUtil.get("wps_tall_appId")); + return JsonResponse.newInstance().ok("测试"); } diff --git a/util/src/main/java/com/ccsens/util/PropUtil.java b/util/src/main/java/com/ccsens/util/PropUtil.java index 5d03e025..6a0b44a4 100644 --- a/util/src/main/java/com/ccsens/util/PropUtil.java +++ b/util/src/main/java/com/ccsens/util/PropUtil.java @@ -24,7 +24,22 @@ public class PropUtil { public static String openWx; public static String signUpUrl; public static String gameMqName; + public static String saveWpsFile; + public static String queryVisitUrls; + public static String getWpsFilePath; + @Value("${saveWpsFile:}") + public void setSaveWpsFile(String saveWpsFile) { + PropUtil.saveWpsFile = saveWpsFile; + } + @Value("${queryVisitUrls:}") + public void setQueryVisitUrls(String queryVisitUrls) { + PropUtil.queryVisitUrls = queryVisitUrls; + } + @Value("${getWpsFilePath:}") + public void setGetWpsFilePath(String getWpsFilePath) { + PropUtil.getWpsFilePath = getWpsFilePath; + } @Value("${gameMqName:}") public void setGameMqName(String gameMqName) { PropUtil.gameMqName = gameMqName;