热游签名校验修改
This commit is contained in:
parent
e0080ccf1f
commit
b501410cdc
@ -7,14 +7,19 @@ import com.red.circle.component.game.hotgame.response.HotGameCoin;
|
|||||||
import com.red.circle.component.game.hotgame.response.HotGameErrorEnum;
|
import com.red.circle.component.game.hotgame.response.HotGameErrorEnum;
|
||||||
import com.red.circle.component.game.hotgame.response.HotGameResponse;
|
import com.red.circle.component.game.hotgame.response.HotGameResponse;
|
||||||
import com.red.circle.framework.web.annotation.IgnoreResultResponse;
|
import com.red.circle.framework.web.annotation.IgnoreResultResponse;
|
||||||
|
import com.red.circle.other.app.dto.clientobject.game.HotGameUpdateRequest;
|
||||||
import com.red.circle.other.app.service.game.override.domain.HotGameUserProfile;
|
import com.red.circle.other.app.service.game.override.domain.HotGameUserProfile;
|
||||||
import com.red.circle.other.app.service.game.override.service.HotGameService;
|
import com.red.circle.other.app.service.game.override.service.HotGameService;
|
||||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
import com.red.circle.tool.core.text.StringUtils;
|
||||||
import com.red.circle.tool.crypto.SecurityUtils;
|
import com.red.circle.tool.crypto.SecurityUtils;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -46,7 +51,10 @@ public class HotGameRestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
query.setToken(SecurityUtils.urlDecode(query.getToken()));
|
query.setToken(SecurityUtils.urlDecode(query.getToken()));
|
||||||
if (!query.verifySign(hotGameProperties.getSignKey())) {
|
|
||||||
|
String sign = SecurityUtils.md5(Stream.of(query.getGameId(), query.getUid(), query.getToken(), hotGameProperties.getSignKey()).filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(""))).toUpperCase();
|
||||||
|
|
||||||
|
if (!sign.equals(query.getSign())) {
|
||||||
return new HotGameResponse<HotGameUserProfile>()
|
return new HotGameResponse<HotGameUserProfile>()
|
||||||
.setErrorCode(HotGameErrorEnum.SIGN_VERIFY_FAIL.getErrorCode());
|
.setErrorCode(HotGameErrorEnum.SIGN_VERIFY_FAIL.getErrorCode());
|
||||||
}
|
}
|
||||||
@ -55,7 +63,7 @@ public class HotGameRestController {
|
|||||||
|
|
||||||
@IgnoreResultResponse
|
@IgnoreResultResponse
|
||||||
@PostMapping("/updateBalance")
|
@PostMapping("/updateBalance")
|
||||||
public HotGameResponse<HotGameCoin> updateUserCoin(@RequestBody HotGameUserCoinUpdate update) {
|
public HotGameResponse<HotGameCoin> updateUserCoin(@RequestBody HotGameUpdateRequest update) {
|
||||||
if (Objects.isNull(update) || StringUtils.isBlanks(update.getUid(), update.getGameId(),
|
if (Objects.isNull(update) || StringUtils.isBlanks(update.getUid(), update.getGameId(),
|
||||||
update.getOrderId(), update.getSign())
|
update.getOrderId(), update.getSign())
|
||||||
|| Objects.isNull(update.getType()) || Objects.isNull(update.getCoin())) {
|
|| Objects.isNull(update.getType()) || Objects.isNull(update.getCoin())) {
|
||||||
@ -66,14 +74,30 @@ public class HotGameRestController {
|
|||||||
).setErrorCode(HotGameErrorEnum.PARAM_ERROR.getErrorCode());
|
).setErrorCode(HotGameErrorEnum.PARAM_ERROR.getErrorCode());
|
||||||
}
|
}
|
||||||
update.setToken(SecurityUtils.urlDecode(update.getToken()));
|
update.setToken(SecurityUtils.urlDecode(update.getToken()));
|
||||||
if (!update.verifySign(hotGameProperties.getSignKey())) {
|
|
||||||
|
String sign = SecurityUtils.md5(Stream.of(
|
||||||
|
update.getOrderId(),
|
||||||
|
update.getGameId(),
|
||||||
|
update.getRoundId(),
|
||||||
|
update.getUid(),
|
||||||
|
update.getCoin(),
|
||||||
|
update.getType(),
|
||||||
|
update.getToken(),
|
||||||
|
hotGameProperties.getSignKey()
|
||||||
|
)
|
||||||
|
.filter(Objects::nonNull).map(String::valueOf).collect(Collectors.joining(""))).toUpperCase();
|
||||||
|
|
||||||
|
if (!sign.equals(update.getSign())) {
|
||||||
return new HotGameResponse<HotGameCoin>()
|
return new HotGameResponse<HotGameCoin>()
|
||||||
.setData(new HotGameCoin()
|
.setData(new HotGameCoin()
|
||||||
.setBalanceCoin(0L)
|
.setBalanceCoin(0L)
|
||||||
.setResponseId(IdWorkerUtils.getIdStr()))
|
.setResponseId(IdWorkerUtils.getIdStr()))
|
||||||
.setErrorCode(HotGameErrorEnum.SIGN_VERIFY_FAIL.getErrorCode());
|
.setErrorCode(HotGameErrorEnum.SIGN_VERIFY_FAIL.getErrorCode());
|
||||||
}
|
}
|
||||||
return hostGameService.updateUserCoin(update);
|
|
||||||
|
HotGameUserCoinUpdate coinUpdate = new HotGameUserCoinUpdate();
|
||||||
|
BeanUtils.copyProperties(update, coinUpdate);
|
||||||
|
return hostGameService.updateUserCoin(coinUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.red.circle.other.app.dto.clientobject.game;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HotGameUpdateRequest {
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
private String gameId;
|
||||||
|
private String roundId;
|
||||||
|
private String uid;
|
||||||
|
private Long coin;
|
||||||
|
private Integer type;
|
||||||
|
private String token;
|
||||||
|
private String sign;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user