Skip to main content

Content Category

Overview

Content Category is the top-level grouping used to organise content pages — level one of the category structure. The level below it is Content Subcategory, which can nest several levels deep.

Beyond standard CRUD, the module exposes endpoints for two dropdown shapes and a statistics endpoint reporting how much content sits in each category.

A caveat worth noting: the ContentCategory entity uses a plain deleted_date column rather than gorm.DeletedAt, so GORM does not add the filter automatically. The code must include deleted_date IS NULL wherever the TypeScript version did — and must omit it where the original omitted it, such as on update and save.

Business Flow

  1. GET /api/content-categories lists categories with filtering per QueryContentCategoryDto.
  2. GET /api/content-categories/dropdown returns a flat dropdown shape.
  3. GET /api/content-categories/dropdown-group returns a grouped shape for UIs that use optgroups.
  4. GET /api/content-categories/stats returns the content count per category.
  5. POST /api/content-categories creates a category from CreateContentCategoryDto.
  6. GET /api/content-categories/:id returns a single category's details.
  7. PATCH /api/content-categories/:id updates a category.
  8. DELETE /api/content-categories/:id removes a category, responding with 204 No Content.
  9. Categories appear as options when authoring a content page and are surfaced on the public path GET /api/public/contents/categories.

Key Files & Functions

Core code lives in internal/modules/contentcategory/, comprising controller.go, service.go, and dto.go, registered on the authed.Group("/content-categories") group.

MethodRouteHandlerPolicy (metadata)
GET/api/content-categoriesh.findAllreadAll line-oa
GET/api/content-categories/dropdownh.getDropdownreadAll line-oa
GET/api/content-categories/dropdown-grouph.getDropdownGroupreadAll line-oa
GET/api/content-categories/statsh.getStatsreadAll line-oa
GET/api/content-categories/:idh.findOneread line-oa
POST/api/content-categoriesh.createcreate line-oa
PATCH/api/content-categories/:idh.updateupdate line-oa
DELETE/api/content-categories/:idh.removedelete line-oa

The static paths /dropdown, /dropdown-group, and /stats are registered ahead of /:id so gin resolves to the intended handler.

Connections to Other Services

  • Access control — requests must pass global JwtAuth. The policy metadata is PolicyModuleLineOa and is not yet enforced; there is no ModuleGate.
  • Tablescontent_category, content_subcategory, content_page, line_oa
  • Context — reads lineOaId and organizationId from CLS to scope queries.
  • Related modules — Content Subcategory, Content Page, Content Link, and Public API.