package app import ( "git.ex.umbach.dev/LMS/libcore/models" "github.com/gofiber/fiber/v2" "lms.de/backend/modules/database" "lms.de/backend/modules/structs" ) func GetApp(c *fiber.Ctx) error { // swagger:operation GET /app app getApp // --- // summary: Get app // consumes: // - application/json // produces: // - application/json // responses: // '200': // description: App fetched successfully // schema: // "$ref": "#/definitions/GetAppResponse" // '400': // description: Invalid request body // '500': // description: Failed to fetch app var user models.User if err := database.DB.Model(&models.User{}). Where("id = ?", c.Locals("userId").(string)). Select("profile_picture_url").First(&user).Error; err != nil { return c.SendStatus(fiber.StatusInternalServerError) } var organization models.Organization if err := database.DB.Model(&models.Organization{}). Select("company_name", "primary_color", "logo_url", "banner_url"). Where("id = ?", c.Locals("organizationId").(string)). First(&organization).Error; err != nil { return c.SendStatus(fiber.StatusInternalServerError) } return c.JSON(structs.GetAppResponse{ User: structs.AppUser{ ProfilePictureUrl: user.ProfilePictureUrl, }, Organization: structs.AppOrganization{ CompanyName: organization.CompanyName, PrimaryColor: organization.PrimaryColor, LogoUrl: organization.LogoUrl, BannerUrl: organization.BannerUrl, }, }) }