π The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Category service
Smaug#673965db98c5e138
diff --git a/backend/app/app.go b/backend/app/app.goindex 36187d91..2283a11d 100644--- a/backend/app/app.go+++ b/backend/app/app.go@@ -34,6 +34,7 @@ type Services struct {Session services.AuthServiceLog services.LogServiceDocument services.DocumentService+ Category services.CategoryServiceRessource services.RessourceService}@@ -56,6 +57,7 @@ func InitApp(config Config) *App {Session: services.NewAuthService(app.DB),Log: services.NewLogService(app.DB),Document: services.NewDocumentService(app.DB),+ Category: services.NewCategoryService(app.DB),Ressource: services.NewRessourceService(app.DB),}diff --git a/backend/services/category.service.go b/backend/services/category.service.gonew file mode 100644index 00000000..fe0617aa--- /dev/null+++ b/backend/services/category.service.go@@ -0,0 +1,32 @@+package services++import (+ "alexandrie/models"+ "database/sql"+)++type CategoryService interface {+ GetAllCategories(userId int64) ([]*models.Category, error)+}++func NewCategoryService(db *sql.DB) CategoryService {+ return &Service{db: db}+}++func (s *Service) GetAllCategories(userId int64) ([]*models.Category, error) {+ var categories []*models.Category+ rows, err := s.db.Query("SELECT * FROM categories WHERE author_id = ? ORDER BY order", userId)+ if err != nil {+ return nil, err+ }+ defer rows.Close()++ for rows.Next() {+ var category models.Category+ if err := rows.Scan(&category.Id, &category.Name, &category.Icon, &category.Order, &category.Role, &category.WorkspaceId, &category.ParentId, &category.AuthorId); err != nil {+ return nil, err+ }+ categories = append(categories, &category)+ }+ return categories, nil+}