diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationSwitchRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationSwitchRequest.java new file mode 100644 index 0000000000..147d63b513 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/OrganizationSwitchRequest.java @@ -0,0 +1,17 @@ +package io.metersphere.system.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Data +public class OrganizationSwitchRequest { + @Schema(description = "组织ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{organization.id.not_blank}") + @Size(min = 1, max = 50, message = "{organization.id.length_range}") + private String organizationId; + @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user.id.not_blank}") + private String userId; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java index d460c8d134..ebf8f0af71 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.java @@ -1,11 +1,11 @@ package io.metersphere.system.mapper; -import io.metersphere.system.dto.sdk.OptionDTO; -import io.metersphere.system.dto.user.UserExtendDTO; import io.metersphere.system.domain.User; import io.metersphere.system.dto.*; import io.metersphere.system.dto.request.OrganizationDeleteRequest; import io.metersphere.system.dto.request.OrganizationRequest; +import io.metersphere.system.dto.sdk.OptionDTO; +import io.metersphere.system.dto.user.UserExtendDTO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -107,4 +107,11 @@ public interface ExtOrganizationMapper { * @return 组织下拉选项 */ List getOptionsByIds(@Param("ids") List ids); + + /** + * 获取用户关联组织ID + * @param userId 用户ID + * @return 用户ID集合 + */ + List getRelatedOrganizationIds(@Param("userId") String userId); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml index 163d5c5a62..74bfd71e90 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtOrganizationMapper.xml @@ -131,6 +131,12 @@ + +