Files
platformV2Web/api/model/sys_model_field.js
张成 8309808835 1
2025-11-21 16:53:49 +08:00

83 lines
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 });