Skip to main content

Content Pages

Overview

Content Page produces content pages — articles, promotions, landing pages — that can be shared with LINE users through a public link. The module implements a full CMS lifecycle of draft, publish, and archive, with view analytics and optional password protection.

Pages are organised through Content Category and Content Subcategory, and published as collections through Content Link.

Business Flow

Administrator side

  1. GET /api/content-pages with page, limit, search, and status parameters lists all pages and returns {data, total, page, limit, totalPages}.
  2. POST /api/content-pages creates a page in draft status. The system generates a public token with crypto.randomBytes(32), and if a password is set, hashes it with bcrypt at cost 10.
  3. POST /api/content-pages/upload-image uploads page imagery, validating the Content-Type.
  4. GET /api/content-pages/:id returns details; PATCH /api/content-pages/:id updates them.
  5. POST /api/content-pages/:id/publish publishes a page and POST /api/content-pages/:id/archive moves it into the archive.
  6. POST /api/content-pages/:id/duplicate copies an entire page, images included.
  7. GET /api/content-pages/:id/analytics returns view statistics assembled from content_page_view, content_page_analytics, and UTM data in content_page_utm.
  8. DELETE /api/content-pages/:id performs a soft delete through a plain deleted_date column, which means every query must apply the filter itself.

Reader side

  1. GET /api/public/content-pages/:token opens a page by token and accepts a password parameter. Password-protected pages require a matching value, compared with bcrypt. An unpublished page or an invalid token returns error APP_007 (Content not found).
  2. POST /api/public/content-pages/:token/track records a visit using TrackViewDto, incrementing the view count and storing the event for analytics before returning 200.

A second public path with similar behaviour lives in the publicmod module at /api/public/content/:token, with additional LIFF support.

Key Files & Functions

Core code lives in internal/modules/contentpage/, comprising controller.go, service.go, and dto.go.

MethodRouteHandlerPolicy (metadata)
GET/api/content-pagesct.findAllreadAll line-oa
GET/api/content-pages/:idct.findOneread line-oa
GET/api/content-pages/:id/analyticsct.getAnalyticsread line-oa
POST/api/content-pagesct.createcreate line-oa
POST/api/content-pages/upload-imagect.uploadImagecreate line-oa
POST/api/content-pages/:id/publishct.publishcreate line-oa
POST/api/content-pages/:id/archivect.archivecreate line-oa
POST/api/content-pages/:id/duplicatect.duplicatecreate line-oa
PATCH/api/content-pages/:idct.updateupdate line-oa
DELETE/api/content-pages/:idct.removedelete line-oa
GET/api/public/content-pages/:tokenct.getPublicContentpublic
POST/api/public/content-pages/:token/trackct.trackViewpublic

Connections to Other Services

  • Access control — administrator routes sit on the authed group with global JWT. The policy metadata is PolicyModuleLineOa and is not yet enforced; there is no ModuleGate. Public routes have no guard.
  • Tablescontent_page, content_page_translation, content_page_view, content_page_analytics, content_page_utm, content_category, content_subcategory, and line_oa
  • Soft delete — a plain deleted_date column rather than gorm.DeletedAt, so every read must add deleted_date IS NULL explicitly.
  • Storage Service — stores page imagery.
  • Hashing — bcrypt at cost 10 for page passwords.
  • Related modules — Content Category, Content Subcategory, Content Link, and Public API.