清空权限和角色表数据:
按需执行,本地测试最好清空
Role.delete_all
Authority.delete_all
UsersRole.delete_all
RolesAuthority.delete_all
$redis.flushall
$redis.keys
Role.count
Authority.count
UsersRole.count
RolesAuthority.count
初始化权限和角色数据:
此命令会从excel初始化所有需要的数据
最新权限重新初始化代码,包含migrations中权限:
Authority.init
Authority.where(menu: ['agent_prepaid_orders_revise_fee_history',
'agent_subscribe_prepaid_orders_revise_fee_history',
'agent_acitvate_paid_statistics_revise_fee',
'agent_acitvate_paid_statistics_revise_fee_history',
'agent_order_statistics_revise_fee',
'agent_order_statistics_revise_fee_history']).destroy_all
params = { menu: 'agent_prepaid_orders_revise_fee_history',
menu_name: '开卡套餐预付账单金额修改历史',
controller: 'order_modified_histories',
action: 'index',
description: '开卡套餐预付账单金额修改历史' }
Authority.create_with_roles(params, ['top_profit','top_increase','top_direct','admin',
'sales', 'customer_service', 'finance', 'storekeeper', 'business', 'purchaser'], 'agents')
params = { menu: 'agent_subscribe_prepaid_orders_revise_fee_history',
menu_name: '批量订购预付账单金额修改历史',
controller: 'order_modified_histories',
action: 'index',
description: '批量订购预付账单金额修改历史' }
Authority.create_with_roles(params, ['top_profit','top_increase','top_direct','admin',
'sales', 'customer_service', 'finance', 'storekeeper', 'business', 'purchaser'], 'agents')
params = { menu: 'agent_acitvate_paid_statistics_revise_fee',
menu_name: '开卡套餐激活付账单修改金额',
controller: 'agent_activated_paid_order_statistics',
action: 'revise_fee',
description: '开卡套餐激活付账单修改金额' }
Authority.create_with_roles(params, ['finance'], 'agents')
params = { menu: 'agent_acitvate_paid_statistics_revise_fee_history',
menu_name: '开卡套餐激活付账单金额修改历史',
controller: 'order_modified_histories',
action: 'index',
description: '开卡套餐激活付账单金额修改历史' }
Authority.create_with_roles(params, ['top_profit','top_increase','top_direct','admin',
'sales', 'customer_service', 'finance', 'storekeeper', 'business', 'purchaser'], 'agents')
params = { menu: 'agent_order_statistics_revise_fee',
menu_name: '月账单修改金额',
controller: 'agent_order_statistics',
action: 'revise_fee',
description: '月账单修改金额' }
Authority.create_with_roles(params, ['finance'], 'agents')
params = { menu: 'agent_order_statistics_revise_fee_history',
menu_name: '月账单金额修改历史',
controller: 'order_modified_histories',
action: 'index',
description: '月账单金额修改历史' }
Authority.create_with_roles(params, ['top_profit','top_increase','top_direct','admin',
'sales', 'customer_service', 'finance', 'storekeeper', 'business', 'purchaser'], 'agents')
# 分销商记录收付款权限创建
params = { menu: 'self_agent_orders_pay',
menu_name: '分销商记录收付款',
controller: 'agent_orders',
action: 'pay',
description: '分销管理 -> 代理商 -> 财务信息 -> 记录收付款' }
Authority.create_with_roles(params, %w[top_increase top_profit], 'self_agents_own_agents')
# 平台编辑流量池别名权限创建
params = { menu: 'agent_traffic_pools_client_name_edit',
menu_name: '编辑流量池的名称' }
Authority.create_with_roles(params, %w[business admin super_admin], 'agents')
# 给分销商配置销售
params = { menu: 'configure_sales',
menu_name: '给分销商配置销售',
controller: 'agents',
action: 'configure_sales,save_configured_sales',
description: '销售管理 -> 公众/企业市场 -> 分销商列表 -> 配置销售' }
Authority.create_with_roles(params, %w[super_admin admin business], 'agents')
# 失效分销商账号
params = { menu: 'disable_agent_account',
menu_name: '失效分销商账号',
controller: 'agents',
action: 'disable',
description: '销售管理 -> 公众/企业市场 -> 分销商列表 -> 失效' }
Authority.create_with_roles(params, %w[super_admin admin business], 'agents')
# 生效分销商账号
params = { menu: 'enable_agent_account',
menu_name: '生效分销商账号',
controller: 'agents',
action: 'enable',
description: '销售管理 -> 公众/企业市场 -> 分销商列表 -> 生效' }
Authority.create_with_roles(params, %w[super_admin admin business], 'agents')
# 登录分销商账号
params = { menu: 'login_agent_account',
menu_name: '登录分销商账号',
description: '销售管理 -> 公众/企业市场 -> 分销商列表 -> 超级登录' }
Authority.create_with_roles(params, %w[super_admin admin sales customer_service finance storekeeper business purchaser], 'agents')
# 给分销商配置销售
params = { menu: 'authorities',
menu_name: '权限管理(列表)',
controller: 'authorities',
action: 'index',
description: '设置 -> 权限管理(列表)' }
Authority.create_with_roles(params, %w[super_admin], 'settings_menu')
rake authority:init_authority
User.all.each(&:save_authorities_to_redis)
XanderCheung
#1楼