
const Sequelize = require("sequelize");
//角色表
module.exports = (db) => {
  return db.define("sys_role", {
    name: {
      type: Sequelize.STRING(100),
      allowNull: false,
      defaultValue: "",
  },
  // 0 普通角色 1 系统角色
    type: {
      type: Sequelize.INTEGER(1),
      allowNull: false,
      defaultValue: "0",
  },
    menus: {
      type: Sequelize.JSON,
      allowNull: false,
      defaultValue: "",
      set(value) {
        this.setDataValue('menus', { value });
      },
      get() {
        let jsonValue = this.getDataValue("menus")
        if (jsonValue && jsonValue.value !== undefined) {

          return jsonValue.value;
        }
        else {
          return jsonValue
        }
      }
  },
  });
};


