Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Category controller

Smaug#6739f70ba3bff68e
diff --git a/backend/controllers/categories.controller.go b/backend/controllers/categories.controller.go
new file mode 100644
index 00000000..3a74b322
--- /dev/null
+++ b/backend/controllers/categories.controller.go
@@ -0,0 +1,39 @@
+package controllers
+
+import (
+ "alexandrie/app"
+ "alexandrie/utils"
+ "net/http"
+
+ "github.com/gin-gonic/gin"
+)
+
+type CategoriesController interface {
+ GetCategories(c *gin.Context) (int, any)
+}
+
+func NewCategoriesController(app *app.App) CategoriesController {
+ return &Controller{
+ app: app,
+ }
+}
+
+// Get documents
+// @Summary Get all documents
+// @Method GET
+// @Router /documents [get]
+// @Security Authenfification: Auth
+// @Success 200 {object} Success([]models.Document)
+// @Failure 400 {object} Error
+// @Failure 401 {object} Error
+func (ctr *Controller) GetCategories(c *gin.Context) (int, any) {
+ id, err := utils.SelfOrPermission(c, utils.ADMINISTRATOR, "userId")
+ if err != nil {
+ return http.StatusUnauthorized, err
+ }
+ documents, err := ctr.app.Services.Document.GetAllDocuments(id)
+ if err != nil {
+ return http.StatusInternalServerError, err
+ }
+ return http.StatusOK, documents
+}