From ac94ec6d2a44bb55ec63c7958b5274d17b040df3 Mon Sep 17 00:00:00 2001 From: chenbowen Date: Thu, 17 Jul 2025 15:04:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=8F=AA=E5=85=B3=E8=81=94=E4=B8=80=E4=B8=AA=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E6=94=B9=E4=B8=9A=E5=8A=A1=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit d17fa356ba68ed6c350b6b9e244f980b8fdbc62b) --- sql/dm/新增用户与组织关系表并迁移.sql | 2 +- .../config/YudaoBusinessAutoConfiguration.java | 2 +- .../interceptor/BusinessHeaderInterceptor.java | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sql/dm/新增用户与组织关系表并迁移.sql b/sql/dm/新增用户与组织关系表并迁移.sql index 62efc891..e4747ce0 100644 --- a/sql/dm/新增用户与组织关系表并迁移.sql +++ b/sql/dm/新增用户与组织关系表并迁移.sql @@ -1,5 +1,5 @@ create table "RUOYI-VUE-PRO".SYSTEM_USER_DEPT ( - ID BIGINT primary key, -- 自增主键 + ID BIGINT primary key, USER_ID BIGINT not null, DEPT_ID BIGINT not null, TENANT_ID BIGINT default 0 not null, diff --git a/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/config/YudaoBusinessAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/config/YudaoBusinessAutoConfiguration.java index 714ca87b..05996ef1 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/config/YudaoBusinessAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/config/YudaoBusinessAutoConfiguration.java @@ -15,6 +15,6 @@ public class YudaoBusinessAutoConfiguration implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { // 只拦截增删改和 set 相关的 url registry.addInterceptor(new BusinessHeaderInterceptor()) - .addPathPatterns("/**/add**", "/**/create**", "/**/update**", "/**/edit**", "/**/delete**", "/**/remove**", "/**/set**"); + .addPathPatterns("/**/add**", "/**/create**", "/**/update**", "/**/edit**", "/**/set**"); } } diff --git a/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/interceptor/BusinessHeaderInterceptor.java b/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/interceptor/BusinessHeaderInterceptor.java index 33714ada..e7f79394 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/interceptor/BusinessHeaderInterceptor.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-business/src/main/java/cn/iocoder/yudao/framework/business/interceptor/BusinessHeaderInterceptor.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.framework.business.interceptor; -import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -8,7 +7,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResultCodeEnum; import cn.iocoder.yudao.framework.common.pojo.CompanyDeptInfo; import cn.iocoder.yudao.framework.security.core.LoginUser; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.core.type.TypeReference; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; @@ -17,7 +15,10 @@ import org.springframework.lang.NonNull; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.singleton; @@ -82,11 +83,8 @@ public class BusinessHeaderInterceptor implements HandlerInterceptor { // 2. 没有公司信息,尝试唯一性自动推断 // 如果当前用户下只有一个公司和部门的对于关系 if (companyDeptSet.size() == 1) { - CompanyDeptInfo info = new CompanyDeptInfo(); CompanyDeptInfo companyDeptInfo = companyDeptSet.iterator().next(); - info.setCompanyId(companyDeptInfo.getCompanyId()); - info.setDeptId(companyDeptInfo.getDeptId()); - return writeResponse(response, HttpStatus.OK.value(), CommonResult.success(singleton(info)), objectMapper); + return writeResponse(response, HttpStatus.OK.value(), CommonResult.customize(singleton(companyDeptInfo),CommonResultCodeEnum.NEED_ADJUST), objectMapper); } else { return writeResponse(response, HttpStatus.OK.value(), CommonResult.customize(companyDeptSet,CommonResultCodeEnum.NEED_ADJUST), objectMapper); }