packServer/backend/app/model/doc_article.js
liufumingren b82b07b84f feat(doc): 栏目内容两级结构与悬浮目录
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-10 04:22:52 +08:00

31 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 文档内容页(doc_articles)
*
* 直接挂在栏目下(两级结构),一个栏目下的一批内容页就是文档站左侧的导航列表。
* - `content`:Markdown 原文(保存后由 `service/docSite` 渲染成静态 HTML)
* - `slug`:URL 片段(`/doc/<栏目 code>/<slug>.html`),创建后不能改
* - `status`:1 发布 0 草稿(草稿不生成页面,也不进 sitemap)
*/
module.exports = (app) => {
const { BIGINT, STRING, TINYINT, INTEGER, TEXT } = app.Sequelize;
const DocArticle = app.model.define('doc_article', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
sectionId: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属栏目 doc_sections.id' },
title: { type: STRING(128), allowNull: false, comment: '标题' },
slug: { type: STRING(64), allowNull: false, comment: 'URL 片段(/doc/<栏目>/<slug>.html)' },
summary: { type: STRING(255), allowNull: true, comment: '摘要(列表 / meta description)' },
content: { type: TEXT('medium'), allowNull: true, comment: '正文(Markdown)' },
sort: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 0, comment: '栏目内排序(小的在前)' },
status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1 发布 0 草稿' },
}, {
tableName: 'doc_articles',
paranoid: true,
comment: '文档内容页表',
});
return DocArticle;
};