yomi接口返回字段处理
This commit is contained in:
parent
d163eb8f72
commit
cfdaad54e9
@ -40,21 +40,16 @@ public class YomiGameRestController extends BaseController {
|
|||||||
* @eo.request-type text/plain
|
* @eo.request-type text/plain
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/api/gettoken")
|
@PostMapping(value = "/api/gettoken")
|
||||||
public YomiResponseWrapper<YomiTokenCO> getToken(@RequestBody String encryptedBody) {
|
public YomiTokenCO getToken(@RequestBody String encryptedBody) {
|
||||||
try {
|
try {
|
||||||
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
||||||
|
|
||||||
// 解析JSON为Cmd对象
|
|
||||||
YomiGetTokenCmd cmd = JSON.parseObject(decryptedJson, YomiGetTokenCmd.class);
|
YomiGetTokenCmd cmd = JSON.parseObject(decryptedJson, YomiGetTokenCmd.class);
|
||||||
|
|
||||||
// 调用Service处理
|
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());
|
||||||
return YomiResponseWrapper.fail(10005, e.getMessage());
|
throw new RuntimeException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,21 +62,17 @@ public class YomiGameRestController extends BaseController {
|
|||||||
* @eo.request-type text/plain
|
* @eo.request-type text/plain
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/userinfo")
|
@PostMapping("/api/userinfo")
|
||||||
public YomiResponseWrapper<YomiUserInfoCO> getUserInfo(@RequestBody String encryptedBody) {
|
public YomiUserInfoCO getUserInfo(@RequestBody String encryptedBody) {
|
||||||
try {
|
try {
|
||||||
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
||||||
|
|
||||||
// 解析JSON为Cmd对象
|
|
||||||
YomiUserInfoCmd cmd = JSON.parseObject(decryptedJson, YomiUserInfoCmd.class);
|
YomiUserInfoCmd cmd = JSON.parseObject(decryptedJson, YomiUserInfoCmd.class);
|
||||||
|
|
||||||
// 调用Service处理
|
// 调用Service处理
|
||||||
YomiUserInfoCO result = yomiGameService.getUserInfo(cmd);
|
return 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());
|
||||||
return YomiResponseWrapper.fail(10005, e.getMessage());
|
throw new RuntimeException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +85,7 @@ public class YomiGameRestController extends BaseController {
|
|||||||
* @eo.request-type text/plain
|
* @eo.request-type text/plain
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/change_balance")
|
@PostMapping("/api/change_balance")
|
||||||
public YomiResponseWrapper<YomiBalanceCO> changeBalance(@RequestBody String encryptedBody) {
|
public YomiBalanceCO changeBalance(@RequestBody String encryptedBody) {
|
||||||
try {
|
try {
|
||||||
// AES解密
|
// AES解密
|
||||||
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
String decryptedJson = AesUtils.decryptAESWithBase64(encryptedBody, yomiConfig.getAesKey());
|
||||||
@ -103,22 +94,20 @@ public class YomiGameRestController extends BaseController {
|
|||||||
YomiChangeBalanceCmd cmd = JSON.parseObject(decryptedJson, YomiChangeBalanceCmd.class);
|
YomiChangeBalanceCmd cmd = JSON.parseObject(decryptedJson, YomiChangeBalanceCmd.class);
|
||||||
|
|
||||||
// 调用Service处理
|
// 调用Service处理
|
||||||
YomiBalanceCO result = yomiGameService.changeBalance(cmd);
|
return 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())) {
|
||||||
return YomiResponseWrapper.fail(10003, e.getMessage());
|
throw new ResponseException(WalletErrorCode.INSUFFICIENT_BALANCE);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("yomi changeBalance 系统异常: {}", e.getMessage(), e);
|
log.error("yomi changeBalance 系统异常: {}", e.getMessage(), e);
|
||||||
return YomiResponseWrapper.fail(9999, e.getMessage());
|
throw new RuntimeException(e.getMessage());
|
||||||
}
|
}
|
||||||
return YomiResponseWrapper.fail(9999, "系统错误,联系技术解决");
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user