chore: 后端首次基线提交

运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。
已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
This commit is contained in:
WorkBuddy
2026-08-17 12:25:42 +08:00
commit a303cf2d53
109 changed files with 25904 additions and 0 deletions

117
app/model/news.js Normal file
View File

@@ -0,0 +1,117 @@
'use strict';
/**
* 新闻模型 - News
*
* 存储新闻通知信息,支持置顶、微信公众号链接和按组别过滤显示。
* 表名:news
*/
module.exports = app => {
const { STRING, TEXT, BOOLEAN, DATE, INTEGER } = app.Sequelize;
const News = app.model.define('news', {
// 主键 ID,自增
id: {
type: INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '新闻唯一标识',
},
// 新闻标题
title: {
type: STRING(200),
allowNull: false,
comment: '新闻标题',
},
// 新闻正文内容(支持 HTML)
content: {
type: TEXT,
allowNull: true,
defaultValue: null,
comment: '新闻正文(微信链接型新闻可为空)',
},
// 微信公众号文章链接
wx_link: {
type: STRING(500),
allowNull: true,
defaultValue: null,
comment: '微信公众号文章链接',
},
// 新闻类型:content(内容型)/ wx_link(微信链接型)
news_type: {
type: STRING(20),
allowNull: false,
defaultValue: 'content',
comment: '新闻类型:content=内容型, wx_link=微信链接型',
},
// 发布时间
publish_time: {
type: DATE,
allowNull: false,
comment: '发布时间',
},
// 是否置顶
pinned: {
type: BOOLEAN,
allowNull: false,
defaultValue: false,
comment: '是否置顶',
},
// 排序序号
sort_order: {
type: INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序序号,越小越靠前',
},
// 目标可见组别
group: {
type: STRING(20),
allowNull: false,
defaultValue: 'all',
comment: '目标可见组别',
},
// 标签(逗号分隔)
tags: {
type: STRING(500),
allowNull: true,
defaultValue: null,
comment: '标签,多个标签用逗号分隔',
},
// 记录创建时间
created_at: {
type: DATE,
allowNull: false,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
// 记录更新时间
updated_at: {
type: DATE,
allowNull: false,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '更新时间',
},
}, {
tableName: 'news',
timestamps: false,
underscored: true,
indexes: [
{
fields: ['publish_time'],
},
{
fields: ['pinned', 'publish_time'],
},
{
fields: ['group'],
},
{
fields: ['sort_order'],
},
],
});
return News;
};