/* mysql -uroot --default-character-set=utf8 < E:\test\MyCompetence\sql\create.sql mysql -uroot --default-character-set=utf8 qx < E:\test\MyCompetence\sql\partner\insert.sql */ drop database if exists qx ; create database qx ; use qx ; /*权限描述表*/ drop table if exists competence ; create table competence ( `id` bigint(20) NOT NULL auto_increment, `competenceName` varchar(50) NOT NULL unique COMMENT '此使用 varchar 为id 是默认使用 java 枚举类 名字结合', `effectiveNo` int default 0 COMMENT '有效标识。默认0为有效,其他为无效' , `consumerUseTime` int default null COMMENT '本服务消费时间长度,秒数 null 就是时间免费' , `consumerUseNum` int default null COMMENT '本服务消费次数 null 就是次数免费' , `money` int not null default 0 COMMENT '本服务消费金额描述' , `cdesc` varchar(255) COMMENT '本服务描述' , PRIMARY KEY (`id`), CONSTRAINT `fk_competenceId_roleId` FOREIGN KEY (`id`) REFERENCES `competenceM2Mrole` (`competenceid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; /*权限,角色多对多 描述表*/ drop table if exists competenceM2Mrole ; create table competenceM2Mrole( `id` bigint(20) NOT NULL auto_increment, `competenceid` bigint(20) NOT NULL COMMENT 'competence id ', `roleid` bigint(20) NOT NULL COMMENT 'role id' , `crdesc` varchar(255) COMMENT '本服务描述' , PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; /*角色描述表*/ drop table if exists role ; create table role( `id` bigint(20) NOT NULL auto_increment, `froleId` bigint(20) COMMENT '单继承' , `roleName` varchar(50) NOT NULL unique COMMENT '此使用 varchar 为id 是默认使用 java 枚举类 名字结合', `effectiveNo` int default 0 COMMENT '有效标识。默认0为有效,其他为无效' , `consumerUseTime` int default null COMMENT '本服务消费时间长度,秒数 null 就是时间免费' , `consumerUseNum` int default null COMMENT '本服务消费次数 null 就是次数免费' , `money` int not null default 0 COMMENT '本服务消费金额描述' , `rdesc` varchar(255) COMMENT '本服务描述' , CONSTRAINT `fk_croleId_froleId` FOREIGN KEY (`id`) REFERENCES `role`(`froleId`), PRIMARY KEY (`id`) )ENGINE=MyISAM DEFAULT CHARSET=utf8 ; /*角色多对多 继承关系维护表 (为了简单提供单一继承) drop table if exists roleM2Mrole ; create table roleM2Mrole( `id` bigint(20) NOT NULL auto_increment, `froleid` varchar(50) NOT NULL COMMENT '继承父类 基类 role id', `croleid` varchar(50) NOT NULL COMMENT '扩展类 role id ', PRIMARY KEY (`id`) )ENGINE=MyISAM DEFAULT CHARSET=utf8 ; */ /*用户 角色 申请 清单*/ drop table if exists userAppCustomized ; create table userAppCustomized( `id` bigint(20) NOT NULL auto_increment, `userid` bigint(20) NOT NULL COMMENT '对 各系统用户 id 接入点' , `roleName` varchar(50) NOT NULL unique COMMENT '申请的服务 role 角色' , `effectiveNo` int default 0 COMMENT '有效标识 默认0为有效 其他为无效' , `consumerMultiples` int default 1 COMMENT '用户购买此服务器倍数,默认1倍' , `customTime` timestamp NOT NULL COMMENT '服务申请时间' , `udesc` varchar(255) COMMENT '本服务描述' , PRIMARY KEY (`id`) )ENGINE=MyISAM DEFAULT CHARSET=utf8 ; /*用户 角色,权限 使用 清单*/ /*`roleOrcompetence` ENUM('role','competence') NOT NULL COMMENT ' 枚举判断 角色 权限 使用数据描述 ' , * consumerUseNum 为 -1 为没有权限 * */ drop table if exists userEnumCompetenceOrRole; create table userEnumCompetenceOrRole( `id` bigint(20) NOT NULL auto_increment, `userAppCustomizedId` bigint(20) NOT NULL COMMENT '用户角色申请清单 约束' , `effectiveNo` int default 0 COMMENT '有效标识 默认0为有效 其他为无效' , `roleid` bigint(20), `competenceid` bigint(20) , `consumerUseTime` int default null COMMENT '到此前使用为可用, null 就是时间免费' , `consumerUseNum` int default null COMMENT '本服务消费还有多少次数 , null 就是次数免费' , `money` int not null default 0 COMMENT '本服务消费金额描述' , `uedesc` varchar(255) COMMENT '本服务描述' , PRIMARY KEY (`id`) )ENGINE=MyISAM DEFAULT CHARSET=utf8 ;