修改政府端前端,银行端小程序和后端接口
This commit is contained in:
85
government-backend/models/EpidemicAgency.js
Normal file
85
government-backend/models/EpidemicAgency.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const sequelize = require('../config/database');
|
||||
const { DataTypes } = require('sequelize');
|
||||
|
||||
const EpidemicAgency = sequelize.define('EpidemicAgency', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '机构名称'
|
||||
},
|
||||
director: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '负责人'
|
||||
},
|
||||
phone: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '联系电话'
|
||||
},
|
||||
address: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '地址'
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
comment: '邮箱'
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.ENUM('center', 'branch', 'mobile'),
|
||||
allowNull: false,
|
||||
defaultValue: 'branch',
|
||||
comment: '机构类型: center(中心防疫站), branch(防疫分站), mobile(流动防疫队)'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('active', 'inactive'),
|
||||
allowNull: false,
|
||||
defaultValue: 'active',
|
||||
comment: '状态: active(活跃), inactive(非活跃)'
|
||||
},
|
||||
establishmentDate: {
|
||||
type: DataTypes.DATEONLY,
|
||||
allowNull: false,
|
||||
comment: '成立日期'
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
comment: '机构描述'
|
||||
},
|
||||
created_by: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
comment: '创建人ID'
|
||||
},
|
||||
updated_by: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
comment: '更新人ID'
|
||||
}
|
||||
}, {
|
||||
tableName: 'government_epidemic_agencies',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_agency_name',
|
||||
fields: ['name']
|
||||
},
|
||||
{
|
||||
name: 'idx_agency_status',
|
||||
fields: ['status']
|
||||
},
|
||||
{
|
||||
name: 'idx_agency_type',
|
||||
fields: ['type']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = EpidemicAgency;
|
||||
77
government-backend/models/SmartCollar.js
Normal file
77
government-backend/models/SmartCollar.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../config/database');
|
||||
|
||||
const SmartCollar = sequelize.define('SmartCollar', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
collar_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
comment: '项圈编号'
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '项圈名称'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('active', 'inactive', 'maintenance'),
|
||||
allowNull: false,
|
||||
defaultValue: 'inactive',
|
||||
comment: '状态:active-使用中,inactive-未使用,maintenance-维护中'
|
||||
},
|
||||
battery: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 100,
|
||||
validate: {
|
||||
min: 0,
|
||||
max: 100
|
||||
},
|
||||
comment: '电池电量(%)'
|
||||
},
|
||||
remark: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
comment: '备注'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: '创建时间'
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: '更新时间'
|
||||
}
|
||||
}, {
|
||||
tableName: 'smart_collars',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
paranoid: false,
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_smart_collar_id',
|
||||
fields: ['collar_id']
|
||||
},
|
||||
{
|
||||
name: 'idx_smart_collar_status',
|
||||
fields: ['status']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 钩子函数,在保存前更新更新时间
|
||||
SmartCollar.beforeSave((collar) => {
|
||||
collar.updated_at = new Date();
|
||||
});
|
||||
|
||||
module.exports = SmartCollar;
|
||||
77
government-backend/models/SmartEarmark.js
Normal file
77
government-backend/models/SmartEarmark.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../config/database');
|
||||
|
||||
const SmartEarmark = sequelize.define('SmartEarmark', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
earmark_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
comment: '耳标编号'
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '耳标名称'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('active', 'inactive', 'maintenance'),
|
||||
allowNull: false,
|
||||
defaultValue: 'inactive',
|
||||
comment: '状态:active-使用中,inactive-未使用,maintenance-维护中'
|
||||
},
|
||||
battery: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 100,
|
||||
validate: {
|
||||
min: 0,
|
||||
max: 100
|
||||
},
|
||||
comment: '电池电量(%)'
|
||||
},
|
||||
remark: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
comment: '备注'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: '创建时间'
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: '更新时间'
|
||||
}
|
||||
}, {
|
||||
tableName: 'smart_earmarks',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
paranoid: false,
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_smart_earmark_id',
|
||||
fields: ['earmark_id']
|
||||
},
|
||||
{
|
||||
name: 'idx_smart_earmark_status',
|
||||
fields: ['status']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 钩子函数,在保存前更新更新时间
|
||||
SmartEarmark.beforeSave((earmark) => {
|
||||
earmark.updated_at = new Date();
|
||||
});
|
||||
|
||||
module.exports = SmartEarmark;
|
||||
72
government-backend/models/SmartHost.js
Normal file
72
government-backend/models/SmartHost.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const sequelize = require('../config/database');
|
||||
|
||||
const SmartHost = sequelize.define('SmartHost', {
|
||||
id: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
host_id: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
comment: '主机编号'
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '主机名称'
|
||||
},
|
||||
ip_address: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: 'IP地址'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('active', 'inactive', 'maintenance'),
|
||||
allowNull: false,
|
||||
defaultValue: 'inactive',
|
||||
comment: '状态:active-使用中,inactive-未使用,maintenance-维护中'
|
||||
},
|
||||
remark: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
comment: '备注'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: '创建时间'
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: DataTypes.NOW,
|
||||
comment: '更新时间'
|
||||
}
|
||||
}, {
|
||||
tableName: 'smart_hosts',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
paranoid: false,
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_smart_host_id',
|
||||
fields: ['host_id']
|
||||
},
|
||||
{
|
||||
name: 'idx_smart_host_status',
|
||||
fields: ['status']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 钩子函数,在保存前更新更新时间
|
||||
SmartHost.beforeSave((host) => {
|
||||
host.updated_at = new Date();
|
||||
});
|
||||
|
||||
module.exports = SmartHost;
|
||||
Reference in New Issue
Block a user