
const Sequelize = require("sequelize");
// db日志管理
module.exports = (db) => {
  return db.define("sys_log", {
    table_name: {
      type: Sequelize.STRING(100),
      allowNull: false,
      defaultValue: "",
  },
    operate: {
      type: Sequelize.STRING(100),
      allowNull: false,
      defaultValue: "",
  },
    content: {
      type: Sequelize.JSON,
      allowNull: false,
      defaultValue: "",
      set(value) {
        this.setDataValue("content", { value });
      },
      get() {
        let jsonValue = this.getDataValue("content");
        if (jsonValue && jsonValue.value !== undefined) {
          return jsonValue.value;
        } else {
          return jsonValue;
        }
      },
  },
  });
};

