1. 程式人生 > 實用技巧 >yh-radius 開源計費系統

yh-radius 開源計費系統

yh-radius 開源計費系統

來源https://zhuanlan.zhihu.com/p/74180109

https://gitee.com/lsgx/yh-radius

https://github.com/cometowell/yh-radius

https://github.com/cometowell/yh-radius-web

yh-radius 是一個使用golang語言開發的radius協議實現,目前已適配華為,思科,中興,RouterOS(MikroTik)以及標準協議,其他廠商協議後續陸續補充。

==============

Windows 平臺下簡易測試步驟:

1. 下載radius-release-windows-x64-v0.2.zip 和radius-release-web-v0.2.zip

2. 將radius-v2.sql 導 MySql 的radius-v2 庫,初始化庫的表結構。

/*
Navicat MySQL Data Transfer

Source Server         : localhost
Source Server Version : 50721
Source Host           : localhost:3306
Source Database       : radius-v2

Target Server Type    : MYSQL
Target Server Version : 50721
File Encoding         : 65001

Date: 2019-07-15 09:59:37
*/ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for rad_area -- ---------------------------- DROP TABLE IF EXISTS `rad_area`; CREATE TABLE `rad_area` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `code` varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '編碼', `name` varchar
(200) COLLATE utf8mb4_bin NOT NULL COMMENT '大區名', `status` int(11) NOT NULL DEFAULT '1' COMMENT '狀態,1:正常,2:停用', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '更新時間', `description` varchar(1000) COLLATE utf8mb4_bin DEFAULT '' COMMENT '描述', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='使用者片區劃分表'; -- ---------------------------- -- Records of rad_area -- ---------------------------- INSERT INTO `rad_area` VALUES ('1', 'test', '測試片區', '1', '2019-07-04 15:44:06', '2019-07-05 10:52:56', '測試片區'); INSERT INTO `rad_area` VALUES ('4', 'test2', '測試2', '1', '2019-07-11 11:29:26', null, '測試2'); -- ---------------------------- -- Table structure for rad_nas -- ---------------------------- DROP TABLE IF EXISTS `rad_nas`; CREATE TABLE `rad_nas` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `vendor_id` int(11) NOT NULL COMMENT '廠商ID', `name` varchar(60) NOT NULL COMMENT '名稱', `ip_addr` varchar(15) NOT NULL COMMENT 'IP地址', `secret` varchar(20) NOT NULL COMMENT '共享祕鑰', `authorize_port` int(11) NOT NULL DEFAULT '3799' COMMENT '授權埠,預設3799', `description` varchar(512) DEFAULT NULL COMMENT '描述', PRIMARY KEY (`id`), UNIQUE KEY `uk_nas_ip` (`ip_addr`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8 COMMENT='NAS網路接入裝置表'; -- ---------------------------- -- Records of rad_nas -- ---------------------------- INSERT INTO `rad_nas` VALUES ('2', '9', 'test', '127.0.0.1', '123456', '3699', 'test'); INSERT INTO `rad_nas` VALUES ('99', '2011', 'test2', '10.18.10.68', '123456', '3799', 'mycat test'); -- ---------------------------- -- Table structure for rad_online_user -- ---------------------------- DROP TABLE IF EXISTS `rad_online_user`; CREATE TABLE `rad_online_user` ( `id` bigint(2) NOT NULL AUTO_INCREMENT, `username` varchar(64) NOT NULL COMMENT '賬號', `nas_ip_addr` varchar(15) NOT NULL COMMENT 'NAS IP地址', `acct_session_id` varchar(128) NOT NULL COMMENT '計費session id', `start_time` datetime NOT NULL COMMENT '開始計費時間', `used_duration` int(11) NOT NULL DEFAULT '0' COMMENT '已計費時長', `ip_addr` varchar(15) NOT NULL COMMENT '使用者IP地址', `mac_addr` varchar(19) NOT NULL COMMENT '使用者MAC地址', `nas_port_id` varchar(128) DEFAULT NULL COMMENT '標識使用者認證埠', `total_up_stream` bigint(20) NOT NULL DEFAULT '0' COMMENT '上行總流量 KB', `total_down_stream` bigint(20) NOT NULL DEFAULT '0' COMMENT '下行總流量,KB', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 COMMENT='線上使用者表'; -- ---------------------------- -- Records of rad_online_user -- ---------------------------- INSERT INTO `rad_online_user` VALUES ('39', 'test1', '10.18.10.68', '0001', '2019-07-11 10:30:37', '0', '192.168.10.235', '5C:FF:35:0E:58:A5', 'sdafsadfasdfasfasfdas', '1888888', '8990000'); -- ---------------------------- -- Table structure for rad_product -- ---------------------------- DROP TABLE IF EXISTS `rad_product`; CREATE TABLE `rad_product` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(60) NOT NULL COMMENT '產品名稱', `type` int(11) NOT NULL COMMENT '型別:1:包月 2:自由時長,3:流量', `status` int(11) NOT NULL COMMENT '狀態,0:停用,1:正常', `should_bind_mac_addr` tinyint(1) NOT NULL DEFAULT '0' COMMENT '需要繫結MAC地址,0:N,1:Y', `should_bind_vlan` tinyint(1) NOT NULL DEFAULT '0' COMMENT '需要繫結虛擬區域網,0:N,1:Y', `concurrent_count` int(11) NOT NULL DEFAULT '0' COMMENT '併發數', `product_duration` bigint(20) NOT NULL DEFAULT '0' COMMENT '時長,單位秒', `service_month` int(11) NOT NULL DEFAULT '0' COMMENT '套餐購買月數', `product_flow` bigint(20) NOT NULL DEFAULT '0' COMMENT '流量,單位KB', `flow_clear_cycle` tinyint(1) NOT NULL COMMENT '計費週期;1:預設, 2:日,3:月:4:固定(開通至使用時長截止[使用者套餐過期時間])', `price` int(11) NOT NULL DEFAULT '0' COMMENT '產品價格,單位分', `up_stream_limit` bigint(20) NOT NULL COMMENT '上行流量限制,單位Mbps', `down_stream_limit` bigint(20) NOT NULL COMMENT '下行流量限制,單位Mbps', `domain_name` varchar(200) DEFAULT NULL COMMENT '使用者域', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '建立時間', `description` varchar(512) DEFAULT NULL COMMENT '描述', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8 COMMENT='產品表'; -- ---------------------------- -- Records of rad_product -- ---------------------------- INSERT INTO `rad_product` VALUES ('10', '測試套餐1', '1', '1', '1', '1', '1', '0', '12', '0', '0', '9000', '8', '8', 'ccc', '2019-07-08 15:26:21', '2019-07-08 15:31:42', '測試描述'); INSERT INTO `rad_product` VALUES ('11', '流量套餐', '3', '1', '1', '1', '0', '0', '0', '102400000', '1', '1800', '8', '8', '', '2019-07-08 17:40:40', null, '流量套餐'); -- ---------------------------- -- Table structure for rad_town -- ---------------------------- DROP TABLE IF EXISTS `rad_town`; CREATE TABLE `rad_town` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `area_id` bigint(20) NOT NULL COMMENT '片區ID', `code` varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '編碼', `name` varchar(200) COLLATE utf8mb4_bin NOT NULL COMMENT '大區名', `status` int(11) NOT NULL DEFAULT '1' COMMENT '狀態,1:正常,2:停用', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '修改時間', `description` varchar(1000) COLLATE utf8mb4_bin DEFAULT '' COMMENT '描述', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='村鎮/街道,片區下級單位表'; -- ---------------------------- -- Records of rad_town -- ---------------------------- INSERT INTO `rad_town` VALUES ('1', '1', 'test', '測試街道', '1', '2019-07-04 15:43:21', '2019-07-05 15:02:57', '測試街道'); INSERT INTO `rad_town` VALUES ('5', '4', 'test2', '測試街道2', '1', '2019-07-11 11:32:55', null, '測試街道2'); -- ---------------------------- -- Table structure for rad_user -- ---------------------------- DROP TABLE IF EXISTS `rad_user`; CREATE TABLE `rad_user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主鍵', `username` varchar(64) NOT NULL COMMENT '賬號', `real_name` varchar(128) DEFAULT NULL COMMENT '姓名', `town_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '村鎮/街道ID', `password` varchar(256) NOT NULL COMMENT '密碼', `product_id` bigint(20) DEFAULT NULL COMMENT '產品ID', `status` int(11) NOT NULL COMMENT '狀態,1:正常,2:停機,3:禁用,4:銷戶', `available_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '可用時長,單位:秒', `available_flow` bigint(20) NOT NULL DEFAULT '0' COMMENT '可用流量,單位KB', `expire_time` date DEFAULT NULL COMMENT '到期時間', `concurrent_count` int(11) NOT NULL DEFAULT '0' COMMENT '併發數', `should_bind_mac_addr` tinyint(1) NOT NULL DEFAULT '0' COMMENT '需要繫結MAC地址,1:Y,2:N', `should_bind_vlan` tinyint(1) NOT NULL DEFAULT '0' COMMENT '需要繫結虛擬區域網,1:Y,2:N', `mac_addr` varchar(19) DEFAULT NULL COMMENT 'MAC地址', `vlan_id` int(11) DEFAULT '0' COMMENT 'vlanId1', `vlan_id2` int(11) DEFAULT '0' COMMENT 'vlanId2', `framed_ip_addr` varchar(15) DEFAULT NULL COMMENT '使用者繫結的靜態IP地址', `installed_addr` varchar(256) DEFAULT NULL COMMENT '裝機地址', `mobile` varchar(12) DEFAULT NULL COMMENT '手機號碼', `email` varchar(200) DEFAULT NULL COMMENT '電子郵件', `pause_time` datetime DEFAULT NULL COMMENT '最近停機時間', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '更新時間', `description` varchar(512) DEFAULT NULL COMMENT '描述', PRIMARY KEY (`id`), UNIQUE KEY `uk_user_name` (`username`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8 COMMENT='使用者表'; -- ---------------------------- -- Records of rad_user -- ---------------------------- INSERT INTO `rad_user` VALUES ('20', 'test1', '測試', '1', 'kjjSLcA0XhsYbz6ztm6xaA==', '10', '1', '0', '0', '2022-07-08', '1', '1', '1', '', '0', '0', '', 'test', '', '', null, '2019-07-05 17:28:56', null, ''); INSERT INTO `rad_user` VALUES ('21', 'test2', '測試2', '1', 'kjjSLcA0XhsYbz6ztm6xaA==', '10', '1', '0', '0', '2020-07-08', '1', '1', '1', '', '0', '0', '', 'ceshi2', '', '', null, '2019-07-08 17:45:47', null, ''); INSERT INTO `rad_user` VALUES ('22', 'test3', 'ceshi3', '1', 'kjjSLcA0XhsYbz6ztm6xaA==', '11', '1', '0', '102400000', '2099-12-31', '0', '1', '1', '', '0', '0', '', 'sdffsf', '', '', null, '2019-07-10 17:49:04', null, ''); INSERT INTO `rad_user` VALUES ('23', 'test33', '測試3', '5', 'kjjSLcA0XhsYbz6ztm6xaA==', '10', '1', '0', '0', '2020-07-11', '1', '1', '1', '', '0', '0', '', 'ceshi', '', '', null, '2019-07-11 11:33:21', null, ''); -- ---------------------------- -- Table structure for rad_user_balance -- ---------------------------- DROP TABLE IF EXISTS `rad_user_balance`; CREATE TABLE `rad_user_balance` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user_wallet_id` bigint(20) DEFAULT NULL COMMENT '使用者錢包ID', `type` int(11) DEFAULT NULL COMMENT '型別1: 專項套餐,2:無限使用', `product_id` bigint(20) DEFAULT NULL COMMENT '產品ID', `balance` int(11) DEFAULT NULL COMMENT '餘額', `expire_time` datetime DEFAULT NULL COMMENT '金額過期時間', PRIMARY KEY (`id`), UNIQUE KEY `user_wallet_id` (`user_wallet_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='使用者餘額表'; -- ---------------------------- -- Records of rad_user_balance -- ---------------------------- -- ---------------------------- -- Table structure for rad_user_online_log -- ---------------------------- DROP TABLE IF EXISTS `rad_user_online_log`; CREATE TABLE `rad_user_online_log` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL COMMENT '賬號', `start_time` datetime NOT NULL COMMENT '開始時間', `stop_time` datetime DEFAULT NULL COMMENT '結束時間', `used_duration` int(11) NOT NULL DEFAULT '0' COMMENT '使用時長,單位秒', `total_up_stream` int(11) NOT NULL DEFAULT '0' COMMENT '上行流量,單位KB', `total_down_stream` int(11) NOT NULL DEFAULT '0' COMMENT '下行流量,單位KB', `ip_addr` varchar(15) DEFAULT NULL COMMENT '使用者IP地址', `mac_addr` varchar(17) DEFAULT NULL COMMENT '使用者MAC地址', `nas_ip_addr` varchar(15) DEFAULT NULL COMMENT 'nas ip地址', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='使用者上網記錄'; -- ---------------------------- -- Records of rad_user_online_log -- ---------------------------- -- ---------------------------- -- Table structure for rad_user_order_record -- ---------------------------- DROP TABLE IF EXISTS `rad_user_order_record`; CREATE TABLE `rad_user_order_record` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user_id` bigint(20) NOT NULL COMMENT '使用者id', `product_id` bigint(20) NOT NULL COMMENT '產品id', `price` int(11) NOT NULL COMMENT '價格,單位:分', `sys_user_id` bigint(20) NOT NULL COMMENT '操作管理員', `order_time` datetime NOT NULL COMMENT '訂單時間', `status` tinyint(1) NOT NULL DEFAULT '2' COMMENT '1:預定,2: 已生效,3:已取消', `end_date` date NOT NULL COMMENT '訂單截止日期', `count` int(11) NOT NULL DEFAULT '1' COMMENT '套餐倍數', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8 COMMENT='使用者訂單表'; -- ---------------------------- -- Records of rad_user_order_record -- ---------------------------- INSERT INTO `rad_user_order_record` VALUES ('51', '20', '10', '9000', '1', '2019-07-08 17:28:56', '2', '2020-07-08', '0'); INSERT INTO `rad_user_order_record` VALUES ('54', '20', '10', '9000', '1', '2019-07-08 17:39:18', '2', '2022-07-08', '1'); INSERT INTO `rad_user_order_record` VALUES ('55', '20', '11', '1800', '1', '2019-07-08 17:43:52', '1', '2099-12-31', '1'); INSERT INTO `rad_user_order_record` VALUES ('56', '21', '10', '9000', '1', '2019-07-08 17:45:47', '2', '2020-07-08', '0'); INSERT INTO `rad_user_order_record` VALUES ('57', '22', '11', '1800', '1', '2019-07-08 17:49:04', '2', '2099-12-31', '1'); INSERT INTO `rad_user_order_record` VALUES ('58', '23', '10', '9000', '1', '2019-07-11 11:33:21', '2', '2020-07-11', '1'); -- ---------------------------- -- Table structure for rad_user_special_balance -- ---------------------------- DROP TABLE IF EXISTS `rad_user_special_balance`; CREATE TABLE `rad_user_special_balance` ( `Id` bigint(20) NOT NULL AUTO_INCREMENT, `user_wallet_id` bigint(20) DEFAULT NULL COMMENT '使用者錢包ID', `type` int(11) DEFAULT NULL COMMENT '型別1: 專項套餐,2:無限使用', `product_id` bigint(20) DEFAULT NULL COMMENT '產品ID', `balance` int(11) DEFAULT NULL COMMENT '餘額', `expire_time` datetime DEFAULT NULL COMMENT '金額過期時間', PRIMARY KEY (`Id`), UNIQUE KEY `user_wallet_id` (`user_wallet_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of rad_user_special_balance -- ---------------------------- -- ---------------------------- -- Table structure for rad_user_wallet -- ---------------------------- DROP TABLE IF EXISTS `rad_user_wallet`; CREATE TABLE `rad_user_wallet` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `user_id` bigint(20) DEFAULT NULL COMMENT '使用者ID', `payment_password` varchar(256) DEFAULT NULL COMMENT '支付密碼', PRIMARY KEY (`id`), UNIQUE KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='使用者錢包表'; -- ---------------------------- -- Records of rad_user_wallet -- ---------------------------- -- ---------------------------- -- Table structure for sys_department -- ---------------------------- DROP TABLE IF EXISTS `sys_department`; CREATE TABLE `sys_department` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主鍵', `code` varchar(64) NOT NULL COMMENT '部門編碼', `name` varchar(128) NOT NULL COMMENT '部門名稱', `parent_id` bigint(20) NOT NULL COMMENT '上級部門ID', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '修改時間', `description` varchar(512) DEFAULT NULL COMMENT '描述', `status` int(1) NOT NULL DEFAULT '1' COMMENT '1:正常,2:停用', PRIMARY KEY (`id`), UNIQUE KEY `uk_code` (`code`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='部門表'; -- ---------------------------- -- Records of sys_department -- ---------------------------- INSERT INTO `sys_department` VALUES ('1', 'test', '測試', '0', '2019-07-03 15:53:29', '2019-07-08 15:50:36', '發發發22', '1'); -- ---------------------------- -- Table structure for sys_resource -- ---------------------------- DROP TABLE IF EXISTS `sys_resource`; CREATE TABLE `sys_resource` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `parent_id` bigint(20) DEFAULT NULL COMMENT '父級選單', `name` varchar(255) NOT NULL COMMENT '選單名稱', `icon` varchar(255) DEFAULT NULL COMMENT '圖示', `url` varchar(256) DEFAULT NULL COMMENT 'URL地址', `type` tinyint(1) NOT NULL COMMENT '選單型別,1:模組,2:欄目,3:按鈕', `enable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否啟用,1:啟用,0:關閉', `perm_mark` varchar(255) DEFAULT NULL COMMENT '許可權標誌,可用於shiro註解', `sort_order` int(11) NOT NULL DEFAULT '1' COMMENT '排序順序', `description` varchar(512) DEFAULT NULL COMMENT '描述', `should_perm_control` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否需要許可權控制,1:需要,0:不需要', `level` tinyint(1) NOT NULL COMMENT '層次', `front_router` varchar(200) DEFAULT NULL COMMENT '前端路由', `front_key` varchar(255) DEFAULT NULL COMMENT '前端路由key', `show` int(11) NOT NULL DEFAULT '1' COMMENT '是否展示選單,1:是, 2:否', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=505 DEFAULT CHARSET=utf8 COMMENT='選單表'; -- ---------------------------- -- Records of sys_resource -- ---------------------------- INSERT INTO `sys_resource` VALUES ('100', '0', '使用者管理', 'team', '/user/list', '2', '1', 'user::list', '100', '使用者管理', '1', '1', '/user', 'user', '1'); INSERT INTO `sys_resource` VALUES ('110', '100', '新增使用者', '', '/user/add', '3', '1', 'user::add', '110', '新增使用者', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('120', '100', '修改使用者', '', '/user/update', '3', '1', 'user::list', '120', '修改使用者', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('130', '100', '刪除使用者', null, '/user/delete', '3', '1', 'user::delete', '130', '刪除使用者', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('140', '100', '獲取使用者資訊', '', '/user/info', '3', '1', 'user::info', '130', '獲取使用者資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('150', '100', '使用者續訂', null, '/user/continue', '3', '1', 'user::continue', '1', '使用者續訂', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('160', '100', '獲取使用者訂購記錄', null, '/user/order/record', '3', '1', 'user::order::record', '160', '獲取使用者訂購記錄', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('200', '0', '套餐管理', 'shopping', '/product/list', '2', '1', 'product::list', '200', '套餐管理', '1', '1', '/product', 'product', '1'); INSERT INTO `sys_resource` VALUES ('210', '200', '新增套餐', '', '/product/add', '3', '1', 'product::add', '200', '新增套餐', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('220', '200', '套餐資訊', '', '/product/info', '3', '1', 'product::add', '200', '新增套餐', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('230', '200', '修改套餐', '', '/product/update', '3', '1', 'product::add', '200', '新增套餐', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('240', '200', '刪除套餐', '', '/product/delete', '3', '1', 'product::add', '200', '新增套餐', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('250', '200', '獲取套餐列表', '', '/fetch/product', '3', '1', 'product::fetch', '200', '獲取套餐列表', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('300', '0', '線上使用者', 'global', '/online/list', '2', '1', 'online::list', '300', '線上使用者', '1', '1', '/online', 'online', '1'); INSERT INTO `sys_resource` VALUES ('310', '300', '使用者下線', '', '/online/off', '2', '1', 'online::off', '310', '使用者下線', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('320', '300', '清理線上使用者', null, '/online/delete', '3', '1', 'online::delete', '300', '清理線上使用者', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('400', '0', '系統設定', 'setting', '', '1', '1', '', '400', '系統設定', '1', '1', null, 'system', '1'); INSERT INTO `sys_resource` VALUES ('410', '400', '管理員', 'user', '/system/user/list', '2', '1', 'manager::list', '410', '管理員', '1', '2', '/sysUser', 'manager', '1'); INSERT INTO `sys_resource` VALUES ('411', '410', '新增管理員', null, '/system/user/add', '3', '1', 'manager::add', '410', '新增管理員', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('412', '410', '修改管理員', null, '/system/user/update', '3', '1', 'manager::update', '410', '修改管理員', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('413', '410', '刪除管理員', null, '/system/user/delete', '3', '1', 'manager::delete', '410', '刪除管理員', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('414', '410', '獲取管理員資訊', null, '/system/user/info', '3', '1', 'manager::info', '410', '獲取管理員資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('415', '410', '修改管理員密碼', null, '/system/user/change/password', '3', '1', '/manager::change::password', '410', '修改管理員密碼', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('416', '410', '獲取會話使用者資訊', null, '/system/user/session/info', '3', '1', 'system::user::session::info', '416', null, '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('420', '400', 'NAS管理', 'database', '/nas/list', '2', '1', 'nas::list', '420', 'NAS管理', '1', '2', '/nas', 'nas', '1'); INSERT INTO `sys_resource` VALUES ('421', '420', '新增NAS', null, '/nas/add', '3', '1', 'nas::add', '420', '新增NAS', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('422', '420', '修改NAS', null, '/nas/update', '3', '1', 'nas::update', '420', '修改NAS', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('423', '420', '刪除NAS', null, '/nas/delete', '3', '1', 'nas::delete', '420', '刪除NAS', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('424', '420', '獲取NAS資訊', null, '/nas/info', '3', '1', 'nas::info', '420', '獲取NAS資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('430', '400', '部門管理', 'appstore', '/department/list', '2', '1', 'department::list', '430', '部門管理', '1', '2', '/department', 'department', '1'); INSERT INTO `sys_resource` VALUES ('431', '430', '新增部門', null, '/department/add', '3', '1', 'department::add', '430', '新增部門', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('432', '430', '修改部門', null, '/department/update', '3', '1', 'department::update', '430', '修改部門', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('433', '430', '刪除部門', null, '/department/delete', '3', '1', 'department::delete', '430', '刪除部門', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('434', '430', '獲取部門列表', null, '/fetch/department', '3', '1', 'department::fetch', '430', '獲取部門列表', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('435', '430', '部門資訊', null, '/department/info', '2', '1', 'department::info', '430', '部門資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('440', '400', '角色管理', 'solution', '/role/list', '2', '1', 'role::list', '440', '角色管理', '1', '2', '/role', 'role', '1'); INSERT INTO `sys_resource` VALUES ('441', '440', '新增角色', null, '/role/add', '3', '1', 'role::add', '440', '新增角色', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('442', '440', '獲取角色資訊', null, '/role/info', '3', '1', 'role::info', '440', '獲取角色資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('443', '440', '修改角色', null, '/role/update', '3', '1', 'role::update', '440', '修改角色', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('444', '440', '刪除角色', null, '/role/delete', '3', '1', 'role::delete', '440', '刪除角色', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('445', '440', '角色賦權', null, '/role/empower/\\d+', '3', '1', 'role::empower', '440', '角色賦權', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('446', '440', '獲取角色許可權', null, '/role/resources', '3', '1', 'role::resource', '440', '獲取角色許可權', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('447', '440', '構建選單', null, '/session/resource', '3', '1', 'session::resource', '440', '構建選單', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('450', '400', '選單管理', 'profile', '/resource/list', '2', '1', 'resource::list', '450', '選單管理', '1', '2', '/resource', 'resource', '1'); INSERT INTO `sys_resource` VALUES ('460', '400', '片區管理', null, '/area/list', '2', '1', 'area::list', '460', '部門管理', '1', '2', '/area', 'area', '1'); INSERT INTO `sys_resource` VALUES ('461', '460', '新增片區', null, '/area/add', '3', '1', 'area::add', '461', '新增片區', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('462', '460', '修改片區', null, '/area/update', '3', '1', 'area::update', '462', '修改片區', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('463', '460', '刪除片區', null, '/area/delete', '3', '1', 'area::delete', '463', '刪除片區', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('464', '460', '獲取片區列表', null, '/fetch/areas', '3', '1', 'area::fetch', '464', '獲取片區列表', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('465', '460', '片區資訊', null, '/area/info', '2', '1', 'area::info', '465', '片區資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('470', '400', '村鎮街道管理', null, '/town/list', '2', '1', 'town::list', '470', '村鎮街道管理', '1', '2', '/town', 'town', '1'); INSERT INTO `sys_resource` VALUES ('471', '470', '新增村鎮街道', null, '/town/add', '3', '1', 'town::add', '471', '新增村鎮街道', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('472', '470', '修改村鎮街道', null, '/town/update', '3', '1', 'town::update', '472', '修改村鎮街道', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('473', '470', '刪除村鎮街道', null, '/town/delete', '3', '1', 'town::delete', '473', '刪除村鎮街道', '1', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('474', '470', '獲取村鎮街道列表', null, '/fetch/towns', '3', '1', 'town::fetch', '474', '獲取村鎮街道列表', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('475', '470', '村鎮街道資訊', null, '/town/info', '2', '1', 'town::info', '475', '村鎮街道資訊', '0', '3', null, null, '1'); INSERT INTO `sys_resource` VALUES ('500', '0', '首頁', null, '/index', '1', '1', 'index', '500', '首頁', '0', '1', '/index', 'index', '0'); INSERT INTO `sys_resource` VALUES ('501', '500', '統計新使用者資料', null, '/statistic/new/user', '3', '1', 'statistic::new::user', '501', '統計新使用者資料', '0', '3', null, null, '0'); INSERT INTO `sys_resource` VALUES ('502', '500', '統計線上使用者資料', '', '/statistic/online/user', '3', '1', 'statistic::online::user', '502', '統計線上使用者資料', '0', '3', '', '', '0'); INSERT INTO `sys_resource` VALUES ('503', '500', '統計片區使用者資料', '', '/statistic/area/user', '3', '1', 'statistic::area::user', '503', '統計片區使用者資料', '0', '3', '', '', '0'); INSERT INTO `sys_resource` VALUES ('504', '500', '統計套餐訂購資料', '', '/statistic/product/order', '3', '1', 'statistic::product::order', '504', '統計套餐訂購資料', '0', '3', '', '', '0'); -- ---------------------------- -- Table structure for sys_role -- ---------------------------- DROP TABLE IF EXISTS `sys_role`; CREATE TABLE `sys_role` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主鍵', `name` varchar(255) NOT NULL COMMENT '角色名', `code` varchar(255) NOT NULL COMMENT '角色編碼', `enable` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否啟用角色,1:啟用,2:關閉', `description` varchar(512) DEFAULT NULL COMMENT '描述', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '最近更新時間', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='角色表'; -- ---------------------------- -- Records of sys_role -- ---------------------------- INSERT INTO `sys_role` VALUES ('1', '測試', 'test', '1', '測試2', '2019-04-12 15:26:46', '2019-07-08 15:51:51'); -- ---------------------------- -- Table structure for sys_role_resource_rel -- ---------------------------- DROP TABLE IF EXISTS `sys_role_resource_rel`; CREATE TABLE `sys_role_resource_rel` ( `resource_id` bigint(20) NOT NULL COMMENT '選單id', `role_id` bigint(20) NOT NULL COMMENT '角色id', PRIMARY KEY (`resource_id`,`role_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色與選單關聯關係表'; -- ---------------------------- -- Records of sys_role_resource_rel -- ---------------------------- INSERT INTO `sys_role_resource_rel` VALUES ('100', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('100', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('110', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('110', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('120', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('120', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('130', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('130', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('150', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('150', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('160', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('200', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('210', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('230', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('240', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('300', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('310', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('320', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('400', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('400', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('410', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('411', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('412', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('413', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('420', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('420', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('421', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('421', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('422', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('422', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('423', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('423', '2'); INSERT INTO `sys_role_resource_rel` VALUES ('430', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('431', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('432', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('433', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('440', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('441', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('443', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('444', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('445', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('450', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('460', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('461', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('462', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('463', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('464', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('465', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('470', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('471', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('472', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('473', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('474', '1'); INSERT INTO `sys_role_resource_rel` VALUES ('475', '1'); -- ---------------------------- -- Table structure for sys_user -- ---------------------------- DROP TABLE IF EXISTS `sys_user`; CREATE TABLE `sys_user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主鍵', `department_id` bigint(20) NOT NULL COMMENT '部門ID', `username` varchar(64) NOT NULL COMMENT '使用者名稱', `real_name` varchar(128) DEFAULT NULL COMMENT '姓名', `password` varchar(256) NOT NULL COMMENT '密碼', `status` int(11) NOT NULL COMMENT '狀態,1:正常,2:停機,3:銷戶,4:禁用', `mobile` varchar(12) DEFAULT NULL COMMENT '聯絡方式', `email` varchar(250) DEFAULT NULL COMMENT '電子郵件', `create_time` datetime NOT NULL COMMENT '建立時間', `update_time` datetime DEFAULT NULL COMMENT '修改時間', `description` varchar(512) DEFAULT NULL COMMENT '描述', PRIMARY KEY (`id`), UNIQUE KEY `uk_user_name` (`username`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='系統管理使用者表'; -- ---------------------------- -- Records of sys_user -- ---------------------------- INSERT INTO `sys_user` VALUES ('1', '1', 'admin', '超級管理員', 'oD2Ou3h126sv7bje58Z+fA==', '1', '186989878678', '[email protected]', '2019-03-27 21:25:07', '2019-07-04 10:12:07', '測試'); -- ---------------------------- -- Table structure for sys_user_role_rel -- ---------------------------- DROP TABLE IF EXISTS `sys_user_role_rel`; CREATE TABLE `sys_user_role_rel` ( `role_id` bigint(20) NOT NULL COMMENT '角色id', `sys_user_id` bigint(20) NOT NULL COMMENT '使用者主鍵id', PRIMARY KEY (`role_id`,`sys_user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理員與角色關聯表'; -- ---------------------------- -- Records of sys_user_role_rel -- ---------------------------- INSERT INTO `sys_user_role_rel` VALUES ('1', '1');

3. 解壓radius-release-windows-x64-v0.2.zip 檔案,修改 ./config/radius.json 中的"database.url" 對應的 資料庫訪問連結 ( 訪問資料庫的使用者名稱和密碼以及庫名一定要正確 )

欄位名預設值型別描述
auth.port 1812 int radius認證埠
acct.port 1813 int radius計費埠
encrypt.key 支援16,24,32長度的十六進位制字串 string 用於加密使用者密碼
radius.session.timeout 604800 int 預設一週的秒數
limiter.limit 100 int 用於限制每次新增到令牌桶中的token數量,間接控制go協程併發數量, 伺服器環境可根據實際情況調整
limiter.burst 1000 int 用於限制最多的可用token數量,間接控制go協程併發數量,伺服器環境可根據實際情況調整
product.stage debug string 控制gin日誌,sql顯示;可選值:test,debug,release 釋出生產環境時請修改此配置為:release

4. 在終端中執行計費服務程式 yh-radius.exe

5. 解壓radius-release-web-v0.2.zip 至IIS站點的網站主目錄中

6. 使用瀏覽器訪問IIS站點,web平臺預設的登陸使用者: admin/123456

============== End