<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                common ``` /** * 錯誤code 和提示 */ public enum BizCodeEnum { // 10 開頭是通用錯誤 start UNKNOWN_EXCEPTION(10000, "系統未知異常"), VALID_EXCEPTION(10001, "參數校驗未通過"); // 10 開頭是通用錯誤 end private int code; private String msg; BizCodeEnum(int code, String msg) { this.code = code; this.msg = msg; } public int getCode() { return code; } public String getMsg() { return msg; } } ``` 具體項目 ``` /** * 統一異常處理類 * basePackages => 只捕獲這個路徑下的異常, 改成自己的 * 中間使用 ** 或 * 的通配符都沒起效果 */ @Slf4j @RestControllerAdvice(basePackages = "com.product.controller") public class ExceptionControllerAdvice { @ExceptionHandler(value = Exception.class) public R handleException(Exception e) { log.error("服務器錯誤{},異常類型:{}", e.getMessage(), e.getClass()); return R.error(BizCodeEnum.UNKNOWN_EXCEPTION.getCode(), BizCodeEnum.UNKNOWN_EXCEPTION.getMsg()); } // 數據校驗 @ExceptionHandler(value = MethodArgumentNotValidException.class) public R handleValidException(MethodArgumentNotValidException e) { log.error("數據校驗未通過{},異常類型:{}", e.getMessage(), e.getClass()); // controller 層不能在使用 BindingResult BindingResult bindingResult = e.getBindingResult(); Map<String, String> errorMap = Maps.newHashMap(); // 報錯未通過的錯誤項, 返回給前端 bindingResult.getFieldErrors().forEach(fieldError -> { errorMap.put(fieldError.getField(), fieldError.getDefaultMessage()); }); return R.error(BizCodeEnum.VALID_EXCEPTION.getCode(), BizCodeEnum.VALID_EXCEPTION.getMsg()) .put("data", errorMap); } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看