Files
nxxmdata/government-backend/models/HarmlessRegistration.js

85 lines
2.1 KiB
JavaScript
Raw Normal View History

const { DataTypes, Sequelize } = require('sequelize');
module.exports = (sequelize) => {
const HarmlessRegistration = sequelize.define('HarmlessRegistration', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false
},
registrationNumber: {
type: DataTypes.STRING(50),
allowNull: false,
unique: true,
comment: '登记编号'
},
animalType: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '动物类型'
},
quantity: {
type: DataTypes.INTEGER,
allowNull: false,
comment: '数量',
validate: {
min: 1
}
},
reason: {
type: DataTypes.TEXT,
allowNull: false,
comment: '无害化处理原因'
},
processingMethod: {
type: DataTypes.STRING(100),
allowNull: false,
comment: '处理方式'
},
processingPlace: {
type: DataTypes.STRING(100),
allowNull: false,
comment: '处理场所'
},
processingDate: {
type: DataTypes.DATEONLY,
allowNull: false,
comment: '处理日期'
},
registrant: {
type: DataTypes.STRING(50),
allowNull: false,
comment: '登记人'
},
status: {
type: DataTypes.ENUM('待处理', '处理中', '已完成', '已取消'),
allowNull: false,
defaultValue: '待处理',
comment: '状态'
},
createTime: {
type: DataTypes.DATE,
defaultValue: Sequelize.fn('NOW'),
allowNull: false,
comment: '创建时间'
},
updateTime: {
type: DataTypes.DATE,
defaultValue: Sequelize.fn('NOW'),
allowNull: false,
comment: '更新时间'
}
}, {
tableName: 'government_harmless_registrations',
timestamps: false,
indexes: [
{ name: 'idx_registrationNumber', fields: ['registrationNumber'] },
{ name: 'idx_status', fields: ['status'] },
{ name: 'idx_processingDate', fields: ['processingDate'] }
],
comment: '无害化登记管理表'
});
return HarmlessRegistration;
};