83 lines
1.6 KiB
JavaScript
83 lines
1.6 KiB
JavaScript
const db = require("../../middleware/db");
|
||
const Sequelize = require("sequelize");
|
||
|
||
module.exports = sys_model_field = db.define("sys_model_field", {
|
||
model_id: {
|
||
type: Sequelize.INTEGER(11).UNSIGNED,
|
||
allowNull: false,
|
||
defaultValue: "0",
|
||
comment: "模型Id",
|
||
},
|
||
|
||
key: {
|
||
type: Sequelize.STRING(50),
|
||
allowNull: false,
|
||
defaultValue: "",
|
||
comment: "字段Key",
|
||
},
|
||
name: {
|
||
type: Sequelize.STRING(50),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: "名称",
|
||
},
|
||
// 控件
|
||
control: {
|
||
type: Sequelize.JSON,
|
||
allowNull: false,
|
||
defaultValue: "{}",
|
||
comment: "控件",
|
||
set(value) {
|
||
this.setDataValue("control", { value });
|
||
},
|
||
get() {
|
||
let jsonValue = this.getDataValue("control");
|
||
if (jsonValue && jsonValue.value !== undefined) {
|
||
return jsonValue.value;
|
||
} else {
|
||
return jsonValue;
|
||
}
|
||
},
|
||
},
|
||
// 排序
|
||
sort: {
|
||
type: Sequelize.INTEGER(11),
|
||
allowNull: false,
|
||
defaultValue: 1,
|
||
comment: "排序",
|
||
},
|
||
// 类型
|
||
data_type: {
|
||
type: Sequelize.STRING(50),
|
||
allowNull: false,
|
||
defaultValue: "0",
|
||
comment: "数据类型",
|
||
},
|
||
|
||
//数据长度
|
||
data_length: {
|
||
type: Sequelize.INTEGER(11),
|
||
allowNull: false,
|
||
defaultValue: 50,
|
||
comment: "数据长度",
|
||
},
|
||
|
||
//是否为空 0 为空 , 1 不允许为空
|
||
allow_null: {
|
||
type: Sequelize.INTEGER(1),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: "是否为空",
|
||
},
|
||
|
||
// 默认值
|
||
default_value: {
|
||
type: Sequelize.STRING(50),
|
||
allowNull: false,
|
||
defaultValue: "",
|
||
comment: "默认值",
|
||
},
|
||
});
|
||
|
||
// sys_model_field.sync({ force: true });
|