drop table if exists sys_admin;
create table sys_admin
(
    id       varchar(20)          not null,
    org_id   varchar(20),
    type 	 int default 0 comment '0管理员,1普通用户',
    realname varchar(100) not null,
    username varchar(100) not null,
    password varchar(100) not null comment 'sha3_256hex',
    islock   int default 0 comment '0正常,1锁定',
    primary key (id),
    unique (username)
);

drop table if exists sys_role;
create table sys_role
(
    id       varchar(20)          not null,
    rolename   varchar(50) not null,
    department varchar(50) not null,
    primary key (id)
);

drop table if exists sys_admin_role;
create table sys_admin_role
(
    id       varchar(20)          not null,
    admin_id varchar(20)         not null,
    role_id  int not null,
    primary key (id)
);

drop table if exists sys_resource;
create table sys_resource
(
    id       varchar(20)          not null,
    parent_id   varchar(20)         not null,
    level       smallint     default null comment '菜单排列顺序',
    name        varchar(50)  default null,
    types       varchar(40)  default null comment '资源类型',
    url         varchar(200) default null,
    icon        varchar(100) default null comment '菜单图标',
    ishide      tinyint      default '0' comment '是否折叠隐藏',
    description varchar(200) default null,
    primary key (`id`)
);

drop table if exists sys_role_resource;
create table sys_role_resource
(
	id varchar(20)         not null,
    roleid varchar(20)         not null,
    resid  varchar(20)         not null,
    primary key (roleid, resid)
);

drop table if exists sys_urls;
create table sys_urls
(
    id     varchar(20)         not null,
    pid    int comment '父类id',
    types  int          default 1 comment '1:url,2:菜单',
    level  int          default 0 comment '0:url,1:一级菜单, 2:二级菜单',
    url    varchar(300) default null,
    name   varchar(200) default null,
    method varchar(200) default null,
    primary key (id),
    unique (url)
);

drop table if exists sys_role_url;
create table sys_role_url
(
    id       varchar(20)         not null,
    roleid   varchar(20)         not null,
    url      varchar(300) not null comment '对应sys_urls的url',
    urltypes int          not null comment '1:url,2:菜单',
    primary key (id)
);

-- 系统配置表
drop table if exists sys_config;
create table sys_config
(
    id        varchar(20)         not null,
    subgroup  varchar(500)  not null comment '分组',
    k         varchar(1000) not null comment '键',
    val       varchar(14000) comment '值',
    admin_id   varchar(20)         not null comment '管理员id',
    adminname varchar(100)  not null comment '管理员名称',
    edittime  datetime default current_timestamp on update current_timestamp comment '最后编辑时间',
    primary key (id),
    unique (k)
);

drop table if exists sys_menu;
create table sys_menu (
  id varchar(20)         not null,
  parent_id varchar(20)         not null,
  level int default null,
  name varchar(50) default null,
  types varchar(50) default null comment 'menu,url',
  url varchar(200) default null,
  icon varchar(100) default null,
  is_open int default '0',
  description varchar(200) default null,
  sort int default '0',
  PRIMARY KEY (id)
);

drop table if exists sys_admin_menu;
create table sys_admin_menu
(
	id     varchar(20)         not null,
    adminid varchar(20)         not null,
    memuid  varchar(20)         not null,
    primary key (id),
    unique  (adminid, memuid)
);


drop table if exists sys_org;
create table sys_org (
	id     varchar(20)         not null,
	pid    varchar(20)         not null,
	status integer null default 1,
	org_type varchar(20)  default null,
	primary key (id)
);



drop table if exists idc9998_admin_info;
create table idc9998_admin_info (
	id     varchar(20)         not null,
	status integer null default 1 comment '1启用,0禁用',
	manager_name varchar(30)  not null comment '采集管理员账号',
	member_name varchar(30) comment '采集会员账号',
	user_name varchar(30)  not null comment '采集用户账号',
	user_password varchar(30)  not null comment '采集用户密码',
	domain varchar(100)  not null comment '网站域名或者IP,无须/',
	is_default integer not null default 0 comment '是否默认为默认采集号',
	is_online integer null default 0 comment '1在线,0掉线',
	login_info varchar(5000) comment '最后一次登录cookie信息',
	g_24 integer default 0 not null comment '幸运飞艇',
	g_29 integer default 0 not null comment '极速时时彩',
	g_30 integer default 0 not null comment '极速赛车',
	g_31 integer default 0 not null comment '极速飞艇',
	g_35 integer default 0 not null comment '澳洲幸运5',
	g_37 integer default 0  not null comment '澳洲幸运10',
	primary key (id)
);



drop table if exists  current_g24;
create table current_g24 (
	id       varchar(20)         not null,
	newIssue varchar(20)  not null comment '当前期号',
	issue    varchar(20)  not null comment '下一期号',
	ball     varchar(100) comment '开奖号码',
	closeTime integer  not null comment '关闭时间',
	openTime  integer  not null comment '开奖时间',
	addTime  datetime comment '提交时间',
	gameID   varchar(20) default 24 comment '游戏ID',
	primary key (id),
	unique (newIssue)
);

drop table if exists  history_g24;
create table history_g24 (
    id       varchar(20)         not null,
	newIssue varchar(20)  not null comment '当前期号',
	issue    varchar(20)  not null comment '下一期号',
	ball     varchar(100) comment '开奖号码',
	closeTime integer  not null comment '关闭时间',
	openTime  integer  not null comment '开奖时间',
	addTime  datetime comment '提交时间',
	gameID   varchar(20) default 24 comment '游戏ID',
	primary key (id),
	unique (newIssue)
);


drop table if exists  INT_LOCK;
CREATE TABLE INT_LOCK  (
	LOCK_KEY CHAR(36) NOT NULL,
	REGION VARCHAR(100) NOT NULL,
	CLIENT_ID CHAR(36),
	CREATED_DATE DATETIME(6) NOT NULL,
	constraint INT_LOCK_PK primary key (LOCK_KEY, REGION)
) ENGINE=InnoDB;

