50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
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
|
|
|
|
database.DB.Model(&models.User{
|
|
Id: c.Locals("userId").(string),
|
|
}).Select("profile_picture_url").First(&user)
|
|
|
|
var organization models.Organization
|
|
|
|
database.DB.Model(&models.Organization{}).Select("company_name", "primary_color", "logo_url", "banner_url").Where("id = ?", c.Locals("organizationId").(string)).First(&organization)
|
|
|
|
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,
|
|
},
|
|
})
|
|
}
|