use energy;

drop table if exists `project`;
create table `project`
(
    `id`                 bigint                                not null auto_increment,
    `project_name`       varchar(64)                           null comment '项目名称',
    `short_name`         varchar(64)                           null comment '项目简称',
    `p_id`               bigint                                null comment '父项目id',
    `status`             tinyint(4)  default 0                 null comment '状态（0正常 1停用）',
    `pic_url`            varchar(255)                          null comment '项目图片',
    `lng`                varchar(20)                           null COMMENT '经度',
    `lat`                varchar(20)                           null COMMENT '纬度',
    `remark`             varchar(500)                          null comment '备注',
    `type`               varchar(20)                           null comment '项目类型',
    `is_type`            tinyint(4)                            null comment '项目类型（1光伏 2风电）',
    `create_by`          bigint                                null comment '创建者',
    `update_by`          bigint                                null comment '更新者',
    `create_time`        datetime    default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time`        datetime    default CURRENT_TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP comment '更新时间',
    `deleted_at`         datetime                              null comment '删除时间',
    `project_site`       varchar(255)                          null comment '项目地址',
    `principal`          varchar(50)                           null comment '负责人',
    `principal_phone`    varchar(50)                           null comment '负责人电话',
    `actual`             varchar(64)                           null comment '实际容量',
    `plan`               varchar(64)                           null comment '计划容量',
    `on_stream_time`     varchar(64)                           null comment '开工时间',
    `punch_range`        varchar(30) default '09:00,18:00'     not null comment '打卡范围（09:00,18:00）',
    `design_total`       int         default 0                 not null comment '设计总量',
    `security_agreement` varchar(255)                          null comment '安全协议书',
    `sort`               bigint      default 0                 not null comment '排序字段',
    `show_hidden`        tinyint(4)  default 0                 not null comment '显示隐藏（0显示 1隐藏）',
    `is_delete`          tinyint(4)  default 0                 not null comment '是否删除（0正常 1删除）',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 60
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci comment = '项目表'
  ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `user_project_relevancy`;
CREATE TABLE `user_project_relevancy`
(
    `id`          bigint                             not null AUTO_INCREMENT COMMENT '主键ID',
    `user_id`     bigint                             not null comment '用户ID',
    `project_id`  bigint                             not null comment '项目ID',
    `create_by`   varchar(50)                        null comment '创建人',
    `update_by`   varchar(50)                        null comment '更新人',
    `create_time` datetime default CURRENT_TIMESTAMP null comment '创建时间',
    `update_time` datetime default CURRENT_TIMESTAMP null ON UPDATE CURRENT_TIMESTAMP comment '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    INDEX `user_id` (`user_id` ASC) USING BTREE COMMENT '用户id',
    INDEX `project_id` (`project_id` ASC) USING BTREE COMMENT '项目id'
) ENGINE = InnoDB
  AUTO_INCREMENT = 1365
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT = '系统用户与项目关联'
  ROW_FORMAT = DYNAMIC;

-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367169, '项目', '1', '1', 'project', 'project/project/index', 1, 0, 'C', '0', '0',
        'project:project:list', '#', 103, 1, sysdate(), null, null, '项目菜单');

-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367170, '项目查询', 1896943300447367169, '1', '#', '', 1, 0, 'F', '0', '0',
        'project:project:query', '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367171, '项目新增', 1896943300447367169, '2', '#', '', 1, 0, 'F', '0', '0', 'project:project:add',
        '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367172, '项目修改', 1896943300447367169, '3', '#', '', 1, 0, 'F', '0', '0', 'project:project:edit',
        '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367173, '项目删除', 1896943300447367169, '4', '#', '', 1, 0, 'F', '0', '0',
        'project:project:remove', '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896943300447367174, '项目导出', 1896943300447367169, '5', '#', '', 1, 0, 'F', '0', '0',
        'project:project:export', '#', 103, 1, sysdate(), null, null, '');

-- 菜单 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047233, '系统用户与项目关联', '1', '1', 'projectRelevancy', 'project/projectRelevancy/index', 1, 0,
        'C', '0', '0', 'project:projectRelevancy:list', '#', 103, 1, sysdate(), null, null, '系统用户与项目关联菜单');

-- 按钮 SQL
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047234, '系统用户与项目关联查询', 1896949180526047233, '1', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:query', '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047235, '系统用户与项目关联新增', 1896949180526047233, '2', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:add', '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047236, '系统用户与项目关联修改', 1896949180526047233, '3', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:edit', '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047237, '系统用户与项目关联删除', 1896949180526047233, '4', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:remove', '#', 103, 1, sysdate(), null, null, '');

insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible,
                      status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
values (1896949180526047238, '系统用户与项目关联导出', 1896949180526047233, '5', '#', '', 1, 0, 'F', '0', '0',
        'project:projectRelevancy:export', '#', 103, 1, sysdate(), null, null, '');
