From 751417a2b88848fa84153c18d6c2a4af2637e7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Mon, 30 Oct 2023 19:59:27 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E6=9B=B4=E6=96=B0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cmhi/gds/controller/ErrorController.java | 48 +++++++++++++++++++ .../GameDatabaseInfoController.java | 9 ++-- .../dto/protocol/base/BaseProtocolDTO.java | 2 +- src/main/resources/mappers/GameTable.xml | 6 +-- 4 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/cmhi/gds/controller/ErrorController.java diff --git a/src/main/java/com/cmhi/gds/controller/ErrorController.java b/src/main/java/com/cmhi/gds/controller/ErrorController.java new file mode 100644 index 0000000..5a58d0d --- /dev/null +++ b/src/main/java/com/cmhi/gds/controller/ErrorController.java @@ -0,0 +1,48 @@ +package com.cmhi.gds.controller; + +import com.cmhi.gds.common.ErrorCode; +import com.cmhi.gds.exception.ControllerNotSupportException; +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; +import org.springframework.boot.web.servlet.error.DefaultErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * The type Error controller. + * + * @author + */ +@Controller +public class ErrorController extends BasicErrorController { + /** + * Instantiates a new Error controller. + * + * @param serverProperties the server properties + */ + public ErrorController(ServerProperties serverProperties) { + super(new DefaultErrorAttributes(), serverProperties.getError()); + } + + /** + * Error response entity. + * + * @param request the request + * @return the response entity + */ + @Override + public ResponseEntity> error(HttpServletRequest request) { + HttpStatus status = getStatus(request); + + if (status.value() == HttpServletResponse.SC_NOT_FOUND) { + throw new ControllerNotSupportException(ErrorCode.ERR_UNKNOWNINTERFACE); + } + + return super.error(request); + } +} diff --git a/src/main/java/com/cmhi/gds/controller/GameDatabaseInfoController.java b/src/main/java/com/cmhi/gds/controller/GameDatabaseInfoController.java index 076c5f1..98ebaf0 100644 --- a/src/main/java/com/cmhi/gds/controller/GameDatabaseInfoController.java +++ b/src/main/java/com/cmhi/gds/controller/GameDatabaseInfoController.java @@ -11,6 +11,7 @@ import com.cmhi.gds.pojo.dto.protocol.info.GetGameInfoDetailReq; import com.cmhi.gds.pojo.dto.protocol.info.GetGamesInfoRsp; import com.cmhi.gds.pojo.dto.protocol.info.GetGamesSummaryRsp; import com.cmhi.gds.pojo.dto.protocol.info.ReportGameServerReq; +import com.cmhi.gds.pojo.vo.GameDetail; import com.cmhi.gds.pojo.vo.GameTableItemsDetail; import com.cmhi.gds.pojo.vo.GameTableItemsSummary; import com.cmhi.gds.security.annotation.Decryption; @@ -85,7 +86,7 @@ public class GameDatabaseInfoController { @ResponseBody public ProtocolRespDTO getGameInfoDetails(@Validated(ValidGroups.AddGameServiceValid.class) @RequestBody ProtocolReqDTO mr) { - GetGamesInfoRsp rspInfo = GetGamesInfoRsp.builder().build(); + GetGamesInfoRsp rspInfo = GetGamesInfoRsp.builder().items(new ArrayList<>()).build(); List gameContent = new ArrayList<>(); //获取TaskId列表 @@ -116,7 +117,10 @@ public class GameDatabaseInfoController { gi.setStatus(ErrorCode.ERR_OK.getCode()); gi.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); - v.getGameDetails().forEach(k -> { + v.getGameDetails() + .stream() + .sorted(Comparator.comparingLong(GameDetail::getGameInfoId)) + .forEach(k -> { GameInfoDetail gd = GameInfoDetail.builder() .gameInfoId(k.getGameInfoId()) .version(k.getVersion()) @@ -126,7 +130,6 @@ public class GameDatabaseInfoController { gi.getGamesInfo().add(gd); }); - gameContent.add(gi); } diff --git a/src/main/java/com/cmhi/gds/pojo/dto/protocol/base/BaseProtocolDTO.java b/src/main/java/com/cmhi/gds/pojo/dto/protocol/base/BaseProtocolDTO.java index d95c577..1ea64cd 100644 --- a/src/main/java/com/cmhi/gds/pojo/dto/protocol/base/BaseProtocolDTO.java +++ b/src/main/java/com/cmhi/gds/pojo/dto/protocol/base/BaseProtocolDTO.java @@ -24,7 +24,7 @@ public class BaseProtocolDTO { * 当前协议版本号 */ @NotNull(message = "ver 字段不能为空", groups = ValidGroups.ProtocolCommonValid.class) - @Range(min = 3, max = 9999, message = "ver 字段最小值为 3", groups = ValidGroups.ProtocolCommonValid.class) + @Range(min = 1, max = 9999, message = "ver 字段最小值为 1", groups = ValidGroups.ProtocolCommonValid.class) private Integer ver; /** diff --git a/src/main/resources/mappers/GameTable.xml b/src/main/resources/mappers/GameTable.xml index e41f10a..774cade 100644 --- a/src/main/resources/mappers/GameTable.xml +++ b/src/main/resources/mappers/GameTable.xml @@ -20,7 +20,7 @@ - + @@ -39,8 +39,8 @@