Yomi游戏包装类处理
This commit is contained in:
parent
71ee2040fe
commit
e5ee364c9a
@ -2,6 +2,7 @@ package com.red.circle.other.adapter.app.game.party3rd;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.red.circle.framework.core.exception.ResponseException;
|
import com.red.circle.framework.core.exception.ResponseException;
|
||||||
|
import com.red.circle.framework.web.annotation.IgnoreResultResponse;
|
||||||
import com.red.circle.framework.web.controller.BaseController;
|
import com.red.circle.framework.web.controller.BaseController;
|
||||||
import com.red.circle.other.app.dto.cmd.party3rd.*;
|
import com.red.circle.other.app.dto.cmd.party3rd.*;
|
||||||
import com.red.circle.other.app.service.game.override.service.YomiGameService;
|
import com.red.circle.other.app.service.game.override.service.YomiGameService;
|
||||||
@ -39,17 +40,19 @@ public class YomiGameRestController extends BaseController {
|
|||||||
* @eo.method post
|
* @eo.method post
|
||||||
* @eo.request-type text/plain
|
* @eo.request-type text/plain
|
||||||
*/
|
*/
|
||||||
|
@IgnoreResultResponse
|
||||||
@PostMapping(value = "/api/gettoken")
|
@PostMapping(value = "/api/gettoken")
|
||||||
public YomiTokenCO getToken(@RequestBody String encryptedBody) {
|
public YomiResponseWrapper<YomiTokenCO> getToken(@RequestBody String encryptedBody) {
|
||||||
try {
|
try {
|
||||||
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
||||||
YomiGetTokenCmd cmd = JSON.parseObject(decryptedJson, YomiGetTokenCmd.class);
|
YomiGetTokenCmd cmd = JSON.parseObject(decryptedJson, YomiGetTokenCmd.class);
|
||||||
|
|
||||||
return yomiGameService.getToken(cmd);
|
YomiTokenCO result = yomiGameService.getToken(cmd);
|
||||||
|
return YomiResponseWrapper.success(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("yomi getToken 业务异常: {}", e.getMessage());
|
log.error("yomi getToken 业务异常: {}", e.getMessage());
|
||||||
throw new RuntimeException(e.getMessage());
|
return YomiResponseWrapper.fail(500, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,18 +64,20 @@ public class YomiGameRestController extends BaseController {
|
|||||||
* @eo.method post
|
* @eo.method post
|
||||||
* @eo.request-type text/plain
|
* @eo.request-type text/plain
|
||||||
*/
|
*/
|
||||||
|
@IgnoreResultResponse
|
||||||
@PostMapping("/api/userinfo")
|
@PostMapping("/api/userinfo")
|
||||||
public YomiUserInfoCO getUserInfo(@RequestBody String encryptedBody) {
|
public YomiResponseWrapper<YomiUserInfoCO> getUserInfo(@RequestBody String encryptedBody) {
|
||||||
try {
|
try {
|
||||||
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
||||||
YomiUserInfoCmd cmd = JSON.parseObject(decryptedJson, YomiUserInfoCmd.class);
|
YomiUserInfoCmd cmd = JSON.parseObject(decryptedJson, YomiUserInfoCmd.class);
|
||||||
|
|
||||||
// 调用Service处理
|
// 调用Service处理
|
||||||
return yomiGameService.getUserInfo(cmd);
|
YomiUserInfoCO result = yomiGameService.getUserInfo(cmd);
|
||||||
|
return YomiResponseWrapper.success(result);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("yomi getUserInfo 业务异常: {}", e.getMessage());
|
log.error("yomi getUserInfo 业务异常: {}", e.getMessage());
|
||||||
throw new RuntimeException(e.getMessage());
|
return YomiResponseWrapper.fail(500, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +89,9 @@ public class YomiGameRestController extends BaseController {
|
|||||||
* @eo.method post
|
* @eo.method post
|
||||||
* @eo.request-type text/plain
|
* @eo.request-type text/plain
|
||||||
*/
|
*/
|
||||||
|
@IgnoreResultResponse
|
||||||
@PostMapping("/api/change_balance")
|
@PostMapping("/api/change_balance")
|
||||||
public YomiBalanceCO changeBalance(@RequestBody String encryptedBody) {
|
public YomiResponseWrapper<YomiBalanceCO> changeBalance(@RequestBody String encryptedBody) {
|
||||||
try {
|
try {
|
||||||
// AES解密
|
// AES解密
|
||||||
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
||||||
@ -94,20 +100,24 @@ public class YomiGameRestController extends BaseController {
|
|||||||
YomiChangeBalanceCmd cmd = JSON.parseObject(decryptedJson, YomiChangeBalanceCmd.class);
|
YomiChangeBalanceCmd cmd = JSON.parseObject(decryptedJson, YomiChangeBalanceCmd.class);
|
||||||
|
|
||||||
// 调用Service处理
|
// 调用Service处理
|
||||||
return yomiGameService.changeBalance(cmd);
|
YomiBalanceCO result = yomiGameService.changeBalance(cmd);
|
||||||
|
return YomiResponseWrapper.success(result);
|
||||||
|
|
||||||
} catch (ResponseException e) {
|
} catch (ResponseException e) {
|
||||||
log.error("yomi changeBalance 业务异常: recordId={}, error={}",
|
log.error("yomi changeBalance 业务异常: recordId={}, error={}",
|
||||||
e.getMessage(), e.getMessage());
|
e.getMessage(), e.getMessage());
|
||||||
|
|
||||||
if (Objects.equals(e.getErrorCode(), WalletErrorCode.INSUFFICIENT_BALANCE.getCode())) {
|
if (Objects.equals(e.getErrorCode(), WalletErrorCode.INSUFFICIENT_BALANCE.getCode())) {
|
||||||
throw new ResponseException(WalletErrorCode.INSUFFICIENT_BALANCE);
|
return YomiResponseWrapper.fail(
|
||||||
|
WalletErrorCode.INSUFFICIENT_BALANCE.getCode(),
|
||||||
|
WalletErrorCode.INSUFFICIENT_BALANCE.getMessage()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
return YomiResponseWrapper.fail(500, e.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("yomi changeBalance 系统异常: {}", e.getMessage(), e);
|
log.error("yomi changeBalance 系统异常: {}", e.getMessage(), e);
|
||||||
throw new RuntimeException(e.getMessage());
|
return YomiResponseWrapper.fail(500, e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user