明树Git Lab

Commit 97afd353 authored by zfp1's avatar zfp1

update

parent fbd84ce0
Pipeline #103940 passed with stage
in 3 seconds
......@@ -10,6 +10,7 @@ const UserDepart = require("./model/system/userDepart");
const RequestLog = require("./model/system/requestLog");
const File = require("./model/system/file");
const Position = require("./model/system/position");
const UserPosition = require("./model/system/userPosition");
const Message = require("./model/system/message");
const FlowRecord = require("./model/system/flowRecord");
......@@ -48,6 +49,7 @@ global.DB = {
UserDepart,
File,
Position,
UserPosition,
Project,
Resources,
ResourcesInfo,
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const Project = require('./project');
const Project = require('./project');
// 核心边界条件
const projectBjtj = sequelize.define('projectBjtj', {
id: {
......@@ -66,7 +66,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
bcsm: {
type: DataTypes.STRING,
comment: "核心边界条件补充说明"
comment: "核心边界条件补充说明"
},
projectId: {
......@@ -76,13 +76,29 @@ const projectBjtj = sequelize.define('projectBjtj', {
model: Project, // 关联的表名
key: 'id', // 关联的字段
}
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_bjtj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -90,7 +106,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
// 同步模型到数据库(创建表)
projectBjtj.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -26,9 +26,24 @@ const projectCwpjbjtj = sequelize.define('projectCwpjbjtj', {
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
comment: "所属项目ID",
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_cwpjbjtj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -24,6 +24,22 @@ const projectCwpjzb = sequelize.define('projectCwpjzb', {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_cwpjzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -21,7 +21,23 @@ const ProjectFile = sequelize.define('ProjectFile', {
},
proFieldKey: {
type: DataTypes.STRING, //项目表中文件字段key
}
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_file', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -29,7 +45,7 @@ const ProjectFile = sequelize.define('ProjectFile', {
// 同步模型到数据库(创建表)
ProjectFile.sync({
force: false, //
force: false, //
// force: true //会删除已存在表并重新创建
// alter: true
})
......
......@@ -19,16 +19,32 @@ const ProjectFxgl = sequelize.define('ProjectFxgl', {
ydcs: {
type: DataTypes.TEXT,
comment: "应对措施"
},
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_fxgl', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -36,7 +52,7 @@ const ProjectFxgl = sequelize.define('ProjectFxgl', {
// 同步模型到数据库(创建表)
ProjectFxgl.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -50,6 +50,22 @@ const ProjectGdxx = sequelize.define('ProjectGdxx', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_gdxx', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -24,6 +24,22 @@ const ProjectJczt = sequelize.define('ProjectJczt', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_jczt', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -33,6 +33,22 @@ const ProjectJsgm = sequelize.define('ProjectJsgm', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_jsgm', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -17,18 +17,18 @@ const ProjectLcbjd = sequelize.define('ProjectLcbjd', {
primaryKey: true,
autoIncrement: true
},
lcbjdmc: {
type: DataTypes.STRING,
comment: "里程碑节点名称"
comment: "里程碑节点名称"
},
jdwcms: {
type: DataTypes.TEXT,
comment: "节点完成描述"
comment: "节点完成描述"
},
yjwcsj: {
type: DataTypes.DATE,
comment: "预计完成时间"
comment: "预计完成时间"
},
projectId: {
......@@ -40,6 +40,22 @@ const ProjectLcbjd = sequelize.define('ProjectLcbjd', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_lcbjd', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -31,10 +31,12 @@ const ProjectSpyj = sequelize.define('ProjectSpyj', {
},
zxhf: { type: DataTypes.TEXT, allowNull: true, comment: "执行回复" },
zxhfsj: { type: DataTypes.DATE, allowNull: true, comment: "执行回复时间" },
zxhffj: { type: DataTypes.INTEGER, references: {
model: File,
key: 'id'
}, allowNull: true, comment: "执行回复附件" },
zxhffj: {
type: DataTypes.INTEGER, references: {
model: File,
key: 'id'
}, allowNull: true, comment: "执行回复附件"
},
wlsqksm: { type: DataTypes.TEXT, allowNull: true, comment: "未落实情况说明" },
projectId: {
......@@ -46,6 +48,22 @@ const ProjectSpyj = sequelize.define('ProjectSpyj', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_spyj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -13,16 +13,32 @@ const ProjectTjjh = sequelize.define('ProjectTjjh', {
sjx: { type: DataTypes.STRING, allowNull: true, comment: "数据项" },
hj: { type: DataTypes.DECIMAL(20, 4), allowNull: true, comment: "数据项" },
sz: { type: DataTypes.JSON, allowNull: true, comment: "数值" },
rawNum: {type: DataTypes.INTEGER}, //行数
rawNum: { type: DataTypes.INTEGER }, //行数
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_tzzjll', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -30,7 +46,7 @@ const ProjectTjjh = sequelize.define('ProjectTjjh', {
// 同步模型到数据库(创建表)
ProjectTjjh.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -9,18 +9,34 @@ const ProjectTzsyzb = sequelize.define('ProjectTzsyzb', {
primaryKey: true,
autoIncrement: true
},
pjzb:{ type: DataTypes.STRING, allowNull: true, comment: "评价指标" },
jczb:{ type: DataTypes.STRING, comment: '决策指标'},
xzzb:{ type: DataTypes.STRING, comment: '现状指标'},
pjzb: { type: DataTypes.STRING, allowNull: true, comment: "评价指标" },
jczb: { type: DataTypes.STRING, comment: '决策指标' },
xzzb: { type: DataTypes.STRING, comment: '现状指标' },
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_tzsyzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -28,7 +44,7 @@ const ProjectTzsyzb = sequelize.define('ProjectTzsyzb', {
// 同步模型到数据库(创建表)
ProjectTzsyzb.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -13,16 +13,32 @@ const ProjectTzzjll = sequelize.define('ProjectTzzjll', {
sdsqjxjll: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "所得税前净现金流量" },
tzsds: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "调整所得税" },
sdshjxjll: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "所得税后净现金流量" },
year: { type: DataTypes.STRING, allowNull: true, comment: "年份"},
year: { type: DataTypes.STRING, allowNull: true, comment: "年份" },
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_tzzjll', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -30,7 +46,7 @@ const ProjectTzzjll = sequelize.define('ProjectTzzjll', {
// 同步模型到数据库(创建表)
ProjectTzzjll.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -8,7 +8,7 @@ const ProjectTzzt = sequelize.define('ProjectTzzt', {
primaryKey: true,
autoIncrement: true
},
hylx: { type: DataTypes.STRING, allowNull: true, comment: "会议类型" },
hylx: { type: DataTypes.STRING, allowNull: true, comment: "会议类型" },
jc: { type: DataTypes.STRING, allowNull: true, comment: "届次" },
zkrq: { type: DataTypes.DATE, allowNull: true, comment: "召开日期" },
jl: { type: DataTypes.STRING, allowNull: true, comment: "结论" },
......@@ -16,12 +16,28 @@ const ProjectTzzt = sequelize.define('ProjectTzzt', {
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_tzzt', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -29,7 +45,7 @@ const ProjectTzzt = sequelize.define('ProjectTzzt', {
// 同步模型到数据库(创建表)
ProjectTzzt.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -18,7 +18,7 @@ const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
},
zb: {
type: DataTypes.STRING,
comment: "指标"
comment: "指标"
},
dw: {
type: DataTypes.STRING,
......@@ -37,13 +37,29 @@ const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_project_xmtzze', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -51,7 +67,7 @@ const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
// 同步模型到数据库(创建表)
ProjectXmtzze.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -33,6 +33,22 @@ const Resources = sequelize.define('Resources', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_resources', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -25,6 +25,22 @@ const Depart = sequelize.define('Depart', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'system_depart', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -40,7 +40,7 @@ const ExcelRecord = sequelize.define('ExcelRecord', {
type: DataTypes.TEXT,
allowNull: true,
comment: "查询条件"
},
},
status: {
type: DataTypes.INTEGER,
comment: "1.未完成 2. 完成"
......@@ -53,6 +53,22 @@ const ExcelRecord = sequelize.define('ExcelRecord', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'system_excel_record', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -37,6 +37,22 @@ const File = sequelize.define('File', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'system_file', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
......@@ -19,12 +19,28 @@ const Position = sequelize.define('Position', {
type: DataTypes.STRING,
commnet: "职位名称",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'system_position', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -32,7 +48,7 @@ const Position = sequelize.define('Position', {
// 同步模型到数据库(创建表)
Position.sync({
force: false, // force: true 会删除已存在表并重新创建
force: false, // force: true 会删除已存在表并重新创建
// alter: true
})
.then(() => {
......
......@@ -27,6 +27,22 @@ const Role = sequelize.define('Role', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'system_role', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......
// models/User.js
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
const User = sequelize.define('User', {
// 定义字段
......@@ -41,6 +42,22 @@ const User = sequelize.define('User', {
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue? moment(rawValue).format('YYYY-MM-DD HH:mm:ss'): '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue? moment(rawValue).format('YYYY-MM-DD HH:mm:ss'): '';
}
}
}, {
tableName: 'system_user', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
......@@ -48,7 +65,7 @@ const User = sequelize.define('User', {
// 同步模型到数据库(创建表)
User.sync({
force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -17,7 +17,7 @@ const UserPosition = sequelize.define('UserPosition', {
},
posiId: {
type: DataTypes.INTEGER,
references: { model: UserPosition, key: 'id' }
references: { model: Position, key: 'id' }
}
}, {
tableName: 'system_user_position', // 指定表名(如果与模型名不同)
......@@ -26,7 +26,8 @@ const UserPosition = sequelize.define('UserPosition', {
// 同步模型到数据库(创建表)
UserPosition.sync({
// force: false, // force: true 会删除已存在表并重新创建
// force: false,
force: true //会删除已存在表并重新创建
// alter: true
})
.then(() => {
......
......@@ -10,10 +10,10 @@ async function setUserRole(userId, roleIds, roles) {
let dbIds = [], needAddIds = [], needDelIds = [];
for (let index = 0; index < roles.length; index++) {
const element = roles[index];
dbIds.push(element.roleId);
if (!roleIds.includes(element.roleId)) {
dbIds.push(element.id);
if (!roleIds.includes(element.id)) {
// 1. roleIds里面没有 但是关系表里有的 需要删除
needDelIds.push(element.roleId);
needDelIds.push(element.id);
}
}
for (let index = 0; index < roleIds.length; index++) {
......@@ -43,10 +43,10 @@ async function setUserDepart(userId, departIds, departs) {
let dbIds = [], needAddIds = [], needDelIds = [];
for (let index = 0; index < departs.length; index++) {
const element = departs[index];
dbIds.push(element.roleId);
if (!departIds.includes(element.roleId)) {
dbIds.push(element.id);
if (!departIds.includes(element.id)) {
// 1. departIds里面没有 但是关系表里有的 需要删除
needDelIds.push(element.roleId);
needDelIds.push(element.id);
}
}
for (let index = 0; index < departIds.length; index++) {
......@@ -76,10 +76,10 @@ async function setUserPosition(userId, positionIds, positions) {
let dbIds = [], needAddIds = [], needDelIds = [];
for (let index = 0; index < positions.length; index++) {
const element = positions[index];
dbIds.push(element.roleId);
if (!positionIds.includes(element.roleId)) {
dbIds.push(element.id);
if (!positionIds.includes(element.id)) {
// 1. departIds里面没有 但是关系表里有的 需要删除
needDelIds.push(element.roleId);
needDelIds.push(element.id);
}
}
for (let index = 0; index < positionIds.length; index++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment