diff --git a/frontend/src/api/organization/index.ts b/frontend/src/api/organization/index.ts
index ef281512..1af2f165 100644
--- a/frontend/src/api/organization/index.ts
+++ b/frontend/src/api/organization/index.ts
@@ -92,6 +92,7 @@ export interface SearchableOrganizationItem {
description: string
avatar?: string
member_count: number
+ member_limit: number // 0 = unlimited
share_count: number
is_already_member: boolean
require_approval: boolean
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index 540f4175..074cd363 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -2373,9 +2373,12 @@ export default {
byInviteCode: 'Enter invite code',
searchSpaces: 'Search spaces',
searchSpacesDesc: 'Browse or search spaces that are open for discovery; join without an invite code',
- searchSpacesPlaceholder: 'Search by space name or description',
+ searchSpacesPlaceholder: 'Search by space name, description or space ID',
+ spaceId: 'Space ID',
noSearchResult: 'No matching spaces',
noSearchableSpaces: 'No discoverable spaces yet, or try a search',
+ membersWithLimit: '{current}/{limit} members',
+ memberLimitReached: 'Full',
},
invite: {
loading: 'Loading...',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index e13980c0..5e2bcf9f 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -2378,9 +2378,12 @@ export default {
byInviteCode: "输入邀请码",
searchSpaces: "搜索空间",
searchSpacesDesc: "浏览或搜索已开放可被搜索的空间,无需邀请码即可加入",
- searchSpacesPlaceholder: "按空间名称或描述搜索",
+ searchSpacesPlaceholder: "按空间名称、描述或空间ID搜索",
+ spaceId: "空间ID",
noSearchResult: "未找到匹配的空间",
noSearchableSpaces: "暂无开放可被搜索的空间,或输入关键词搜索",
+ membersWithLimit: "{current}/{limit} 成员",
+ memberLimitReached: "成员已满",
},
invite: {
loading: "加载中...",
diff --git a/frontend/src/views/organization/OrganizationList.vue b/frontend/src/views/organization/OrganizationList.vue
index 6acdb0f5..8d132810 100644
--- a/frontend/src/views/organization/OrganizationList.vue
+++ b/frontend/src/views/organization/OrganizationList.vue
@@ -239,7 +239,7 @@
{{ $t('organization.join.searchSpaces') }}
@@ -309,45 +309,53 @@
- {{ searchQuery ? $t('organization.join.noSearchResult') : $t('organization.join.noSearchableSpaces') }}
+
+
+ {{ searchQuery ? $t('organization.join.noSearchResult') : $t('organization.join.noSearchableSpaces') }}
+
-
-
-
-
-
+
+
+
+
+
{{ org.name }}
-
{{ org.description || $t('organization.noDescription') }}
-
- {{ org.member_count }} {{ $t('organization.invite.members') }}
- {{ org.share_count }} {{ $t('organization.invite.knowledgeBases') }}
-
- {{ $t('organization.invite.needApproval') }}
-
-
+
+
+ {{ $t('organization.join.membersWithLimit', { current: org.member_count, limit: org.member_limit }) }}
+
+
+ {{ org.member_count }} {{ $t('organization.invite.members') }}
+
+ · {{ org.share_count }} {{ $t('organization.invite.knowledgeBases') }}
+ {{ $t('organization.invite.needApproval') }}
+ {{ $t('organization.join.memberLimitReached') }}
+
+
{{ org.description || $t('organization.noDescription') }}
- {{ $t('organization.invite.viewOrganization') }}
+ {{ $t('organization.join.memberLimitReached') }}
@@ -373,50 +381,38 @@
{{ $t('organization.invite.loading') }}
-
+
-
+
{{ invitePreviewData.name }}
+
{{ $t('organization.join.spaceId') }}: {{ invitePreviewData.id }}
+
+ {{ invitePreviewData.member_count }} {{ $t('organization.invite.members') }} · {{ invitePreviewData.share_count }} {{ $t('organization.invite.knowledgeBases') }}
+
{{ invitePreviewData.description || $t('organization.noDescription') }}
-
-
-
-
- {{ invitePreviewData.member_count }}
- {{ $t('organization.invite.members') }}
-
-
-
- {{ invitePreviewData.share_count }}
- {{ $t('organization.invite.knowledgeBases') }}
-
-
-
-
+
-
-
{{ $t('organization.invite.approvalLabel') }}
-
+
+ {{ $t('organization.invite.approvalLabel') }}
+
{{ invitePreviewData.require_approval ? $t('organization.invite.needApproval') : $t('organization.invite.noApproval') }}
-
-
-
{{ $t('organization.invite.defaultRoleAfterJoin', { role: $t('organization.role.viewer') }) }}
+
+ {{ $t('organization.invite.defaultRoleAfterJoin', { role: $t('organization.role.viewer') }) }}
-
-
-
{{ $t('organization.invite.requireApprovalTip') }}
+
+ {{ $t('organization.invite.requireApprovalTip') }}
@@ -443,9 +439,9 @@
-
-
-
{{ $t('organization.invite.alreadyMember') }}
+
+
+ {{ $t('organization.invite.alreadyMember') }}
@@ -533,6 +529,9 @@ const searchQuery = ref('')
const searchableList = ref
([])
const searchLoading = ref(false)
let searchDebounceTimer: ReturnType | null = null
+// 搜索结果缓存:避免重复点击时重复请求导致高度跳动
+const searchCache = ref<{ query: string; data: SearchableOrganizationItem[]; timestamp: number } | null>(null)
+const CACHE_DURATION = 5 * 60 * 1000 // 缓存5分钟
// Tab 内容容器 ref,用于高度过渡
const tabContentWrapperRef = ref(null)
@@ -596,6 +595,7 @@ const handleOrganizationDialogEvent = ((event: CustomEvent<{ type: 'create' | 'j
joinStep.value = 'invite'
searchQuery.value = ''
searchableList.value = []
+ // 注意:不清空缓存,保留搜索结果以便下次快速显示
showInvitePreview.value = true
}
}) as EventListener
@@ -838,23 +838,66 @@ function closeInvitePreview() {
joinStep.value = 'invite'
searchQuery.value = ''
searchableList.value = []
+ // 注意:不清空缓存,保留搜索结果以便下次快速显示
inviteRequestRole.value = 'viewer'
inviteRequestMessage.value = ''
router.replace({ path: route.path, query: {} })
}
+// 处理搜索标签点击:如果有缓存,先显示缓存,避免高度跳动
+function handleSearchTabClick() {
+ joinStep.value = 'search'
+
+ // 检查是否有有效的缓存
+ const currentQuery = searchQuery.value.trim()
+ if (searchCache.value &&
+ searchCache.value.query === currentQuery &&
+ Date.now() - searchCache.value.timestamp < CACHE_DURATION) {
+ // 先显示缓存结果(已过滤已加入空间),避免高度跳动
+ searchableList.value = searchCache.value.data
+ // 然后在后台刷新(可选,如果需要最新数据)
+ // doSearchSearchable()
+ } else {
+ // 没有缓存或缓存过期,执行搜索
+ doSearchSearchable()
+ }
+}
+
// 搜索可加入空间
async function doSearchSearchable() {
+ const currentQuery = searchQuery.value.trim()
+
+ // 检查缓存
+ if (searchCache.value &&
+ searchCache.value.query === currentQuery &&
+ Date.now() - searchCache.value.timestamp < CACHE_DURATION) {
+ // 使用缓存(已是过滤后的列表),不重新请求
+ searchableList.value = searchCache.value.data
+ return
+ }
+
searchLoading.value = true
try {
- const res = await searchSearchableOrganizations(searchQuery.value.trim(), 20)
+ const res = await searchSearchableOrganizations(currentQuery, 20)
if (res.success && res.data) {
- searchableList.value = res.data.data || []
+ const raw = res.data.data || []
+ // 不展示已加入的空间
+ const data = raw.filter((org: SearchableOrganizationItem) => !org.is_already_member)
+ searchableList.value = data
+ // 更新缓存(存过滤后的列表)
+ searchCache.value = {
+ query: currentQuery,
+ data: data,
+ timestamp: Date.now()
+ }
} else {
searchableList.value = []
+ // 清空缓存
+ searchCache.value = null
}
} catch (e) {
searchableList.value = []
+ searchCache.value = null
} finally {
searchLoading.value = false
}
@@ -865,6 +908,11 @@ function doSearchSearchableDebounced() {
searchDebounceTimer = setTimeout(() => doSearchSearchable(), 300)
}
+// 空间是否已满(超过成员上限无法加入)
+function isOrgFull(org: SearchableOrganizationItem): boolean {
+ return org.member_limit > 0 && org.member_count >= org.member_limit
+}
+
// 预览搜索到的空间(转换为预览格式)
function previewSearchableOrg(org: SearchableOrganizationItem) {
// 将 SearchableOrganizationItem 转换为 OrganizationPreview 格式
@@ -883,22 +931,16 @@ function previewSearchableOrg(org: SearchableOrganizationItem) {
inviteCode.value = ''
}
-// 查看搜索到的空间(已是成员时,打开空间设置)
+// 查看搜索到的空间(已是成员时,打开空间设置;不关闭加入弹窗,关闭设置后仍回到搜索)
function viewSearchableOrg(org: SearchableOrganizationItem) {
- // 关闭加入弹框
- closeInvitePreview()
- // 打开空间设置弹框
settingsOrgId.value = org.id
settingsMode.value = 'edit'
showSettingsModal.value = true
}
-// 从预览弹框中查看空间(已是成员时)
+// 从预览弹框中查看空间(已是成员时;不关闭加入弹窗,关闭设置后仍回到搜索)
function viewOrganizationFromPreview() {
if (!invitePreviewData.value) return
- // 关闭加入弹框
- closeInvitePreview()
- // 打开空间设置弹框
settingsOrgId.value = invitePreviewData.value.id
settingsMode.value = 'edit'
showSettingsModal.value = true
@@ -1618,12 +1660,9 @@ onUnmounted(() => {
max-width: 480px;
max-height: 90vh;
background: #ffffff;
- border-radius: 16px;
- box-shadow:
- 0 0 0 1px rgba(0, 0, 0, 0.04),
- 0 4px 6px -1px rgba(15, 23, 42, 0.06),
- 0 12px 24px -4px rgba(15, 23, 42, 0.1),
- 0 24px 48px -8px rgba(15, 23, 42, 0.12);
+ border-radius: 12px;
+ border: 1px solid #e2e8f0;
+ box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
overflow: hidden;
display: flex;
flex-direction: column;
@@ -1633,9 +1672,9 @@ onUnmounted(() => {
display: flex;
align-items: center;
justify-content: space-between;
- padding: 28px 24px 20px;
- background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
- border-bottom: 1px solid rgba(0, 0, 0, 0.06);
+ padding: 20px 52px 20px 24px; /* 右侧为关闭按钮留空 */
+ background: #ffffff;
+ border-bottom: 1px solid #e2e8f0;
flex-shrink: 0;
}
@@ -1650,29 +1689,28 @@ onUnmounted(() => {
.invite-preview-close {
position: absolute;
- top: 20px;
- right: 20px;
- width: 36px;
- height: 36px;
+ top: 16px;
+ right: 16px;
+ width: 32px;
+ height: 32px;
border: none;
- background: rgba(0, 0, 0, 0.04);
- border-radius: 10px;
+ background: transparent;
+ border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: #64748b;
- transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
+ transition: background 0.2s ease, color 0.2s ease;
z-index: 10;
&:hover {
- background: rgba(0, 0, 0, 0.08);
+ background: #f1f5f9;
color: #0f172a;
- transform: scale(1.02);
}
&:active {
- transform: scale(0.98);
+ background: #e2e8f0;
}
}
@@ -1709,7 +1747,7 @@ onUnmounted(() => {
gap: 32px;
margin-bottom: 24px;
padding-bottom: 4px;
- border-bottom: 1px solid rgba(0, 0, 0, 0.08);
+ border-bottom: 1px solid #e2e8f0;
.join-tab {
padding: 10px 0;
@@ -1760,12 +1798,13 @@ onUnmounted(() => {
.searchable-list-wrap {
max-height: 320px;
+ min-height: 120px; /* 设置最小高度,避免高度跳动 */
overflow-y: auto;
margin-bottom: 20px;
- border: 1px solid rgba(0, 0, 0, 0.06);
+ border: 1px solid #e2e8f0;
border-radius: 12px;
- background: #f8fafc;
- box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
+ background: #ffffff;
+ box-shadow: none;
&::-webkit-scrollbar {
width: 6px;
@@ -1788,108 +1827,133 @@ onUnmounted(() => {
}
.searchable-empty {
- padding: 48px 20px;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 32px 20px;
+ min-height: 120px;
text-align: center;
- color: #64748b;
- font-size: 14px;
- font-family: "PingFang SC", -apple-system, sans-serif;
- line-height: 1.5;
+
+ .searchable-empty-icon {
+ font-size: 32px;
+ color: #cbd5e1;
+ margin-bottom: 12px;
+ opacity: 0.6;
+ }
+
+ .searchable-empty-text {
+ margin: 0;
+ color: #94a3b8;
+ font-size: 13px;
+ font-family: "PingFang SC", -apple-system, sans-serif;
+ line-height: 1.5;
+ max-width: 280px;
+ }
}
.searchable-list {
display: flex;
flex-direction: column;
gap: 0;
- padding: 4px;
+ padding: 0;
.searchable-item {
display: flex;
align-items: center;
- justify-content: space-between;
- gap: 14px;
- padding: 14px 16px;
- margin-bottom: 4px;
- border-radius: 10px;
- background: #fff;
- border: 1px solid transparent;
- transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
+ gap: 12px;
+ padding: 10px 12px;
+ border-bottom: 1px solid #e2e8f0;
+ background: #ffffff;
+ transition: background 0.15s ease;
cursor: pointer;
&:last-child {
- margin-bottom: 0;
+ border-bottom: none;
}
- &:hover:not(.is-already-member) {
- background: #fff;
- border-color: rgba(7, 192, 95, 0.2);
- box-shadow: 0 2px 8px rgba(7, 192, 95, 0.06);
+ &:hover:not(.is-full) {
+ background: #f0fdf4;
}
- &.is-already-member {
+ &.is-full {
cursor: default;
- opacity: 0.75;
- background: #f8fafc;
- }
+ opacity: 0.85;
- .searchable-item-left {
- display: flex;
- align-items: center;
- gap: 14px;
- flex: 1;
- min-width: 0;
+ .searchable-item-name {
+ color: #64748b;
+ }
}
.searchable-item-avatar {
flex-shrink: 0;
}
- .searchable-item-info {
+ .searchable-item-main {
flex: 1;
min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
- .searchable-item-name {
- display: block;
- font-size: 14px;
- font-weight: 600;
- color: #0f172a;
- margin-bottom: 4px;
- font-family: "PingFang SC", -apple-system, sans-serif;
+ .searchable-item-row1 {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ }
+
+ .searchable-item-name {
+ font-size: 14px;
+ font-weight: 500;
+ color: #0f172a;
+ font-family: "PingFang SC", -apple-system, sans-serif;
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .searchable-item-meta {
+ font-size: 12px;
+ color: #94a3b8;
+ font-family: "PingFang SC", -apple-system, sans-serif;
+ flex-shrink: 0;
+ white-space: nowrap;
+
+ .searchable-item-approval {
+ margin-left: 4px;
+ color: #d97706;
}
- .searchable-item-desc {
- display: block;
- font-size: 13px;
- color: #64748b;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- margin-bottom: 8px;
- font-family: "PingFang SC", -apple-system, sans-serif;
+ .searchable-item-full {
+ margin-left: 4px;
+ color: #94a3b8;
}
+ }
- .searchable-item-badges {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-wrap: wrap;
-
- .badge {
- font-size: 12px;
- color: #64748b;
- font-family: "PingFang SC", -apple-system, sans-serif;
- padding: 2px 8px;
- background: rgba(0, 0, 0, 0.04);
- border-radius: 6px;
- }
-
- .approval-tag {
- flex-shrink: 0;
- }
- }
+ .searchable-item-desc {
+ font-size: 12px;
+ color: #64748b;
+ margin: 0;
+ line-height: 1.45;
+ font-family: "PingFang SC", -apple-system, sans-serif;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ line-clamp: 2;
+ overflow: hidden;
}
.searchable-item-action {
flex-shrink: 0;
+
+ .t-button {
+ padding: 4px 8px;
+ font-size: 12px;
+ }
}
}
}
@@ -1973,26 +2037,22 @@ onUnmounted(() => {
}
}
-// 预览内容区域 - 空间信息卡片
+// 预览内容区域 - 版式与组织列表一致
.invite-preview-body-preview {
- padding-top: 20px;
+ padding: 24px 24px 0;
}
.invite-preview-org {
display: flex;
align-items: flex-start;
- gap: 18px;
- margin-bottom: 24px;
- padding: 20px;
- background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
- border: 1px solid rgba(0, 0, 0, 0.05);
- border-radius: 14px;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
+ gap: 16px;
+ padding-bottom: 20px;
+ margin-bottom: 20px;
+ border-bottom: 1px solid #e2e8f0;
}
.invite-preview-org-icon {
flex-shrink: 0;
- filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));
}
.invite-preview-org-info {
@@ -2001,142 +2061,98 @@ onUnmounted(() => {
}
.invite-preview-org-name {
- font-size: 17px;
+ font-size: 18px;
font-weight: 600;
color: #0f172a;
- margin: 0 0 8px;
+ margin: 0 0 6px;
font-family: "PingFang SC", -apple-system, sans-serif;
line-height: 1.3;
- letter-spacing: -0.02em;
+}
+
+.invite-preview-org-id {
+ font-size: 12px;
+ color: #94a3b8;
+ margin: 0 0 6px;
+ font-family: "PingFang SC", -apple-system, sans-serif;
+ word-break: break-all;
}
.invite-preview-org-desc {
font-size: 14px;
color: #64748b;
+ margin: 0 0 8px;
+ line-height: 1.5;
+ font-family: "PingFang SC", -apple-system, sans-serif;
+}
+
+.invite-preview-org-meta {
+ font-size: 13px;
+ color: #94a3b8;
margin: 0;
- line-height: 1.55;
font-family: "PingFang SC", -apple-system, sans-serif;
}
-.invite-preview-stats {
- display: flex;
- gap: 16px;
- margin-bottom: 24px;
- padding: 18px 0 22px;
- border-bottom: 1px solid rgba(0, 0, 0, 0.06);
-}
-
-.invite-preview-stat {
- display: flex;
- align-items: center;
- gap: 10px;
- padding: 10px 16px;
- background: rgba(7, 192, 95, 0.06);
- border: 1px solid rgba(7, 192, 95, 0.12);
- border-radius: 10px;
- font-size: 14px;
- color: #0f172a;
- font-family: "PingFang SC", -apple-system, sans-serif;
- transition: background 0.2s ease, border-color 0.2s ease;
-
- &:hover {
- background: rgba(7, 192, 95, 0.08);
- border-color: rgba(7, 192, 95, 0.18);
- }
-
- .invite-preview-stat-icon {
- color: #07c05f;
- font-size: 18px;
- flex-shrink: 0;
- }
-
- .invite-preview-stat-value {
- font-weight: 600;
- color: #0f172a;
- font-size: 15px;
- }
-
- .invite-preview-stat-label {
- color: #64748b;
- font-weight: 500;
- }
-}
-
.invite-preview-join-section,
.invite-preview-status-section {
- margin-top: 24px;
+ margin-top: 0;
+ padding-bottom: 24px;
}
-.invite-preview-approval-row {
+.invite-preview-row {
display: flex;
align-items: center;
- gap: 12px;
- margin-bottom: 18px;
+ gap: 10px;
+ margin-bottom: 12px;
font-size: 14px;
font-family: "PingFang SC", -apple-system, sans-serif;
+}
- .invite-preview-approval-label {
- color: #475569;
- flex-shrink: 0;
- font-weight: 500;
+.invite-preview-label {
+ color: #64748b;
+ flex-shrink: 0;
+}
+
+.invite-preview-value {
+ font-weight: 500;
+
+ &.value-success {
+ color: #059669;
}
- .invite-preview-approval-badge {
- display: inline-flex;
- align-items: center;
- padding: 6px 12px;
- border-radius: 8px;
- font-size: 12px;
- font-weight: 600;
-
- &.need-approval {
- background: rgba(250, 173, 20, 0.12);
- color: #b45309;
- border: 1px solid rgba(250, 173, 20, 0.2);
- }
-
- &.no-approval {
- background: rgba(7, 192, 95, 0.1);
- color: #059669;
- border: 1px solid rgba(7, 192, 95, 0.2);
- }
+ &.value-warning {
+ color: #b45309;
}
}
-.invite-preview-tip {
- display: flex;
- align-items: flex-start;
- gap: 10px;
- padding: 12px 14px;
- border-radius: 10px;
+.invite-preview-note {
+ padding: 10px 12px;
+ background: #f8fafc;
+ border: 1px solid #e2e8f0;
+ border-radius: 8px;
font-size: 13px;
- line-height: 1.55;
+ color: #64748b;
+ line-height: 1.5;
font-family: "PingFang SC", -apple-system, sans-serif;
- margin-bottom: 18px;
- border: 1px solid transparent;
+ margin-bottom: 16px;
- .t-icon {
- flex-shrink: 0;
- margin-top: 1px;
+ &.invite-preview-note-warning {
+ background: #fffbeb;
+ border-color: #fde68a;
+ color: #b45309;
}
-}
-.invite-preview-tip-success {
- background: rgba(7, 192, 95, 0.08);
- color: #059669;
- border-color: rgba(7, 192, 95, 0.15);
-}
+ &.invite-preview-note-success {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ background: #f0fdf4;
+ border-color: #bbf7d0;
+ color: #059669;
-.invite-preview-tip-warning {
- background: rgba(250, 173, 20, 0.08);
- color: #b45309;
- border-color: rgba(250, 173, 20, 0.15);
-}
-
-.invite-preview-tip-info {
- background: rgba(0, 112, 240, 0.06);
- color: #0369a1;
- border-color: rgba(0, 112, 240, 0.12);
+ .t-icon {
+ flex-shrink: 0;
+ }
+ }
}
.invite-preview-form-group {
@@ -2153,8 +2169,7 @@ onUnmounted(() => {
font-family: "PingFang SC", -apple-system, sans-serif;
font-size: 14px;
font-weight: 500;
- color: #475569;
- letter-spacing: -0.02em;
+ color: #64748b;
}
.invite-preview-role-select {
@@ -2168,8 +2183,8 @@ onUnmounted(() => {
.invite-preview-footer {
padding: 20px 24px;
- border-top: 1px solid rgba(0, 0, 0, 0.06);
- background: linear-gradient(0deg, #fafbfc 0%, #ffffff 100%);
+ border-top: 1px solid #e2e8f0;
+ background: #f8fafc;
display: flex;
justify-content: flex-end;
gap: 12px;
diff --git a/internal/application/repository/organization.go b/internal/application/repository/organization.go
index 0fd3a05b..19c7146b 100644
--- a/internal/application/repository/organization.go
+++ b/internal/application/repository/organization.go
@@ -77,7 +77,7 @@ func (r *organizationRepository) ListByUserID(ctx context.Context, userID string
return orgs, nil
}
-// ListSearchable lists organizations that are searchable (open for discovery), optionally filtered by name/description
+// ListSearchable lists organizations that are searchable (open for discovery), optionally filtered by name/description/ID
func (r *organizationRepository) ListSearchable(ctx context.Context, query string, limit int) ([]*types.Organization, error) {
if limit <= 0 {
limit = 20
@@ -86,7 +86,8 @@ func (r *organizationRepository) ListSearchable(ctx context.Context, query strin
q := r.db.WithContext(ctx).Where("searchable = ?", true)
if query != "" {
pattern := "%" + query + "%"
- q = q.Where("name ILIKE ? OR description ILIKE ?", pattern, pattern)
+ // 支持按名称、描述或空间 ID 搜索,便于区分同名空间
+ q = q.Where("name ILIKE ? OR description ILIKE ? OR id::text ILIKE ?", pattern, pattern, pattern)
}
err := q.Order("created_at DESC").Limit(limit).Find(&orgs).Error
if err != nil {
diff --git a/internal/application/service/organization.go b/internal/application/service/organization.go
index a87e5fdf..b090c765 100644
--- a/internal/application/service/organization.go
+++ b/internal/application/service/organization.go
@@ -245,9 +245,10 @@ func (s *organizationService) SearchSearchableOrganizations(ctx context.Context,
Description: org.Description,
Avatar: org.Avatar,
MemberCount: int(memberCounts[org.ID]),
+ MemberLimit: org.MemberLimit,
ShareCount: int(shareCounts[org.ID]),
IsAlreadyMember: memberOrgIDs[org.ID],
- RequireApproval: org.RequireApproval,
+ RequireApproval: org.RequireApproval,
})
}
return &types.ListSearchableOrganizationsResponse{
diff --git a/internal/types/organization.go b/internal/types/organization.go
index 1f879122..1d02ce27 100644
--- a/internal/types/organization.go
+++ b/internal/types/organization.go
@@ -352,12 +352,13 @@ type ListOrganizationsResponse struct {
type SearchableOrganizationItem struct {
ID string `json:"id"`
Name string `json:"name"`
- Description string `json:"description"`
- Avatar string `json:"avatar,omitempty"`
- MemberCount int `json:"member_count"`
- ShareCount int `json:"share_count"`
- IsAlreadyMember bool `json:"is_already_member"`
- RequireApproval bool `json:"require_approval"`
+ Description string `json:"description"`
+ Avatar string `json:"avatar,omitempty"`
+ MemberCount int `json:"member_count"`
+ MemberLimit int `json:"member_limit"` // 0 = unlimited
+ ShareCount int `json:"share_count"`
+ IsAlreadyMember bool `json:"is_already_member"`
+ RequireApproval bool `json:"require_approval"`
}
// ListSearchableOrganizationsResponse is the response for searching discoverable organizations
diff --git a/migrations/versioned/000012_organizations_searchable.down.sql b/migrations/versioned/000012_organizations_searchable.down.sql
new file mode 100644
index 00000000..af65bbd0
--- /dev/null
+++ b/migrations/versioned/000012_organizations_searchable.down.sql
@@ -0,0 +1,2 @@
+-- Rollback: 000012_organizations_searchable
+ALTER TABLE organizations DROP COLUMN IF EXISTS searchable;
diff --git a/migrations/versioned/000012_organizations_searchable.up.sql b/migrations/versioned/000012_organizations_searchable.up.sql
new file mode 100644
index 00000000..268d7299
--- /dev/null
+++ b/migrations/versioned/000012_organizations_searchable.up.sql
@@ -0,0 +1,8 @@
+-- Migration: 000012_organizations_searchable
+-- Description: Add searchable flag to organizations (open for discovery)
+DO $$ BEGIN RAISE NOTICE '[Migration 000012] Adding searchable to organizations...'; END $$;
+
+ALTER TABLE organizations ADD COLUMN IF NOT EXISTS searchable BOOLEAN NOT NULL DEFAULT FALSE;
+COMMENT ON COLUMN organizations.searchable IS 'When true, space appears in search and can be joined by org ID';
+
+DO $$ BEGIN RAISE NOTICE '[Migration 000012] Organizations searchable column added.'; END $$;