DROP TABLE IF EXISTS `bz_base_info`;
DROP TABLE IF EXISTS `bz_holiday_village_info`;
DROP TABLE IF EXISTS `bz_home_stay_info`;
DROP TABLE IF EXISTS `bz_hotel_info`;
DROP TABLE IF EXISTS `bz_scenery_info`;
DROP TABLE IF EXISTS `bz_tourist_info`;
DROP TABLE IF EXISTS `bz_venue_info`;
DROP TABLE IF EXISTS `bz_data_type_extend_column`;
DROP TABLE IF EXISTS `bz_data_type`;
DROP TABLE IF EXISTS `bz_data_base_info_extend`;
DROP TABLE IF EXISTS `bz_data_base_info`;

DROP TABLE IF EXISTS `place_category`;
CREATE TABLE `place_category`
(
    `id`           BIGINT(20) NOT NULL COMMENT 'ID',
    `name`         VARCHAR(50) NOT NULL COMMENT '分类名称',
    `sort_number`  INT(11) NOT NULL DEFAULT 0 COMMENT '排序ID',
    `remark`       TEXT NULL DEFAULT NULL COMMENT '备注说明',
    `created_time` DATETIME NULL DEFAULT NULL COMMENT '创建时间',
    `created_by`   BIGINT(20) NULL DEFAULT NULL COMMENT '创建人',
    `updated_time` DATETIME NULL DEFAULT NULL COMMENT '修改时间',
    `updated_by`   BIGINT(20) NULL DEFAULT NULL COMMENT '修改人',
    PRIMARY KEY (`id`)
) COMMENT ='基础数据类型管理' ENGINE = InnoDB;

DROP TABLE IF EXISTS `place_category_extend_column`;
CREATE TABLE `place_category_extend_column`
(
    `id`            BIGINT(20) NOT NULL COMMENT 'ID',
    `category_id`   VARCHAR(50)  NOT NULL COMMENT '分类ID',
    `field_key`     VARCHAR(50)  NOT NULL COMMENT '字段Key',
    `field_label`   VARCHAR(100) NOT NULL COMMENT '字段名称',
    `sort_number`   INT(11) NOT NULL DEFAULT 0 COMMENT '排序ID',
    `field_type`    INT(11) NULL DEFAULT NULL COMMENT '字段类型',
    `default_value` TEXT NULL DEFAULT NULL COMMENT '默认值',
    PRIMARY KEY (`id`)
) COMMENT ='基础数据类型扩展字段管理' ENGINE = InnoDB;


DROP TABLE IF EXISTS `place_base_info`;
CREATE TABLE `place_base_info`
(
    `id`             BIGINT(20) NOT NULL COMMENT 'ID',
    `category_id`    BIGINT(20) NULL DEFAULT NULL COMMENT '类型',
    `name`           VARCHAR(50) NULL DEFAULT NULL COMMENT '名称',
    `litpics`        VARCHAR(500) NULL DEFAULT NULL COMMENT '图片',
    `brief`          VARCHAR(500) NULL DEFAULT NULL COMMENT '简介',
    `address`        VARCHAR(100) NULL DEFAULT NULL COMMENT '地址',
    `contacts`       VARCHAR(50) NULL DEFAULT NULL COMMENT '联系人',
    `contact_number` VARCHAR(50) NULL DEFAULT NULL COMMENT '联系电话',
    `lng`            DECIMAL(20, 6) NOT NULL DEFAULT '0.000000' COMMENT '经度（坐标）',
    `lat`            DECIMAL(20, 6) NOT NULL DEFAULT '0.000000' COMMENT '纬度（坐标）',
    `created_time`   DATETIME NULL DEFAULT NULL COMMENT '创建时间',
    `created_by`     BIGINT(20) NULL DEFAULT NULL COMMENT '创建人',
    `updated_time`   DATETIME NULL DEFAULT NULL COMMENT '修改时间',
    `updated_by`     BIGINT(20) NULL DEFAULT NULL COMMENT '修改人',
    PRIMARY KEY (`id`)
) COMMENT ='文旅场所基础信息' ENGINE = InnoDB;


DROP TABLE IF EXISTS `place_base_info_extend`;
CREATE TABLE `place_base_info_extend`
(
    `id`               VARCHAR(32)  NOT NULL COMMENT 'ID',
    `extend_column_id` BIGINT(20) NOT NULL COMMENT '扩展字段ID',
    `category_id`      BIGINT(20) NOT NULL COMMENT '分类ID',
    `base_info_id`     BIGINT(20) NOT NULL COMMENT '基本信息ID',
    `field_key`        VARCHAR(50)  NOT NULL COMMENT '字段Key',
    `field_label`      VARCHAR(100) NOT NULL COMMENT '字段名称',
    `sort_number`      INT(11) NOT NULL DEFAULT 0 COMMENT '排序ID',
    `field_type`       INT(11) NULL DEFAULT NULL COMMENT '字段类型',
    `field_value`      TEXT NULL DEFAULT NULL COMMENT '字段值',
    PRIMARY KEY (`id`)
) COMMENT ='基础数据类型扩展字段管理' ENGINE = InnoDB;



REPLACE
INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
VALUES (1400, 0, 'place.category', '文旅场所分类管理'),
       (1401, 1400, 'place.category.find', '查询'),
       (1402, 1400, 'place.category.add', '添加'),
       (1403, 1400, 'place.category.edit', '修改'),
       (1404, 1400, 'place.category.delete', '删除');

REPLACE
INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
VALUES (1500, 0, 'place.category.extend.column', '文旅场所扩展字段管理'),
       (1501, 1500, 'place.category.extend.column.find', '查询'),
       (1502, 1500, 'place.category.extend.column.add', '添加'),
       (1503, 1500, 'place.category.extend.column.edit', '修改'),
       (1504, 1500, 'place.category.extend.column.delete', '删除');

REPLACE
INTO `authority_info` (`id`, `parent_id`, `name`, `remark`)
VALUES (1600, 0, 'place.base.info', '文旅场所管理'),
       (1601, 1600, 'place.base.info.find', '查询'),
       (1602, 1600, 'place.base.info.add', '添加'),
       (1603, 1600, 'place.base.info.edit', '修改'),
       (1604, 1600, 'place.base.info.delete', '删除'),
       (1605, 1600, 'place.base.info.gis.map', 'GIS地图查看');



