diff --git a/src/main/kotlin/com/pomelotea/hoperun/sign/api/HoperunDakaController.kt b/src/main/kotlin/com/pomelotea/hoperun/sign/api/HoperunDakaController.kt index d3cfa71..7bd3da0 100644 --- a/src/main/kotlin/com/pomelotea/hoperun/sign/api/HoperunDakaController.kt +++ b/src/main/kotlin/com/pomelotea/hoperun/sign/api/HoperunDakaController.kt @@ -276,6 +276,9 @@ class HoperunSignController( if (lastDakaInfo.getString("actual_area_end") != null) { val area: String = lastDakaInfo.getString("actual_area_end") userConfig.device = area.substring(area.lastIndexOf("Qing") + 13) + } else if (lastDakaInfo.getString("actual_area_begin") != null) { + val area: String = lastDakaInfo.getString("actual_area_begin") + userConfig.device = area.substring(area.lastIndexOf("Qing") + 13) } else { userConfig.device = null } diff --git a/src/main/kotlin/com/pomelotea/hoperun/sign/error/ExtendExceptionHandler.kt b/src/main/kotlin/com/pomelotea/hoperun/sign/error/ExtendExceptionHandler.kt index 9238f37..fd22907 100644 --- a/src/main/kotlin/com/pomelotea/hoperun/sign/error/ExtendExceptionHandler.kt +++ b/src/main/kotlin/com/pomelotea/hoperun/sign/error/ExtendExceptionHandler.kt @@ -11,15 +11,9 @@ import org.springframework.core.annotation.Order import org.springframework.http.HttpStatus import org.springframework.validation.BindException import org.springframework.web.bind.MethodArgumentNotValidException -import org.springframework.web.bind.annotation.ControllerAdvice -import org.springframework.web.bind.annotation.ExceptionHandler -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.ResponseBody -import org.springframework.web.bind.annotation.ResponseStatus +import org.springframework.web.bind.annotation.* import org.springframework.web.client.HttpServerErrorException import org.springframework.web.servlet.NoHandlerFoundException -import org.springframework.web.servlet.view.RedirectView import java.net.InetAddress import java.net.UnknownHostException import java.text.MessageFormat @@ -178,7 +172,6 @@ open class ExtendExceptionHandler(errorAttributes: ErrorAttributes) : AbstractEr /** * 请求校验缺少必要参数 - * @param request HttpServletRequest 请求 * @param response HttpServletResponse 响应 * @param ex Exception 服务异常 * @throws Exception 方法抛出异常 @@ -186,7 +179,7 @@ open class ExtendExceptionHandler(errorAttributes: ErrorAttributes) : AbstractEr @ResponseStatus(code = HttpStatus.BAD_REQUEST) @ExceptionHandler(MethodArgumentNotValidException::class) @Throws(Exception::class) - fun methodArgumentNotValidException(request: HttpServletRequest, response: HttpServletResponse, ex: MethodArgumentNotValidException) { + fun methodArgumentNotValidException(response: HttpServletResponse, ex: MethodArgumentNotValidException) { val msg = StringBuilder() ex.bindingResult.fieldErrors.forEach { msg.append( @@ -204,7 +197,6 @@ open class ExtendExceptionHandler(errorAttributes: ErrorAttributes) : AbstractEr /** * 参数绑定请求实体错误 - * @param request HttpServletRequest 请求 * @param response HttpServletResponse 响应 * @param ex Exception 服务异常 * @throws Exception 方法抛出异常 @@ -212,7 +204,7 @@ open class ExtendExceptionHandler(errorAttributes: ErrorAttributes) : AbstractEr @ResponseStatus(code = HttpStatus.BAD_REQUEST) @ExceptionHandler(BindException::class) @Throws(Exception::class) - fun bindException(request: HttpServletRequest, response: HttpServletResponse, ex: BindException) { + fun bindException(response: HttpServletResponse, ex: BindException) { val msg = StringBuilder() ex.bindingResult.fieldErrors.forEach { msg.append( @@ -250,8 +242,8 @@ open class ExtendExceptionHandler(errorAttributes: ErrorAttributes) : AbstractEr @ResponseStatus(code = HttpStatus.NOT_FOUND) @RequestMapping(produces = ["text/html"]) @Throws(Exception::class) - fun handleHtml(request: HttpServletRequest, response: HttpServletResponse): RedirectView { - return RedirectView("/404") + fun handleHtml(response: HttpServletResponse) { + response.sendRedirect("/404.html") } @@ -292,13 +284,13 @@ open class ExtendExceptionHandler(errorAttributes: ErrorAttributes) : AbstractEr var ipAddress: String? return try { ipAddress = request.getHeader("x-forwarded-for") - if (ipAddress == null || ipAddress.length == 0 || "unknown".equals(ipAddress, ignoreCase = true)) { + if (ipAddress.isNullOrEmpty() || "unknown".equals(ipAddress, ignoreCase = true)) { ipAddress = request.getHeader("Proxy-Client-IP") } - if (ipAddress == null || ipAddress.length == 0 || "unknown".equals(ipAddress, ignoreCase = true)) { + if (ipAddress.isNullOrEmpty() || "unknown".equals(ipAddress, ignoreCase = true)) { ipAddress = request.getHeader("WL-Proxy-Client-IP") } - if (ipAddress == null || ipAddress.length == 0 || "unknown".equals(ipAddress, ignoreCase = true)) { + if (ipAddress.isNullOrEmpty() || "unknown".equals(ipAddress, ignoreCase = true)) { ipAddress = request.remoteAddr // 本机访问, 获取网卡地址 if (ipAddress == "127.0.0.1" || ipAddress == "0:0:0:0:0:0:0:1") { diff --git a/src/main/resources/static/404.html b/src/main/resources/static/404.html new file mode 100644 index 0000000..2887e36 --- /dev/null +++ b/src/main/resources/static/404.html @@ -0,0 +1,56 @@ + + + + 404 Not Found + + + + + + +
+
+
+

+ 非常抱歉,您访 +
+ 问的页面不存在 +

+ 返回首页 +
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/static/img/airplane-404page.jpg b/src/main/resources/static/img/airplane-404page.jpg new file mode 100644 index 0000000..d77950a Binary files /dev/null and b/src/main/resources/static/img/airplane-404page.jpg differ