-- --------------------------------------------------------------------------------------------
-- 学生去向登记
-- --------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS base_student_development;   
CREATE TABLE `base_student_development` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL COMMENT '创建人',
  `create_date` DATETIME DEFAULT NULL COMMENT '创建时间',
  `modify_user_id` BIGINT DEFAULT NULL COMMENT '修改人',
  `modify_date` DATETIME DEFAULT NULL COMMENT '修改日期',
  `delete_mark` INT DEFAULT NULL COMMENT '删除标记',
  `enabled_mark` INT DEFAULT NULL COMMENT '有效标记',
  `user_id` BIGINT DEFAULT NULL COMMENT '学生id(xjr_user)',
  `enroll_type` INT DEFAULT NULL COMMENT '登记类型(1:升学 2:就业 3:未就业)',
  `base_student_graduate_id` BIGINT DEFAULT NULL COMMENT '毕业id(base_student_graduate)',
  `is_entrepreneurship` INT DEFAULT NULL COMMENT '是否自己创业(1:是 0:否)',
  `entrepreneurial_project` VARCHAR(100) DEFAULT NULL COMMENT '创业项目名称',
  `is_flexible_work` INT DEFAULT NULL COMMENT '是否灵活就业(1:是 0:否)',
  `work_content` VARCHAR(1000) DEFAULT NULL COMMENT '工作内容',
  `is_company_coop` INT DEFAULT NULL COMMENT '是否校企合作单位(1:是 0:否)',
  `company_coop_id` BIGINT DEFAULT NULL COMMENT '企合作单位(company_coop)，是校企合作单位',
  `work_company` VARCHAR(100) DEFAULT NULL COMMENT '就业单位名称(非校企合作单位)',
  `company_industry` VARCHAR(100) DEFAULT NULL COMMENT '就业单位行业',
  `company_nature` VARCHAR(100) DEFAULT NULL COMMENT '就业单位性质',
  `company_scale` VARCHAR(50) DEFAULT NULL COMMENT '就业单位规模(xjr_dictionary_item[company_scale])',
  `is_matching` INT DEFAULT NULL COMMENT '是否对口(1:是 0:否)',
  `money` DOUBLE DEFAULT NULL COMMENT '最低薪资',
  `work_date` DATE DEFAULT NULL COMMENT '就业日期',
  `work_city` VARCHAR(50) DEFAULT NULL COMMENT '就业所在地区',
  `culture_type` VARCHAR(50) DEFAULT NULL COMMENT '学生类型(xjr_dictionary_item[culture_type])',
  `ascending_channels` VARCHAR(50) DEFAULT NULL COMMENT '升学渠道(xjr_dictionary_item[ascending_channels])',
  `school` VARCHAR(50) DEFAULT NULL COMMENT '学校名称',
  `admission_major` VARCHAR(50) DEFAULT NULL COMMENT '录取专业',
  `score`INT DEFAULT NULL COMMENT '分数',
  `ascending_arrangement` VARCHAR(50) DEFAULT NULL COMMENT '升学层次(xjr_dictionary_item[education_type])',
  `unemployed_type` VARCHAR(50) DEFAULT NULL COMMENT '未就业类型(xjr_dictionary_item[unemployed_type])',
  `remark` VARCHAR(500) DEFAULT NULL COMMENT '备注信息',
  PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='学生去向登记';


ALTER TABLE `room_bed_check_record`   
  CHANGE `condition` `record` VARCHAR(1000) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL   COMMENT '情况';

ALTER TABLE `xjr_department`   
  ADD COLUMN `is_major` INT NULL   COMMENT '是否专业部(1:是 0:否)' AFTER `department_type`;
  
