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 @@