feat(organization): implement searchable organizations feature

- Added a 'searchable' flag to organizations, allowing them to be discoverable and joinable by ID without an invite code.
- Introduced API endpoints for searching and joining searchable organizations.
- Updated UI components to support searching for organizations and displaying results.
- Enhanced localization for new search-related features in both English and Chinese.

This update improves user experience by enabling easier discovery and joining of organizations.
This commit is contained in:
wizardchen
2026-01-30 19:20:52 +08:00
committed by lyingbug
parent 760bbffafe
commit 2818a4fe8f
13 changed files with 1065 additions and 312 deletions
@@ -77,10 +77,28 @@ 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
func (r *organizationRepository) ListSearchable(ctx context.Context, query string, limit int) ([]*types.Organization, error) {
if limit <= 0 {
limit = 20
}
var orgs []*types.Organization
q := r.db.WithContext(ctx).Where("searchable = ?", true)
if query != "" {
pattern := "%" + query + "%"
q = q.Where("name ILIKE ? OR description ILIKE ?", pattern, pattern)
}
err := q.Order("created_at DESC").Limit(limit).Find(&orgs).Error
if err != nil {
return nil, err
}
return orgs, nil
}
// Update updates an organization (Select ensures zero values like invite_code_validity_days=0 are persisted)
func (r *organizationRepository) Update(ctx context.Context, org *types.Organization) error {
return r.db.WithContext(ctx).Model(&types.Organization{}).Where("id = ?", org.ID).
Select("name", "description", "require_approval", "invite_code_validity_days", "updated_at").
Select("name", "description", "require_approval", "searchable", "invite_code_validity_days", "updated_at").
Updates(org).Error
}