|
|
@@ -70,6 +70,15 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
@Autowired
|
|
|
private IGameSupperService gameSupperService;
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getAppletToken(String gameAppId) {
|
|
|
+ GameExt gameExt = gameExtService.getByGameAppId(gameAppId);
|
|
|
+ if (gameExt == null) {
|
|
|
+ throw new BaseException("参数错误, 游戏配置信息不存在");
|
|
|
+ }
|
|
|
+ return this.buildAppletTokenResult(gameExt);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, String> getAppletToken(String gameId, Long signTime, String sign) {
|
|
|
GameExt gameExt = gameExtService.getByGameAppId(gameId);
|
|
|
@@ -84,18 +93,21 @@ public class GameAppletServiceImpl extends ServiceImpl<GameAppletMapper, GameApp
|
|
|
if (gameSupper == null) {
|
|
|
throw new BaseException("参数错误, 超父游戏信息不存在");
|
|
|
}
|
|
|
- //签名验证
|
|
|
this.signCheck(gameSupper.getCpServerKey(), gameId, signTime, sign);
|
|
|
- //获取小程序 accessToken
|
|
|
+
|
|
|
+ return this.buildAppletTokenResult(gameExt);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, String> buildAppletTokenResult(GameExt gameExt) {
|
|
|
GameAppletDTO gameAppletDTO = gameAppletService.getByGameId(gameExt.getGameId());
|
|
|
if (gameAppletDTO == null) {
|
|
|
throw new BaseException("参数错误, 微信小游戏配置信息不存在");
|
|
|
}
|
|
|
String accessToken = wxApiService.getAccessToken(gameAppletDTO.getAppId(), gameAppletDTO.getAppSecret());
|
|
|
- Map<String, String> resultMap = new HashMap<>(2);
|
|
|
- resultMap.put("appId", gameAppletDTO.getAppId());
|
|
|
- resultMap.put("accessToken", accessToken);
|
|
|
- return resultMap;
|
|
|
+ Map<String, String> result = new HashMap<>(2);
|
|
|
+ result.put("appId", gameAppletDTO.getAppId());
|
|
|
+ result.put("accessToken", accessToken);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private void signCheck(String cpServerKey, String gameId, Long signTime, String sign) {
|