feat: add organization management features
- Introduced a new API for organization management, including creation, updating, and deletion of organizations. - Implemented organization sharing functionality for knowledge bases, allowing users to share knowledge bases with specific organizations and set permissions. - Added UI components for organization selection and sharing dialogs. - Enhanced existing components to support organization-related features, including shared knowledge base handling and organization role management. This update enhances collaboration capabilities within the application by allowing users to manage and share knowledge bases across different organizations.
This commit is contained in:
@@ -95,6 +95,28 @@ func (r *userRepository) ListUsers(ctx context.Context, offset, limit int) ([]*t
|
||||
return users, nil
|
||||
}
|
||||
|
||||
// SearchUsers searches users by username or email
|
||||
func (r *userRepository) SearchUsers(ctx context.Context, query string, limit int) ([]*types.User, error) {
|
||||
var users []*types.User
|
||||
searchPattern := "%" + query + "%"
|
||||
|
||||
dbQuery := r.db.WithContext(ctx).
|
||||
Where("username ILIKE ? OR email ILIKE ?", searchPattern, searchPattern).
|
||||
Where("is_active = ?", true).
|
||||
Order("username ASC")
|
||||
|
||||
if limit > 0 {
|
||||
dbQuery = dbQuery.Limit(limit)
|
||||
} else {
|
||||
dbQuery = dbQuery.Limit(20) // default limit
|
||||
}
|
||||
|
||||
if err := dbQuery.Find(&users).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return users, nil
|
||||
}
|
||||
|
||||
// authTokenRepository implements auth token repository interface
|
||||
type authTokenRepository struct {
|
||||
db *gorm.DB
|
||||
|
||||
Reference in New Issue
Block a user