You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
2.7 KiB
114 lines
2.7 KiB
/* eslint-disable*/
|
|
|
|
'use strict';
|
|
|
|
module.exports = dc => {
|
|
const DataTypes = dc.ORM;
|
|
const sequelize = dc.orm;
|
|
const BookChapter = sequelize.define("bookChapter", {
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: null,
|
|
comment: "章节ID",
|
|
primaryKey: true,
|
|
field: "id",
|
|
autoIncrement: true
|
|
},
|
|
bookId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: null,
|
|
comment: "所属书籍ID",
|
|
primaryKey: false,
|
|
field: "book_id",
|
|
autoIncrement: false,
|
|
references: {
|
|
key: "id",
|
|
model: "book"
|
|
}
|
|
},
|
|
parentId: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: true,
|
|
defaultValue: null,
|
|
comment: "父章节ID",
|
|
primaryKey: false,
|
|
field: "parent_id",
|
|
autoIncrement: false,
|
|
references: {
|
|
key: "id",
|
|
model: "bookChapter"
|
|
}
|
|
},
|
|
level: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 1,
|
|
comment: "章节层级",
|
|
primaryKey: false,
|
|
field: "level",
|
|
autoIncrement: false
|
|
},
|
|
title: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
defaultValue: null,
|
|
comment: "章节标题",
|
|
primaryKey: false,
|
|
field: "title",
|
|
autoIncrement: false
|
|
},
|
|
requirements: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
defaultValue: null,
|
|
comment: "章节要求",
|
|
primaryKey: false,
|
|
field: "requirements",
|
|
autoIncrement: false
|
|
},
|
|
generationStatus: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
defaultValue: 'pending',
|
|
comment: "生成状态: pending待生成/generating生成中/success成功/failed失败",
|
|
primaryKey: false,
|
|
field: "generation_status",
|
|
autoIncrement: false
|
|
},
|
|
sortOrder: {
|
|
type: DataTypes.DOUBLE,
|
|
allowNull: false,
|
|
defaultValue: 0,
|
|
comment: "排序字段",
|
|
primaryKey: false,
|
|
field: "sort_order",
|
|
autoIncrement: false
|
|
},
|
|
createdAt: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
|
|
comment: "创建时间",
|
|
primaryKey: false,
|
|
field: "created_at",
|
|
autoIncrement: false
|
|
},
|
|
updatedAt: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
|
|
comment: "更新时间",
|
|
primaryKey: false,
|
|
field: "updated_at",
|
|
autoIncrement: false
|
|
}
|
|
}, {
|
|
tableName: "book_chapters",
|
|
comment: "书籍章节表",
|
|
indexes: []
|
|
});
|
|
dc.models.BookChapter = BookChapter;
|
|
return BookChapter;
|
|
};
|