|
|
@@ -0,0 +1,224 @@
|
|
|
+create database if not exists nuojing_data_admin
|
|
|
+ default character set utf8mb4
|
|
|
+ collate utf8mb4_unicode_ci;
|
|
|
+
|
|
|
+use nuojing_data_admin;
|
|
|
+
|
|
|
+drop table if exists sys_role_menu;
|
|
|
+drop table if exists sys_user_role;
|
|
|
+drop table if exists media_advertiser_account;
|
|
|
+drop table if exists media_auth_account;
|
|
|
+drop table if exists media_auth_config;
|
|
|
+drop table if exists sys_user;
|
|
|
+drop table if exists sys_role;
|
|
|
+drop table if exists sys_menu;
|
|
|
+drop table if exists sys_dept;
|
|
|
+
|
|
|
+create table sys_dept
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '部门ID',
|
|
|
+ parent_id bigint not null default 0 comment '上级部门ID',
|
|
|
+ dept_name varchar(64) not null comment '部门名称',
|
|
|
+ sort int not null default 0 comment '排序',
|
|
|
+ status tinyint not null default 1 comment '状态:1启用,0禁用',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ key idx_parent_id (parent_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '部门表';
|
|
|
+
|
|
|
+create table sys_user
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '用户ID',
|
|
|
+ username varchar(64) not null comment '用户名',
|
|
|
+ password varchar(128) not null comment '密码',
|
|
|
+ nickname varchar(64) not null comment '昵称',
|
|
|
+ dept_id bigint null comment '部门ID',
|
|
|
+ status tinyint not null default 1 comment '状态:1启用,0禁用',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ unique key uk_username (username),
|
|
|
+ key idx_dept_id (dept_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '用户表';
|
|
|
+
|
|
|
+create table sys_role
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '角色ID',
|
|
|
+ role_name varchar(64) not null comment '角色名称',
|
|
|
+ role_code varchar(64) not null comment '角色编码',
|
|
|
+ sort int not null default 0 comment '排序',
|
|
|
+ status tinyint not null default 1 comment '状态:1启用,0禁用',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ unique key uk_role_code (role_code)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '角色表';
|
|
|
+
|
|
|
+create table sys_menu
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '菜单ID',
|
|
|
+ parent_id bigint not null default 0 comment '上级菜单ID',
|
|
|
+ menu_name varchar(64) not null comment '菜单名称',
|
|
|
+ path varchar(128) not null comment '路由路径',
|
|
|
+ component varchar(128) null comment '组件标识',
|
|
|
+ route_name varchar(64) null comment '路由名称',
|
|
|
+ icon varchar(64) null comment '图标',
|
|
|
+ permission varchar(128) null comment '权限标识',
|
|
|
+ menu_type tinyint not null default 2 comment '类型:1目录,2菜单',
|
|
|
+ sort int not null default 0 comment '排序',
|
|
|
+ hidden tinyint not null default 0 comment '是否隐藏:1隐藏,0显示',
|
|
|
+ status tinyint not null default 1 comment '状态:1启用,0禁用',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ key idx_parent_id (parent_id),
|
|
|
+ key idx_permission (permission)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '菜单表';
|
|
|
+
|
|
|
+create table sys_user_role
|
|
|
+(
|
|
|
+ user_id bigint not null comment '用户ID',
|
|
|
+ role_id bigint not null comment '角色ID',
|
|
|
+ primary key (user_id, role_id),
|
|
|
+ key idx_role_id (role_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '用户角色关联表';
|
|
|
+
|
|
|
+create table sys_role_menu
|
|
|
+(
|
|
|
+ role_id bigint not null comment '角色ID',
|
|
|
+ menu_id bigint not null comment '菜单ID',
|
|
|
+ primary key (role_id, menu_id),
|
|
|
+ key idx_menu_id (menu_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '角色菜单关联表';
|
|
|
+
|
|
|
+create table media_auth_config
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '授权配置ID',
|
|
|
+ media_type tinyint not null comment '媒体类型:1字节,2快手,3腾讯',
|
|
|
+ app_id bigint not null comment '媒体应用ID',
|
|
|
+ app_secret varchar(256) null comment '媒体应用密钥',
|
|
|
+ client_secret varchar(256) null comment '腾讯client secret',
|
|
|
+ redirect_uri varchar(512) null comment '回调地址',
|
|
|
+ callback_return_url varchar(512) null comment '前端授权结果回跳地址',
|
|
|
+ auth_url varchar(1024) null comment '授权地址',
|
|
|
+ status tinyint not null default 1 comment '状态:1启用,0禁用',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ unique key uk_media_app (media_type, app_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '媒体授权配置表';
|
|
|
+
|
|
|
+create table media_auth_account
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '授权账户ID',
|
|
|
+ media_type tinyint not null comment '媒体类型:1字节,2快手,3腾讯',
|
|
|
+ app_id bigint null comment '媒体应用ID',
|
|
|
+ user_id bigint null comment '授权发起用户ID',
|
|
|
+ admin_advertiser_id bigint not null comment '管家账户ID',
|
|
|
+ admin_advertiser_name varchar(255) null comment '管家账户名称',
|
|
|
+ email varchar(128) null comment '邮箱',
|
|
|
+ account_role varchar(64) null comment '账户角色',
|
|
|
+ advertiser_role int null comment '广告主角色',
|
|
|
+ is_valid tinyint null comment '是否有效:1有效,0无效',
|
|
|
+ access_token text null comment 'access token',
|
|
|
+ refresh_token text null comment 'refresh token',
|
|
|
+ raw_response longtext null comment '媒体原始响应',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ unique key uk_media_admin (media_type, admin_advertiser_id),
|
|
|
+ key idx_user_id (user_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '媒体授权管家账户表';
|
|
|
+
|
|
|
+create table media_advertiser_account
|
|
|
+(
|
|
|
+ id bigint not null auto_increment comment '广告账户ID',
|
|
|
+ media_type tinyint not null comment '媒体类型:1字节,2快手,3腾讯',
|
|
|
+ admin_advertiser_id bigint not null comment '管家账户ID',
|
|
|
+ advertiser_id bigint not null comment '广告账户ID',
|
|
|
+ advertiser_name varchar(255) null comment '广告账户名称',
|
|
|
+ account_role varchar(64) null comment '账户角色',
|
|
|
+ advertiser_role int null comment '广告主角色',
|
|
|
+ is_valid tinyint null comment '是否有效:1有效,0无效',
|
|
|
+ raw_response longtext null comment '媒体原始响应',
|
|
|
+ create_time datetime not null default current_timestamp comment '创建时间',
|
|
|
+ update_time datetime not null default current_timestamp on update current_timestamp comment '更新时间',
|
|
|
+ primary key (id),
|
|
|
+ unique key uk_media_admin_advertiser (media_type, admin_advertiser_id, advertiser_id),
|
|
|
+ key idx_advertiser_id (advertiser_id)
|
|
|
+) engine = InnoDB
|
|
|
+ default charset = utf8mb4
|
|
|
+ collate = utf8mb4_unicode_ci
|
|
|
+ comment = '媒体广告账户表';
|
|
|
+
|
|
|
+insert into sys_dept (id, parent_id, dept_name, sort, status)
|
|
|
+values (1, 0, '诺鲸科技', 1, 1),
|
|
|
+ (2, 1, '研发部', 1, 1),
|
|
|
+ (3, 1, '运营部', 2, 1);
|
|
|
+
|
|
|
+insert into sys_user (id, username, password, nickname, dept_id, status)
|
|
|
+values (1, 'admin', '123456', '管理员', 2, 1);
|
|
|
+
|
|
|
+insert into sys_role (id, role_name, role_code, sort, status)
|
|
|
+values (1, '超级管理员', 'admin', 1, 1);
|
|
|
+
|
|
|
+insert into sys_menu (id, parent_id, menu_name, path, component, route_name, icon, permission, menu_type, sort, hidden, status)
|
|
|
+values (1, 0, '系统管理', '/system', 'Layout', 'System', 'Settings', 'system', 1, 1, 0, 1),
|
|
|
+ (2, 1, '权限管理', '/system/permission', 'ParentView', 'SystemPermission', 'ShieldCheck', 'system:permission', 1, 1, 0, 1),
|
|
|
+ (3, 2, '用户管理', '/system/permission/users', 'system/UserList', 'SystemPermissionUsers', 'UserRound', 'system:user:list', 2, 1, 0, 1),
|
|
|
+ (4, 2, '角色管理', '/system/permission/roles', 'system/RoleList', 'SystemPermissionRoles', 'UsersRound', 'system:role:list', 2, 2, 0, 1),
|
|
|
+ (5, 2, '菜单管理', '/system/permission/menus', 'system/MenuList', 'SystemPermissionMenus', 'Menu', 'system:menu:list', 2, 3, 0, 1),
|
|
|
+ (6, 1, '组织管理', '/system/org', 'ParentView', 'SystemOrg', 'Network', 'system:org', 1, 2, 0, 1),
|
|
|
+ (7, 6, '部门管理', '/system/org/depts', 'system/DeptList', 'SystemOrgDepts', 'Building2', 'system:dept:list', 2, 1, 0, 1),
|
|
|
+ (20, 0, '投放工作台', '/authorization', 'Layout', 'Authorization', 'ChartNoAxesCombined', 'authorization', 1, 2, 0, 1),
|
|
|
+ (21, 20, '账号管理', '/authorization/authorization', 'ParentView', 'AuthorizationAccount', 'WalletCards', 'authorization:account', 1, 1, 0, 1),
|
|
|
+ (22, 21, '字节系', '/authorization/authorization/authorizationConfigDy', 'media/MediaAuthConfig', 'AuthorizationConfigDy', 'BadgeIcon', 'authorization:bytedance:list', 2, 1, 0, 1),
|
|
|
+ (23, 21, '快手系', '/authorization/authorization/authorizationConfigKs', 'media/MediaAuthConfig', 'AuthorizationConfigKs', 'BadgeIcon', 'authorization:kuaishou:list', 2, 2, 0, 1),
|
|
|
+ (24, 21, '腾讯系', '/authorization/authorization/authorizationConfigJl', 'media/MediaAuthConfig', 'AuthorizationConfigTencent', 'BadgeIcon', 'authorization:tencent:list', 2, 3, 0, 1),
|
|
|
+ (25, 21, '授权回调', '/authorization/authorization/authorizationCallback', 'media/MediaAuthCallback', 'AuthorizationCallback', 'BadgeCheck', 'authorization:callback', 2, 99, 1, 1);
|
|
|
+
|
|
|
+insert into sys_user_role (user_id, role_id)
|
|
|
+values (1, 1);
|
|
|
+
|
|
|
+insert into sys_role_menu (role_id, menu_id)
|
|
|
+values (1, 1),
|
|
|
+ (1, 2),
|
|
|
+ (1, 3),
|
|
|
+ (1, 4),
|
|
|
+ (1, 5),
|
|
|
+ (1, 6),
|
|
|
+ (1, 7),
|
|
|
+ (1, 20),
|
|
|
+ (1, 21),
|
|
|
+ (1, 22),
|
|
|
+ (1, 23),
|
|
|
+ (1, 24),
|
|
|
+ (1, 25);
|
|
|
+
|
|
|
+insert into media_auth_config (media_type, app_id, app_secret, redirect_uri, callback_return_url, auth_url, status)
|
|
|
+values (1, 1826985807952410, '', 'http://localhost:9028/api/media/callback/bytedance', 'http://localhost:5173/authorization/authorization/authorizationCallback', '', 1);
|