OCT 1. 修正代码规范问题

This commit is contained in:
黄昕 2023-10-26 15:47:36 +08:00
parent 517a9a70dc
commit 3a65ae27ad
5 changed files with 28 additions and 38 deletions

View File

@ -132,6 +132,11 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>

View File

@ -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;
};
}
/**

View File

@ -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());
}

View File

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

View File

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