From 3a65ae27adc1ca7172e5416769f6b8961522048f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= Date: Thu, 26 Oct 2023 15:47:36 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E4=BF=AE=E6=AD=A3=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +++ .../java/com/cmhi/gds/common/ErrorCode.java | 35 ++++++------------- .../gds/exception/GlobalExceptionHandler.java | 23 ++++++------ .../manager/GameDatabaseServiceManager.java | 2 -- .../dto/protocol/info/GameListSummary.java | 1 - 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/pom.xml b/pom.xml index 0592ece..f7d4a06 100644 --- a/pom.xml +++ b/pom.xml @@ -132,6 +132,11 @@ mybatis-spring-boot-starter 3.0.2 + + org.yaml + snakeyaml + 2.1 + diff --git a/src/main/java/com/cmhi/gds/common/ErrorCode.java b/src/main/java/com/cmhi/gds/common/ErrorCode.java index fcb1417..80e3b9e 100644 --- a/src/main/java/com/cmhi/gds/common/ErrorCode.java +++ b/src/main/java/com/cmhi/gds/common/ErrorCode.java @@ -334,31 +334,16 @@ public enum ErrorCode implements BaseEnum { * @return the http code */ public int getHttpCode() { - switch (this) { - case ERR_OK: - return HttpServletResponse.SC_OK; - case ERR_SYSTEMEXCEPTION: - case ERR_PARAMEXCEPTION: - return HttpServletResponse.SC_EXPECTATION_FAILED; - case ERR_TOKENTIMEOUT: - case ERR_REQTIMEOUT: - return HttpServletResponse.SC_REQUEST_TIMEOUT; - case ERR_UNTRUSTTOKEN: - case ERR_UNTRUSTHOST: - case ERR_LOGOUT: - return HttpServletResponse.SC_UNAUTHORIZED; - case ERR_MISSAUTHHEAD: - case ERR_PARAMS: - case ERR_INPUTFORMAT: - case ERR_INPUTMISS: - return HttpServletResponse.SC_BAD_REQUEST; - case ERR_UNSUPPORT: - return HttpServletResponse.SC_METHOD_NOT_ALLOWED; - case ERR_UNKNOWNINTERFACE: - return HttpServletResponse.SC_NOT_FOUND; - default: - return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; - } + return switch (this) { + case ERR_OK -> HttpServletResponse.SC_OK; + case ERR_SYSTEMEXCEPTION, ERR_PARAMEXCEPTION -> HttpServletResponse.SC_EXPECTATION_FAILED; + case ERR_TOKENTIMEOUT, ERR_REQTIMEOUT -> HttpServletResponse.SC_REQUEST_TIMEOUT; + case ERR_UNTRUSTTOKEN, ERR_UNTRUSTHOST, ERR_LOGOUT -> HttpServletResponse.SC_UNAUTHORIZED; + case ERR_MISSAUTHHEAD, ERR_PARAMS, ERR_INPUTFORMAT, ERR_INPUTMISS -> HttpServletResponse.SC_BAD_REQUEST; + case ERR_UNSUPPORT -> HttpServletResponse.SC_METHOD_NOT_ALLOWED; + case ERR_UNKNOWNINTERFACE -> HttpServletResponse.SC_NOT_FOUND; + default -> HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + }; } /** diff --git a/src/main/java/com/cmhi/gds/exception/GlobalExceptionHandler.java b/src/main/java/com/cmhi/gds/exception/GlobalExceptionHandler.java index 4171558..2669cf9 100644 --- a/src/main/java/com/cmhi/gds/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/cmhi/gds/exception/GlobalExceptionHandler.java @@ -66,9 +66,10 @@ public class GlobalExceptionHandler { } sb.append("]"); - log.error("Interface [{}] request <{}> from {}, token = <{}>\n" + - "+++ Request: {}\n" + - "--- Verify params failed: {}", + log.error(""" + Interface [{}] request <{}> from {}, token = <{}> + +++ Request: {} + --- Verify params failed: {}""", reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), sb); } catch (Exception ignored) { } @@ -112,9 +113,10 @@ public class GlobalExceptionHandler { if (reqToken != null && !reqToken.isEmpty()) { reqToken = reqToken.replace(ConstValue.STRING_HTTP_AUTH_HEAD, ""); } - log.error("Interface [{}] request <{}> from {}, token = <{}>\n" + - "+++ Request: {}\n" + - "--- Verify params failed: {}", + log.error(""" + Interface [{}] request <{}> from {}, token = <{}> + +++ Request: {} + --- Verify params failed: {}""", reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), ex.getMessage() == null ? ex.getDescription() : ex.getMessage()); } catch (Exception ignored) { @@ -161,9 +163,10 @@ public class GlobalExceptionHandler { if (reqToken != null && !reqToken.isEmpty()) { reqToken = reqToken.replace(ConstValue.STRING_HTTP_AUTH_HEAD, ""); } - log.error("Interface [{}] request <{}> from {}, token = <{}>\n" + - "+++ Request: {}\n" + - "--- Verify params failed: {}", + log.error(""" + Interface [{}] request <{}> from {}, token = <{}> + +++ Request: {} + --- Verify params failed: {}""", reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), ex.getMessage()); } catch (Exception ignored) { @@ -202,7 +205,7 @@ public class GlobalExceptionHandler { errMeg.add(ErrorCode.ERR_PARAMEXCEPTION.getMsg()); } - if (ex.getMessage() != null && ex.getMessage().length() > 0) { + if (ex.getMessage() != null && !ex.getMessage().isEmpty()) { errMeg.add(ex.getMessage()); } diff --git a/src/main/java/com/cmhi/gds/manager/GameDatabaseServiceManager.java b/src/main/java/com/cmhi/gds/manager/GameDatabaseServiceManager.java index a2e03dd..90b9376 100644 --- a/src/main/java/com/cmhi/gds/manager/GameDatabaseServiceManager.java +++ b/src/main/java/com/cmhi/gds/manager/GameDatabaseServiceManager.java @@ -1,7 +1,5 @@ package com.cmhi.gds.manager; -import com.cmhi.gds.pojo.entry.GameInfo; -import com.cmhi.gds.pojo.entry.GameTable; import com.cmhi.gds.pojo.entry.GameTableSummary; import java.util.List; diff --git a/src/main/java/com/cmhi/gds/pojo/dto/protocol/info/GameListSummary.java b/src/main/java/com/cmhi/gds/pojo/dto/protocol/info/GameListSummary.java index 6a1de1b..c7f0be7 100644 --- a/src/main/java/com/cmhi/gds/pojo/dto/protocol/info/GameListSummary.java +++ b/src/main/java/com/cmhi/gds/pojo/dto/protocol/info/GameListSummary.java @@ -1,6 +1,5 @@ package com.cmhi.gds.pojo.dto.protocol.info; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import lombok.AllArgsConstructor; import lombok.Builder;