rentease-backend-new/models/Category.js

102 lines
2.0 KiB
JavaScript
Raw 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.

const { DataTypes } = require('sequelize');
const sequelize = require('../config/db');
const Category = sequelize.define('Category', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
comment: '类目ID'
},
name: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '类目名称'
},
code: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '类目编码'
},
type: {
type: DataTypes.ENUM('income', 'expense'),
allowNull: false,
comment: '类型income-收入expense-支出'
},
sort: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序号'
},
status: {
type: DataTypes.ENUM('active', 'inactive'),
allowNull: false,
defaultValue: 'active',
comment: '状态active-启用inactive-禁用'
},
isDefault: {
type: DataTypes.TINYINT,
allowNull: false,
defaultValue: 0,
comment: '是否默认类目01'
},
tenantId: {
type: DataTypes.INTEGER,
allowNull: false,
comment: '租户ID'
},
createBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '创建人ID'
},
updateBy: {
type: DataTypes.INTEGER,
allowNull: true,
comment: '修改人ID'
},
isDeleted: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '删除状态0未删除1已删除'
},
createTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
comment: '创建时间'
},
updateTime: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW,
comment: '更新时间'
}
}, {
tableName: 'categories',
timestamps: false,
comment: '收支类目表',
indexes: [
{
fields: ['tenantId'],
name: 'idx_tenant'
},
{
fields: ['type'],
name: 'idx_type'
},
{
fields: ['status'],
name: 'idx_status'
},
{
fields: ['code'],
name: 'idx_code'
}
]
});
module.exports = Category;