From 41514100e0e79329dbecb1b9788ce70687343603 Mon Sep 17 00:00:00 2001
From: YunaiV <>
Date: Sat, 4 Jul 2020 21:08:37 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20mall-spring-boot-starter-swagger=20?=
=?UTF-8?q?=E6=8E=A5=E5=85=A5=E5=88=B0=20management-web-app=20=E4=B8=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/cn/iocoder/mall/swagger/package-info.java | 3 +++
.../web/core/interceptor/AccessLogInterceptor.java | 10 ++++++----
management-web-app/pom.xml | 5 +++++
management-web-app/src/main/resources/application.yml | 7 +++++++
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/common/mall-spring-boot-starter-swagger/src/main/java/cn/iocoder/mall/swagger/package-info.java b/common/mall-spring-boot-starter-swagger/src/main/java/cn/iocoder/mall/swagger/package-info.java
index ed87ff7e7..e30eadecd 100644
--- a/common/mall-spring-boot-starter-swagger/src/main/java/cn/iocoder/mall/swagger/package-info.java
+++ b/common/mall-spring-boot-starter-swagger/src/main/java/cn/iocoder/mall/swagger/package-info.java
@@ -1 +1,4 @@
+/**
+ * 无情的占位类
+ */
package cn.iocoder.mall.swagger;
diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java
index 27d493786..0a7632cb0 100644
--- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java
+++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java
@@ -13,7 +13,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
-import org.springframework.util.Assert;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
@@ -60,9 +59,12 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter {
accessLog.setUserType(CommonWebUtil.getUserType(request));
// 设置访问结果
CommonResult result = CommonWebUtil.getCommonResult(request);
- Assert.isTrue(result != null, "result 必须非空");
- accessLog.setErrorCode(result.getCode())
- .setErrorMessage(result.getMessage());
+ if (result != null) {
+ accessLog.setErrorCode(result.getCode()).setErrorMessage(result.getMessage());
+ } else {
+ // 在访问非 onemall 系统提供的 API 时,会存在没有 CommonResult 的情况。例如说,Swagger 提供的接口
+ accessLog.setErrorCode(0).setErrorMessage("");
+ }
// 设置其它字段
accessLog.setTraceId(MallUtils.getTraceId())
.setApplicationName(applicationName)
diff --git a/management-web-app/pom.xml b/management-web-app/pom.xml
index 7a90b5adf..abd0dce9a 100644
--- a/management-web-app/pom.xml
+++ b/management-web-app/pom.xml
@@ -32,6 +32,11 @@
mall-spring-boot-starter-web
+
+ cn.iocoder.mall
+ mall-spring-boot-starter-swagger
+
+
com.alibaba.cloud
diff --git a/management-web-app/src/main/resources/application.yml b/management-web-app/src/main/resources/application.yml
index f39a264ba..73fba9f2c 100644
--- a/management-web-app/src/main/resources/application.yml
+++ b/management-web-app/src/main/resources/application.yml
@@ -30,3 +30,10 @@ dubbo:
version: 1.0.0
SystemLogRPC:
version: 1.0.0
+
+# Swagger 配置项
+swagger:
+ title: 管理后台
+ description: 提供管理员管理的所有功能
+ version: 1.0.0
+ base-package: cn.iocoder.mall.managementweb.controller