/*
 Navicat Premium Dump SQL

 Source Server         : localhost
 Source Server Type    : MariaDB
 Source Server Version : 100623 (10.6.23-MariaDB)
 Source Host           : localhost:3306
 Source Schema         : toughradius

 Target Server Type    : MariaDB
 Target Server Version : 100623 (10.6.23-MariaDB)
 File Encoding         : 65001

 Date: 17/11/2025 20:33:02
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tr_bras
-- ----------------------------
DROP TABLE IF EXISTS `tr_bras`;
CREATE TABLE `tr_bras`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `identifier` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `ipaddr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `vendor_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `portal_vendor` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `secret` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `coa_port` int(11) NOT NULL,
  `ac_port` int(11) NOT NULL,
  `auth_limit` int(11) NULL DEFAULT NULL,
  `acct_limit` int(11) NULL DEFAULT NULL,
  `status` enum('enabled','disabled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `create_time` datetime NOT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ix_tr_bras_identifier`(`identifier`) USING BTREE,
  INDEX `ix_tr_bras_ipaddr`(`ipaddr`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tr_bras
-- ----------------------------
INSERT INTO `tr_bras` VALUES (1, 'bras-windows-01', 'Windows测试BRAS', '127.0.0.1', '14988', 'cmccv1', 'secret', 3799, 2000, 1000, 1000, 'enabled', 'Windows环境测试设备', '2025-11-04 15:56:24');
INSERT INTO `tr_bras` VALUES (2, 'bras-windows-02', 'Windows华为设备', '192.168.1.1', '2011', 'huawei', 'huawei123', 3799, 2000, 2000, 2000, 'enabled', '华为设备测试', '2025-11-04 15:56:24');

-- ----------------------------
-- Table structure for tr_config
-- ----------------------------
DROP TABLE IF EXISTS `tr_config`;
CREATE TABLE `tr_config`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2025110415580200002 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tr_config
-- ----------------------------
INSERT INTO `tr_config` VALUES (1, 'system', 'admin_password', 'root', '管理员默认密码');
INSERT INTO `tr_config` VALUES (2, 'radius', 'auth_port', '1812', 'RADIUS认证端口');
INSERT INTO `tr_config` VALUES (3, 'radius', 'acct_port', '1813', 'RADIUS计费端口');
INSERT INTO `tr_config` VALUES (4, 'system', 'session_timeout', '3600', '会话超时时间(秒)');
INSERT INTO `tr_config` VALUES (2025110415580200000, 'system', 'systemUsername', 'admin', NULL);
INSERT INTO `tr_config` VALUES (2025110415580200001, 'system', 'systemUserpwd', '156A88CFAD6EB37D4EFE68E21A5B9045', NULL);

-- ----------------------------
-- Table structure for tr_online
-- ----------------------------
DROP TABLE IF EXISTS `tr_online`;
CREATE TABLE `tr_online`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `subscriber` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `nas_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `nas_addr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `nas_port` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `mac_addr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `ip_addr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `start_time` datetime NOT NULL,
  `accept_time` datetime NULL DEFAULT NULL,
  `framed_ipaddr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `framed_netmask` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `nas_class` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `nas_port_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `nas_port_type` int(11) NULL DEFAULT NULL,
  `nas_real_port` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `service_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `acct_session_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `acct_session_time` bigint(20) NULL DEFAULT NULL,
  `acct_input_octets` bigint(20) NULL DEFAULT NULL,
  `acct_output_octets` bigint(20) NULL DEFAULT NULL,
  `acct_input_packets` bigint(20) NULL DEFAULT NULL,
  `acct_output_packets` bigint(20) NULL DEFAULT NULL,
  `acct_terminate_cause` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `uk_tr_online_session`(`subscriber`, `nas_addr`, `acct_session_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tr_online
-- ----------------------------

-- ----------------------------
-- Table structure for tr_subscribe
-- ----------------------------
DROP TABLE IF EXISTS `tr_subscribe`;
CREATE TABLE `tr_subscribe`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `node_id` bigint(20) NOT NULL DEFAULT 0,
  `subscriber` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `realname` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `password` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `domain` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `addr_pool` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `policy` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `is_online` int(11) NULL DEFAULT NULL,
  `active_num` int(11) NULL DEFAULT NULL,
  `bind_mac` tinyint(1) NULL DEFAULT NULL,
  `bind_vlan` tinyint(1) NULL DEFAULT NULL,
  `ip_addr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `mac_addr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `in_vlan` int(11) NULL DEFAULT NULL,
  `out_vlan` int(11) NULL DEFAULT NULL,
  `up_rate` bigint(20) NULL DEFAULT NULL,
  `down_rate` bigint(20) NULL DEFAULT NULL,
  `up_peak_rate` bigint(20) NULL DEFAULT NULL,
  `down_peak_rate` bigint(20) NULL DEFAULT NULL,
  `up_rate_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `down_rate_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `status` enum('enabled','disabled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `remark` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
  `begin_time` datetime NOT NULL,
  `expire_time` datetime NOT NULL,
  `create_time` datetime NOT NULL,
  `update_time` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `ix_tr_subscribe_create_time`(`create_time`) USING BTREE,
  INDEX `ix_tr_subscribe_expire_time`(`expire_time`) USING BTREE,
  INDEX `ix_tr_subscribe_status`(`status`) USING BTREE,
  INDEX `ix_tr_subscribe_subscriber`(`subscriber`) USING BTREE,
  INDEX `ix_tr_subscribe_update_time`(`update_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of tr_subscribe
-- ----------------------------
INSERT INTO `tr_subscribe` VALUES (1, 0, 'test01', '测试用户01', '888888', NULL, NULL, NULL, 0, 10, 0, 0, '', '', 0, 0, 10000000, 10000000, 20000000, 20000000, '10M', '10M', 'enabled', 'Windows测试用户', '2025-11-04 15:56:24', '2026-11-04 15:56:24', '2025-11-04 15:56:24', '2025-11-04 15:56:24');
INSERT INTO `tr_subscribe` VALUES (2, 0, 'test02', '测试用户02', '888888', NULL, 'pool1', 'policy1', 0, 5, 1, 0, '192.168.10.100', '00:11:22:33:44:55', 100, 200, 20000000, 20000000, 50000000, 50000000, '20M', '20M', 'enabled', '绑定MAC测试用户', '2025-11-04 15:56:24', '2026-05-03 15:56:24', '2025-11-04 15:56:24', '2025-11-04 15:56:24');

SET FOREIGN_KEY_CHECKS = 1;