-- --------------------------------------------------------------------------------------------
-- 功能分类设置
-- --------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS xjr_menu_group_set;   
CREATE TABLE `xjr_menu_group_set` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL COMMENT '创建人',
  `create_date` DATETIME DEFAULT NULL COMMENT '创建时间',
  `modify_user_id` BIGINT DEFAULT NULL COMMENT '修改人',
  `modify_date` DATETIME DEFAULT NULL COMMENT '修改日期',
  `delete_mark` INT DEFAULT NULL COMMENT '删除标记',
  `enabled_mark` INT DEFAULT NULL COMMENT '有效标记',
  `name` VARCHAR(100) DEFAULT NULL COMMENT '功能分类名称',
  `code` VARCHAR(50) DEFAULT NULL COMMENT '分组代码(xjr_dictionary_item[xjr_menu_group])',
  `use_range` INT DEFAULT NULL COMMENT '使用范围(1:全部学生 2:白名单学生)',
  PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='功能分类设置';
INSERT INTO xjr_menu_group_set(id, create_user_id,create_date, NAME, CODE, use_range,delete_mark,enabled_mark) 
VALUES(1821825335458217984,1000000000000000000,NOW(),'基础功能','XMGS_001',1,0,1),
(1821825335458217985,1000000000000000000,NOW(),'增值功能','XMGS_002',2,0,1);


DROP TABLE IF EXISTS xjr_menu_group;   
CREATE TABLE `xjr_menu_group` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL COMMENT '创建人',
  `create_date` DATETIME DEFAULT NULL COMMENT '创建时间',
  `modify_user_id` BIGINT DEFAULT NULL COMMENT '修改人',
  `modify_date` DATETIME DEFAULT NULL COMMENT '修改日期',
  `delete_mark` INT DEFAULT NULL COMMENT '删除标记',
  `enabled_mark` INT DEFAULT NULL COMMENT '有效标记',
  `xjr_menu_id` BIGINT DEFAULT NULL COMMENT '菜单id(xjr_menu)',
  `xjr_menu_group_set_id` BIGINT DEFAULT NULL COMMENT '功能分类设置(xjr_menu_group_set)',
  PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='功能分类设置菜单关联表';

-- --------------------------------------------------------------------------------------------
-- 系统提示信息设置
-- --------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS xjr_tips_message;   
CREATE TABLE `xjr_tips_message` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL COMMENT '创建人',
  `create_date` DATETIME DEFAULT NULL COMMENT '创建时间',
  `modify_user_id` BIGINT DEFAULT NULL COMMENT '修改人',
  `modify_date` DATETIME DEFAULT NULL COMMENT '修改日期',
  `delete_mark` INT DEFAULT NULL COMMENT '删除标记',
  `enabled_mark` INT DEFAULT NULL COMMENT '有效标记',
  `group_name` VARCHAR(100) DEFAULT NULL COMMENT '消息分组',
  `name` VARCHAR(100) DEFAULT NULL COMMENT '提示名称',
  `code` VARCHAR(50) DEFAULT NULL COMMENT '唯一code',
  `content` VARCHAR(500) DEFAULT NULL COMMENT '消息内容',
  PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='系统提示信息设置';
INSERT INTO xjr_tips_message(id, create_user_id,create_date, group_name,`name`, `code`,delete_mark,enabled_mark) 
VALUES(1821825335458217986,1000000000000000000,NOW(),'teleservice','无权限提示语','XTM_001',0,1),
(1821825335458217987,1000000000000000000,NOW(),'teleservice','家长绑定非校园卡学生提示语','XTM_002',0,1);

INSERT INTO xjr_tips_message(id, create_user_id,create_date, group_name,`name`, `code`,delete_mark,enabled_mark) 
VALUES(1821825335458217988,1000000000000000000,NOW(),'teleservice','报名流程','XTM_008',0,1);



DROP PROCEDURE IF EXISTS createCom;
DELIMITER $$
CREATE
    PROCEDURE createCom()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM information_schema.columns  WHERE table_name='base_class' AND COLUMN_NAME = 'major_set_id') THEN
ALTER TABLE `base_class`   
  ADD COLUMN `major_set_id` BIGINT NULL   COMMENT '专业方向id(base_major_set)' AFTER `class_type`;
    END IF;
END$$
DELIMITER ;
CALL createCom;
DROP PROCEDURE createCom;

UPDATE base_class t1
INNER JOIN base_class_major_set t2 ON t1.id = t2.class_id
SET t1.major_set_id = t2.major_set_id;
