// ListOrganizations returns all available organizations // // GET /orgs // func (c *OrganizationsController) ListOrganizations(ctx *gin.Context) { orgs := []*schema.Organization{} //TODO: add pagination support via Skip and Limit query methods // err := models.Organization.Find(nil).All(&orgs) // if err != nil { // helpers.JSONResponseInternalServerError(ctx, err) // return // } helpers.JSONResponseCollection(ctx, presenters.OrganizationCollectionPresenter(orgs)) }
// ListUserOrganizations lists all organizations for a specific user // // GET /users/:username/orgs // func (c *UsersController) ListUserOrganizations(ctx *gin.Context) { user := getCurrentUser(ctx) userService, err := services.NewUserService(user) if err != nil { if c.WriteTrace { c.Logger.Printf("Failed to create UserService for user: %v", user) } helpers.JSONResponseInternalServerError(ctx, err) return } orgs, err := userService.ListOrganizations() if err != nil { helpers.JSONResponseInternalServerError(ctx, err) return } helpers.JSONResponseObject(ctx, presenters.OrganizationCollectionPresenter(orgs)) }