1.0.2 • Published 3 years ago

rbac-sequelize-mysql v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

开发中,暂无法使用

alt 属性文本

install

npm install --save rbac-sequelize-mysql

use

const express = require("express");
const option={}
const { rbacSequelizeMysql, config } = require('rbac-sequelize-mysql').init(option)
const app = express()
app.use(rbacSequelizeMysql)

注:rbacSequelizeMysql 为中间件实例,config 为经过中间件处理过后的标准 option 信息

option

参数类型是否必填意义
hostIP数据库 IP
database字符串数据库名称
user字符串数据库用户名
password字符串数据库访问密码
saas布尔是否开启 saas 模式,默认否
dept布尔是否开启部门功能,默认否
paranoid布尔是否开启软删除模式,默认否
api对象接口地址
table对象表名

api

参数类型默认意义可选值
method枚举false所有接口的提交类型false,'post','get','put','delete'

table

参数类型默认意义
api字符串sys_api所有接口列表
authority字符串sys_authority权限码表
permission字符串sys_permission授权表,用于用户表绑定
role字符串sys_role角色表,
permission_role字符串sys_permission_role角色授权中间表
dept字符串sys_dept部门表(仅在开启部门功能后生效)
dept_role字符串sys_dept_role部门授权中间表(仅在开启部门功能后生效)

option 完整参数

{
  host: '',
  database: '',
  user: '',
  password: '',
  saas:false,
  dept:false,
  paranoid:false,
  api: {
    method:false,
    api: {
      init: { url: '/api/init', method: 'post' },
      sync: { url: '/api/sync', method: 'post' },
      list: { url: '/api/list', method: 'get' },
      save: { url: '/api/save', method: 'post' },
      del: { url: '/api/del', method: 'post' },
    },
    authority: {
      init: { url: '/authority/init', method: 'post' },
      sync: { url: '/authority/sync', method: 'post' },
      list: { url: '/authority/list', method: 'get' },
      save: { url: '/authority/save', method: 'post' },
      del: { url: '/authority/del', method: 'post' },
    },
    permission: {
      init: { url: '/permission/init', method: 'post' },
      sync: { url: '/permission/sync', method: 'post' },
      list: { url: '/permission/list', method: 'get' },
      save: { url: '/permission/save', method: 'post' },
      del: { url: '/permission/del', method: 'post' },
    },
    role: {
      init: { url: '/role/init', method: 'post' },
      sync: { url: '/role/sync', method: 'post' },
      list: { url: '/role/list', method: 'get' },
      save: { url: '/role/save', method: 'post' },
      del: { url: '/role/del', method: 'post' },
    },
    dept: {
      init: { url: '/dept/init', method: 'post' },
      sync: { url: '/dept/sync', method: 'post' },
      list: { url: '/dept/list', method: 'get' },
      save: { url: '/dept/save', method: 'post' },
      del: { url: '/dept/del', method: 'post' },
    },
  },
  table: {
    api: 'sys_api',
    authority: 'sys_authority',
    permission: 'sys_permission',
    role: 'sys_role',
    permission_role: 'sys_permission_role',
    dept: 'sys_dept',
    dept_role: 'sys_dept_role',
  },
}