CODE
1 year ago
5 changed files with 206 additions and 33 deletions
@ -0,0 +1,88 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const Device = sequelize.define("device", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "device_id_uindex" |
||||
|
}, |
||||
|
name: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "name", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
type: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "type", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
specification: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "规格\r\n", |
||||
|
primaryKey: false, |
||||
|
field: "specification", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
dateProduced: { |
||||
|
type: DataTypes.DATEONLY, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "生产日期", |
||||
|
primaryKey: false, |
||||
|
field: "date_produced", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
dateInstall: { |
||||
|
type: DataTypes.DATEONLY, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "安装日期", |
||||
|
primaryKey: false, |
||||
|
field: "date_install", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
dateGuarantee: { |
||||
|
type: DataTypes.DATEONLY, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "质保期", |
||||
|
primaryKey: false, |
||||
|
field: "date_guarantee", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
dateMainten: { |
||||
|
type: DataTypes.DATEONLY, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "维保期", |
||||
|
primaryKey: false, |
||||
|
field: "date_mainten", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "device", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.Device = Device; |
||||
|
return Device; |
||||
|
}; |
@ -0,0 +1,43 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const PointDevice = sequelize.define("pointDevice", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "point_device_id_uindex" |
||||
|
}, |
||||
|
pointId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "point_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
deviceId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "device_id", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "point_device", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.PointDevice = PointDevice; |
||||
|
return PointDevice; |
||||
|
}; |
@ -1,35 +1,35 @@ |
|||||
module.exports = { |
module.exports = { |
||||
// 数据库配置 与 sequelize 相同
|
// 数据库配置 与 sequelize 相同
|
||||
dbOptions: { |
dbOptions: { |
||||
database: 'Inspection', |
database: 'Inspection_20231016', |
||||
username: 'FashionAdmin', |
username: 'FashionAdmin', |
||||
password: '123456', |
password: '123456', |
||||
dialect: 'postgres', |
dialect: 'postgres', |
||||
host: '10.8.30.39', |
host: '10.8.30.39', |
||||
port: 5432, |
port: 5432, |
||||
define: { |
define: { |
||||
underscored: false, |
underscored: false, |
||||
freezeTableName: false, |
freezeTableName: false, |
||||
charset: 'utf8mb4', |
charset: 'utf8mb4', |
||||
timezone: '+00: 00', |
timezone: '+00: 00', |
||||
dialectOptions: { |
dialectOptions: { |
||||
collate: 'utf8_general_ci', |
collate: 'utf8_general_ci', |
||||
}, |
}, |
||||
timestamps: false, |
timestamps: false, |
||||
}, |
}, |
||||
}, |
}, |
||||
options: { |
options: { |
||||
type: 'freesun', // 指定 models 代码风格
|
type: 'freesun', // 指定 models 代码风格
|
||||
camelCase: true, // Models 文件中代码是否使用驼峰命名
|
camelCase: true, // Models 文件中代码是否使用驼峰命名
|
||||
modalNameSuffix: false, // 模型名称是否带 ‘Model’ 后缀
|
modalNameSuffix: false, // 模型名称是否带 ‘Model’ 后缀
|
||||
fileNameCamelCase: false, // Model 文件名是否使用驼峰法命名,默认文件名会使用表名,如 `user_post.js`;如果为 true,则文件名为 `userPost.js`
|
fileNameCamelCase: false, // Model 文件名是否使用驼峰法命名,默认文件名会使用表名,如 `user_post.js`;如果为 true,则文件名为 `userPost.js`
|
||||
dir: './app/lib/models', // 指定输出 models 文件的目录
|
dir: './app/lib/models', // 指定输出 models 文件的目录
|
||||
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
|
typesDir: 'models', // 指定输出 TypeScript 类型定义的文件目录,只有 TypeScript / Midway 等会有类型定义
|
||||
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
|
emptyDir: false, // !!! 谨慎操作 生成 models 之前是否清空 `dir` 以及 `typesDir`
|
||||
tables: ['patrol_plan'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
|
tables: ['device', 'point_device'], // 指定生成哪些表的 models,如 ['user', 'user_post'];如果为 null,则忽略改属性
|
||||
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
|
skipTables: [], // 指定跳过哪些表的 models,如 ['user'];如果为 null,则忽略改属性
|
||||
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
|
tsNoCheck: false, // 是否添加 `@ts-nocheck` 注释到 models 文件中
|
||||
ignorePrefix: ['t_',], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面
|
ignorePrefix: ['t_',], // 生成的模型名称忽略的前缀,因为 项目中有以下表名是以 t_ 开头的,在实际模型中不需要, 可以添加多个 [ 't_data_', 't_',] ,长度较长的 前缀放前面
|
||||
attrLength: false, // 在生成模型的字段中 是否生成 如 var(128)这种格式,公司一般使用 String ,则配置为 false
|
attrLength: false, // 在生成模型的字段中 是否生成 如 var(128)这种格式,公司一般使用 String ,则配置为 false
|
||||
}, |
}, |
||||
} |
} |
@ -0,0 +1,28 @@ |
|||||
|
create table if not exists device |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint device_pk |
||||
|
primary key, |
||||
|
name varchar(256) not null, |
||||
|
type varchar(128) not null, |
||||
|
specification varchar(256), |
||||
|
date_produced date, |
||||
|
date_install date, |
||||
|
date_guarantee date, |
||||
|
date_mainten date |
||||
|
); |
||||
|
|
||||
|
comment on column device.specification is '规格 |
||||
|
'; |
||||
|
|
||||
|
comment on column device.date_produced is '生产日期'; |
||||
|
|
||||
|
comment on column device.date_install is '安装日期'; |
||||
|
|
||||
|
comment on column device.date_guarantee is '质保期'; |
||||
|
|
||||
|
comment on column device.date_mainten is '维保期'; |
||||
|
|
||||
|
create unique index if not exists device_id_uindex |
||||
|
on device (id); |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
create table if not exists point_device |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint point_device_pk |
||||
|
primary key, |
||||
|
point_id integer not null, |
||||
|
device_id integer |
||||
|
); |
||||
|
|
||||
|
comment on table point_device is '点位-设备关联表'; |
||||
|
|
||||
|
create unique index if not exists point_device_id_uindex |
||||
|
on point_device (id); |
||||
|
|
Loading…
Reference in new issue