'use strict'; /** * 文档内容页(doc_articles) * * - `content`:Markdown 原文(保存后由 `service/docSite` 渲染成静态 HTML) * - `slug`:URL 片段(`/doc//.html`),创建后不能改 * - `status`:1 发布 0 草稿(草稿不生成页面,也不进 sitemap) * - `categoryId` 冗余一份:列表 / 生成文档站时不用每次都 join 栏目 */ 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: '主键' }, categoryId: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属分类 doc_categories.id' }, 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/<分类>/.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; };