
ALTER TABLE `itax_base`.`sys_dept`
    ADD COLUMN `dept_category_name` varchar(255) NULL COMMENT '组织类别名称' AFTER `omp_parent_id`,
ADD COLUMN `dept_category_code` varchar(255) NULL COMMENT '组织类别编码' AFTER `dept_category_name`;
-- 字典表
CREATE TABLE `itax_base`.`sys_dict` (
                            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
                            `code` varchar(32) NOT NULL COMMENT '编码',
                            `name` varchar(32) NOT NULL COMMENT '名称',
                            `descript` varchar(64) DEFAULT NULL COMMENT '描述',
                            `status` tinyint(1) DEFAULT 0 COMMENT '状态（0--正常1--冻结）',
                            `create_time` datetime DEFAULT NULL COMMENT '创建时间',
                            `create_user` bigint(20) DEFAULT NULL COMMENT '创建人',
                            `del_flag` tinyint(1) DEFAULT 0 COMMENT '删除状态（0，正常，1已删除）',
                            PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典管理表';

-- 字典项表
CREATE TABLE `itax_base`.`sys_dict_detail` (
                                   `id` bigint(20) NOT NULL COMMENT '主键id',
                                   `dict_code` varchar(32) NOT NULL COMMENT '字典编码',
                                   `code` varchar(32) NOT NULL COMMENT '编码',
                                   `name` varchar(32) NOT NULL COMMENT '名称',
                                   PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典配置表';



-- 插入字典数据
INSERT INTO `itax_base`.`sys_dict` (`id`, `code`, `name`, `descript`, `status`, `create_time`, `create_user`, `del_flag`) VALUES
    (1, 'deptCategoryCode', '组织类别', '组织类别字典', 0, '2023-04-25 10:00:00', 1, 0);

-- 插入字典项数据
INSERT INTO `itax_base`.`sys_dict_detail` (`id`, `dict_code`, `code`, `name`) VALUES
                                                                      (1, 'deptCategoryCode', '0', '财务部门'),
                                                                      (2, 'deptCategoryCode', '1', '技术部门'),
                                                                      (3, 'deptCategoryCode', '2', '技术部门'),
                                                                      (4, 'deptCategoryCode', '3', '研发部门');


ALTER TABLE `itax_base`.`sys_dept`
    ADD COLUMN `status` int(4) DEFAULT '1' COMMENT '''状态  0：删除   1：正常'',' AFTER `omp_parent_id`,
ADD COLUMN `source` int(255) DEFAULT NULL COMMENT '来源 1系统导入 2系统推送 3系统创建',
ADD COLUMN `update_time` datetime DEFAULT NULL COMMENT '更新时间';


ALTER TABLE `itax_base`.`sys_role` ADD COLUMN `role_code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '角色编码' AFTER `tenant_id`;

ALTER TABLE `itax_base`.`sys_role` ADD COLUMN `source` int(4) NULL DEFAULT NULL COMMENT '来源 1系统导入 2系统推送 3系统创建' AFTER `role_code`;

-- 清洗角色数据
CREATE TABLE `itax_base`.sys_role_20240510 select * from sys_role  ;

insert  into `itax_base`.sys_role (
    `role_id`, `role_name`, `type`, `remark`, `dept_id`, `create_time`, `p_user_id`, `manager_id`, `role_type`, `omp_dept_id`, `tenant_id`
)
select concat(`role_id`,'001'), concat(`role_name`,'-数据') , `type`, `remark`, `dept_id`, `create_time`, `p_user_id`, `manager_id`, `role_type`, `omp_dept_id`, `tenant_id`
from `itax_base`.sys_role_20240510 where role_type ='3';

INSERT INTO `itax_base`.`sys_role_dept`( `role_id`, `dept_id`)
select concat(`role_id`,'001'),dept_id from `itax_base`.sys_role_dept where role_id in (
    select role_id from `itax_base`.sys_role_20240510 where role_type ='3');

delete from `itax_base`.sys_role_dept where  role_id in (
    select role_id from `itax_base`.sys_role_20240510 where role_type ='3');

insert into `itax_base`.sys_user_role(user_id,role_id)
select user_id,concat(`role_id`,'001') from  `itax_base`.sys_user_role where  role_id in (
    select role_id from `itax_base`. where role_type ='3');

update `itax_base`.sys_role set role_type ='4'  where  role_id in (select role_id from `itax_base`.sys_role_20240510 where role_type ='3');

-- 清洗角色数据

INSERT INTO `itax_base`.`sys_menu`(`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`, `system_sign`, `create_time`, `puser_id`, `tenant_id`, `remark`, `product_id`) VALUES (471, 4, '数据角色管理', 'http://itax-pre.ele-cloud.com:10000/itax-base/index.html#/rightsManagement/datarole', '', 2, '', 2, 'JCPT', '2024-04-26 10:25:17', 11002370360, '1', NULL, NULL);


UPDATE `itax_base`.`sys_menu` SET `parent_id` = 4, `name` = '功能角色管理', `url` = 'http://itax-pre.ele-cloud.com:10000/itax-base/index.html#/rightsManagement/functionalRole', `perms` = NULL, `type` = 2, `icon` = NULL, `order_num` = 3, `system_sign` = 'JCPT', `create_time` = '2019-04-09 19:24:24', `puser_id` = 1, `tenant_id` = '1', `remark` = NULL, `product_id` = NULL WHERE `menu_id` = 10;








