drop table if exists wx_user_data_rule;
CREATE TABLE wx_user_data_rule (
	`id` bigint(20) NOT NULL,
	`tenant_id` varchar(10) NOT NULL COMMENT '租户ID',
	`user_id` bigint(20) NOT NULL COMMENT '角色名称',
	`type` tinyint(3) NOT NULL COMMENT '权限类型1系统全部数据2楼层及业态',
	`building_floor` json DEFAULT NULL COMMENT '楼层楼座',
	`business` json DEFAULT NULL COMMENT '业态',
	`target` json DEFAULT NULL COMMENT '数据范围',
	`create_time` datetime DEFAULT NULL COMMENT '创建时间',
	`update_time` datetime DEFAULT NULL COMMENT '更新时间',
	PRIMARY KEY (`id`),
	UNIQUE `id_UNIQUE` USING BTREE (`id`) comment ''
) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户数据权限' CHECKSUM=0 DELAY_KEY_WRITE=0;

drop table if exists wx_data_rule_target;
CREATE TABLE wx_data_rule_target (
	`id` bigint(20) NOT NULL,
	`parent` bigint(20) NOT NULL COMMENT '父级',
	`name` varchar(50) NOT NULL COMMENT '名称',
	`tag` varchar(50) DEFAULT NULL COMMENT '标签',
	`create_time` datetime DEFAULT NULL COMMENT '创建时间',
	`update_time` datetime DEFAULT NULL COMMENT '更新时间',
	PRIMARY KEY (`id`),
	UNIQUE `id_UNIQUE` USING BTREE (`id`) comment ''
) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='数据权限目标' CHECKSUM=0 DELAY_KEY_WRITE=0;


insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '1', '0', '商户商铺', '', '2019-08-26 13:23:25', '2019-08-26 13:23:27');
insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '2', '0', '合同管理', '', '2019-08-26 13:32:04', '2019-08-26 13:32:07');
insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '101','1', '商户列表', 'merchant_list', '2019-08-26 13:32:17', '2019-08-26 13:32:19');
insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '102','1', '解单数据', 'merchant_trade', '2019-08-26 13:33:24', '2019-08-26 13:33:25');
insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '201','2', '租金合同', 'rent_contract_list', '2019-08-26 13:34:17', '2019-08-26 13:34:20');
insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '202','2', '物业合同', 'property_contract_list', '2019-08-26 13:34:45', '2019-08-26 13:34:47');
insert into `wx_data_rule_target` ( `id`,  `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '203','2', '租金物业合同', 'rent_property_contract_list', '2019-08-26 13:36:23', '2019-08-26 13:36:25');
