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
GET /api/content-categorieslists categories with filtering perQueryContentCategoryDto.GET /api/content-categories/dropdownreturns a flat dropdown shape.GET /api/content-categories/dropdown-groupreturns a grouped shape for UIs that use optgroups.GET /api/content-categories/statsreturns the content count per category.POST /api/content-categoriescreates a category fromCreateContentCategoryDto.GET /api/content-categories/:idreturns a single category's details.PATCH /api/content-categories/:idupdates a category.DELETE /api/content-categories/:idremoves a category, responding with 204 No Content.- 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.
| Method | Route | Handler | Policy (metadata) |
|---|---|---|---|
| GET | /api/content-categories | h.findAll | readAll line-oa |
| GET | /api/content-categories/dropdown | h.getDropdown | readAll line-oa |
| GET | /api/content-categories/dropdown-group | h.getDropdownGroup | readAll line-oa |
| GET | /api/content-categories/stats | h.getStats | readAll line-oa |
| GET | /api/content-categories/:id | h.findOne | read line-oa |
| POST | /api/content-categories | h.create | create line-oa |
| PATCH | /api/content-categories/:id | h.update | update line-oa |
| DELETE | /api/content-categories/:id | h.remove | delete 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 isPolicyModuleLineOaand is not yet enforced; there is noModuleGate. - Tables —
content_category,content_subcategory,content_page,line_oa - Context — reads
lineOaIdandorganizationIdfrom CLS to scope queries. - Related modules — Content Subcategory, Content Page, Content Link, and Public API.