755 lines
37 KiB
SQL
755 lines
37 KiB
SQL
-- ==========================================
|
||
-- 学生信息管理模块完整优化数据表结构
|
||
-- 版本:V2.0.0 - 完整优化版
|
||
-- 创建时间:2025-01-14
|
||
-- 说明:基于需求分析和数据模型补充分析,创建完整的表结构
|
||
-- 特性:雪花ID、逻辑删除、多租户、完整字段覆盖
|
||
-- ==========================================
|
||
|
||
SET NAMES utf8mb4;
|
||
SET FOREIGN_KEY_CHECKS = 0;
|
||
|
||
-- ===========================================
|
||
-- 1. 学生信息表(核心表)- 完整优化版
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_student_info`;
|
||
CREATE TABLE `xg_student_info` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 基本信息字段
|
||
`student_no` varchar(32) NOT NULL COMMENT '学号',
|
||
`id_card` varchar(18) DEFAULT NULL COMMENT '身份证号',
|
||
`name` varchar(50) NOT NULL COMMENT '姓名',
|
||
`name_english` varchar(100) DEFAULT NULL COMMENT '英文姓名',
|
||
`former_name` varchar(50) DEFAULT NULL COMMENT '曾用名',
|
||
`name_pinyin` varchar(200) DEFAULT NULL COMMENT '姓名拼音',
|
||
`gender` char(1) NOT NULL COMMENT '性别:0-男,1-女',
|
||
`birth_date` date DEFAULT NULL COMMENT '出生日期',
|
||
`nation` varchar(20) DEFAULT NULL COMMENT '民族',
|
||
`political_status` varchar(20) DEFAULT NULL COMMENT '政治面貌',
|
||
`marital_status` varchar(10) DEFAULT NULL COMMENT '婚姻状况:未婚、已婚、离异、丧偶',
|
||
`religion` varchar(20) DEFAULT NULL COMMENT '宗教信仰',
|
||
`photo_url` varchar(500) DEFAULT NULL COMMENT '照片URL',
|
||
`photo_path` varchar(500) DEFAULT NULL COMMENT '学生照片存储路径',
|
||
|
||
-- 学籍信息字段
|
||
`student_status` char(1) DEFAULT '1' COMMENT '学籍状态:1-在籍,2-休学,3-复学,4-退学,5-毕业',
|
||
`enrollment_year` int(4) DEFAULT NULL COMMENT '入学年份',
|
||
`enrollment_date` date DEFAULT NULL COMMENT '入学日期',
|
||
`school_system` int(2) DEFAULT 4 COMMENT '学制(年)',
|
||
`education_level` varchar(20) DEFAULT NULL COMMENT '学历层次',
|
||
`training_type` varchar(20) DEFAULT NULL COMMENT '培养方式:全日制、在职、函授、夜大等',
|
||
`admission_category` varchar(20) DEFAULT NULL COMMENT '录取类别:统招、自主招生、专项计划等',
|
||
`source_region` varchar(100) DEFAULT NULL COMMENT '生源地区(省市县)',
|
||
`middle_school` varchar(100) DEFAULT NULL COMMENT '毕业中学',
|
||
|
||
-- 专业班级信息字段
|
||
`major_code` varchar(20) DEFAULT NULL COMMENT '专业代码',
|
||
`major_name` varchar(100) DEFAULT NULL COMMENT '专业名称',
|
||
`class_code` varchar(32) DEFAULT NULL COMMENT '班级代码',
|
||
`class_name` varchar(100) DEFAULT NULL COMMENT '班级名称',
|
||
`grade` varchar(10) DEFAULT NULL COMMENT '年级',
|
||
|
||
-- 学院信息字段
|
||
`college_code` varchar(20) DEFAULT NULL COMMENT '学院代码',
|
||
`college_name` varchar(100) DEFAULT NULL COMMENT '学院名称',
|
||
|
||
-- 教师信息字段
|
||
`counselor_id` bigint(20) DEFAULT NULL COMMENT '辅导员ID',
|
||
`counselor_name` varchar(50) DEFAULT NULL COMMENT '辅导员姓名',
|
||
`class_teacher_id` bigint(20) DEFAULT NULL COMMENT '班主任ID',
|
||
`class_teacher_name` varchar(50) DEFAULT NULL COMMENT '班主任姓名',
|
||
|
||
-- 联系信息字段
|
||
`phone` varchar(20) DEFAULT NULL COMMENT '手机号码',
|
||
`email` varchar(100) DEFAULT NULL COMMENT '电子邮箱',
|
||
`qq` varchar(20) DEFAULT NULL COMMENT 'QQ号码',
|
||
`wechat` varchar(50) DEFAULT NULL COMMENT '微信号',
|
||
|
||
-- 地址信息字段
|
||
`home_address` varchar(200) DEFAULT NULL COMMENT '家庭地址',
|
||
`current_address` varchar(200) DEFAULT NULL COMMENT '现住址',
|
||
`postal_code` varchar(10) DEFAULT NULL COMMENT '邮政编码',
|
||
`household_register_type` varchar(20) DEFAULT NULL COMMENT '户口类型:农业、非农业',
|
||
`hukou_location` varchar(100) DEFAULT NULL COMMENT '户籍所在地',
|
||
`dormitory_building` varchar(50) DEFAULT NULL COMMENT '宿舍楼栋',
|
||
`dormitory_room` varchar(20) DEFAULT NULL COMMENT '宿舍房间号',
|
||
|
||
-- 紧急联系人信息字段
|
||
`emergency_contact_name` varchar(50) DEFAULT NULL COMMENT '紧急联系人姓名',
|
||
`emergency_contact_phone` varchar(20) DEFAULT NULL COMMENT '紧急联系人电话',
|
||
`emergency_contact_relation` varchar(20) DEFAULT NULL COMMENT '紧急联系人关系',
|
||
|
||
-- 家庭信息字段
|
||
`father_name` varchar(50) DEFAULT NULL COMMENT '父亲姓名',
|
||
`father_phone` varchar(20) DEFAULT NULL COMMENT '父亲电话',
|
||
`father_work_unit` varchar(100) DEFAULT NULL COMMENT '父亲工作单位',
|
||
`mother_name` varchar(50) DEFAULT NULL COMMENT '母亲姓名',
|
||
`mother_phone` varchar(20) DEFAULT NULL COMMENT '母亲电话',
|
||
`mother_work_unit` varchar(100) DEFAULT NULL COMMENT '母亲工作单位',
|
||
`guardian_name` varchar(50) DEFAULT NULL COMMENT '监护人姓名',
|
||
`guardian_phone` varchar(20) DEFAULT NULL COMMENT '监护人电话',
|
||
`guardian_relation` varchar(20) DEFAULT NULL COMMENT '监护人关系',
|
||
`family_income` varchar(20) DEFAULT NULL COMMENT '家庭年收入',
|
||
`family_economic_status` varchar(20) DEFAULT NULL COMMENT '家庭经济状况:富裕、一般、困难、特困',
|
||
`family_members` tinyint(2) DEFAULT NULL COMMENT '家庭成员数量',
|
||
|
||
-- 体征信息字段
|
||
`height` decimal(5,2) DEFAULT NULL COMMENT '身高(cm)',
|
||
`weight` decimal(5,2) DEFAULT NULL COMMENT '体重(kg)',
|
||
`blood_type` varchar(10) DEFAULT NULL COMMENT '血型',
|
||
`health_status` varchar(20) DEFAULT NULL COMMENT '健康状况',
|
||
`special_condition` varchar(200) DEFAULT NULL COMMENT '特殊体质或疾病',
|
||
`medical_history` varchar(500) DEFAULT NULL COMMENT '病史',
|
||
`allergies` varchar(200) DEFAULT NULL COMMENT '过敏史',
|
||
`disability_type` varchar(50) DEFAULT NULL COMMENT '残疾类型',
|
||
`disability_level` varchar(20) DEFAULT NULL COMMENT '残疾等级',
|
||
|
||
-- 银行信息字段
|
||
`bank_card_no` varchar(30) DEFAULT NULL COMMENT '银行卡号',
|
||
`bank_name` varchar(100) DEFAULT NULL COMMENT '开户银行',
|
||
`bank_branch` varchar(100) DEFAULT NULL COMMENT '开户支行',
|
||
`card_holder_name` varchar(50) DEFAULT NULL COMMENT '持卡人姓名',
|
||
|
||
-- 特殊标识字段
|
||
`is_poor_student` tinyint(1) DEFAULT 0 COMMENT '是否贫困生:0-否,1-是',
|
||
`is_minority` tinyint(1) DEFAULT 0 COMMENT '是否少数民族:0-否,1-是',
|
||
`is_disabled` tinyint(1) DEFAULT 0 COMMENT '是否残疾:0-否,1-是',
|
||
`is_orphan` tinyint(1) DEFAULT 0 COMMENT '是否孤儿:0-否,1-是',
|
||
`is_left_behind_child` tinyint(1) DEFAULT 0 COMMENT '是否留守儿童:0-否,1-是',
|
||
`is_single_child` tinyint(1) DEFAULT 0 COMMENT '是否独生子女:0-否,1-是',
|
||
`has_loan` tinyint(1) DEFAULT 0 COMMENT '是否有助学贷款:0-否,1-是',
|
||
`loan_amount` decimal(10,2) DEFAULT NULL COMMENT '助学贷款金额',
|
||
|
||
-- 扩展信息字段
|
||
`specialties` text DEFAULT NULL COMMENT '特长爱好',
|
||
`awards` text DEFAULT NULL COMMENT '获奖情况',
|
||
`violations` text DEFAULT NULL COMMENT '违纪记录',
|
||
`social_activities` text DEFAULT NULL COMMENT '社会活动',
|
||
|
||
-- 状态管理字段
|
||
`info_status` char(1) DEFAULT '1' COMMENT '信息状态:1-正常,2-待审核,3-审核中,4-已驳回,5-已锁定',
|
||
`data_source` varchar(20) DEFAULT 'manual' COMMENT '数据来源:manual-手工录入,import-批量导入,sync-系统同步',
|
||
`last_batch_id` bigint(20) DEFAULT NULL COMMENT '最后修改批次ID',
|
||
`last_audit_time` datetime DEFAULT NULL COMMENT '最后审核时间',
|
||
`is_complete` tinyint(1) DEFAULT 0 COMMENT '信息是否完整:0-不完整,1-完整',
|
||
`completion_rate` decimal(5,2) DEFAULT 0.00 COMMENT '完整度百分比',
|
||
|
||
-- 扩展字段
|
||
`ext_field1` varchar(200) DEFAULT NULL COMMENT '扩展字段1',
|
||
`ext_field2` varchar(200) DEFAULT NULL COMMENT '扩展字段2',
|
||
`ext_field3` varchar(200) DEFAULT NULL COMMENT '扩展字段3',
|
||
`ext_field4` varchar(200) DEFAULT NULL COMMENT '扩展字段4',
|
||
`ext_field5` varchar(500) DEFAULT NULL COMMENT '扩展字段5',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_student_no_tenant` (`student_no`, `tenant_id`),
|
||
UNIQUE KEY `uk_id_card_tenant` (`id_card`, `tenant_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_name` (`name`),
|
||
KEY `idx_college_code` (`college_code`),
|
||
KEY `idx_class_code` (`class_code`),
|
||
KEY `idx_student_status` (`student_status`),
|
||
KEY `idx_info_status` (`info_status`),
|
||
KEY `idx_enrollment_year` (`enrollment_year`),
|
||
KEY `idx_major_code` (`major_code`),
|
||
KEY `idx_counselor_id` (`counselor_id`),
|
||
KEY `idx_class_teacher_id` (`class_teacher_id`),
|
||
KEY `idx_last_batch_id` (`last_batch_id`),
|
||
KEY `idx_phone` (`phone`),
|
||
KEY `idx_create_time` (`create_time`),
|
||
KEY `idx_college_class` (`college_code`, `class_code`),
|
||
KEY `idx_status_filter` (`tenant_id`, `student_status`, `info_status`, `deleted`),
|
||
KEY `idx_grade_college` (`grade`, `college_code`),
|
||
KEY `idx_completion` (`is_complete`, `completion_rate`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学生信息表';
|
||
|
||
-- ===========================================
|
||
-- 2. 班级信息表 - 完整优化版
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_class_info`;
|
||
CREATE TABLE `xg_class_info` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 班级基础信息
|
||
`class_code` varchar(32) NOT NULL COMMENT '班级代码',
|
||
`class_name` varchar(100) NOT NULL COMMENT '班级名称',
|
||
`class_type` varchar(20) DEFAULT 'regular' COMMENT '班级类型:regular-普通班,honor-荣誉班,experimental-实验班',
|
||
`grade` varchar(10) NOT NULL COMMENT '年级',
|
||
`enrollment_year` int(4) NOT NULL COMMENT '入学年份',
|
||
`graduation_year` int(4) DEFAULT NULL COMMENT '毕业年份',
|
||
|
||
-- 专业信息
|
||
`major_code` varchar(20) DEFAULT NULL COMMENT '专业代码',
|
||
`major_name` varchar(100) DEFAULT NULL COMMENT '专业名称',
|
||
`training_type` varchar(20) DEFAULT NULL COMMENT '培养方式:全日制,在职,函授,夜大等',
|
||
`degree_type` varchar(20) DEFAULT NULL COMMENT '学位类型:学士,硕士,博士,专科',
|
||
|
||
-- 学院信息
|
||
`college_code` varchar(20) DEFAULT NULL COMMENT '学院代码',
|
||
`college_name` varchar(100) DEFAULT NULL COMMENT '学院名称',
|
||
|
||
-- 教师信息
|
||
`counselor_id` bigint(20) DEFAULT NULL COMMENT '辅导员ID',
|
||
`counselor_name` varchar(50) DEFAULT NULL COMMENT '辅导员姓名',
|
||
`class_teacher_id` bigint(20) DEFAULT NULL COMMENT '班主任ID',
|
||
`class_teacher_name` varchar(50) DEFAULT NULL COMMENT '班主任姓名',
|
||
`class_advisor_id` bigint(20) DEFAULT NULL COMMENT '班级导师ID',
|
||
`class_advisor_name` varchar(50) DEFAULT NULL COMMENT '班级导师姓名',
|
||
|
||
-- 班干部信息
|
||
`class_monitor_id` bigint(20) DEFAULT NULL COMMENT '班长ID',
|
||
`class_monitor_name` varchar(50) DEFAULT NULL COMMENT '班长姓名',
|
||
`deputy_monitor_id` bigint(20) DEFAULT NULL COMMENT '副班长ID',
|
||
`deputy_monitor_name` varchar(50) DEFAULT NULL COMMENT '副班长姓名',
|
||
|
||
-- 班级状态
|
||
`class_status` char(1) DEFAULT '1' COMMENT '班级状态:1-正常,2-暂停,3-毕业,4-解散',
|
||
`is_graduation` tinyint(1) DEFAULT 0 COMMENT '是否已毕业:0-未毕业,1-已毕业',
|
||
`graduation_date` date DEFAULT NULL COMMENT '毕业日期',
|
||
|
||
-- 人数统计
|
||
`planned_capacity` int(11) DEFAULT 50 COMMENT '计划容量',
|
||
`current_student_count` int(11) DEFAULT 0 COMMENT '当前学生人数',
|
||
`max_student_count` int(11) DEFAULT 50 COMMENT '最大学生人数',
|
||
`male_count` int(11) DEFAULT 0 COMMENT '男生人数',
|
||
`female_count` int(11) DEFAULT 0 COMMENT '女生人数',
|
||
`active_count` int(11) DEFAULT 0 COMMENT '在籍人数',
|
||
`transfer_in_count` int(11) DEFAULT 0 COMMENT '转入人数',
|
||
`transfer_out_count` int(11) DEFAULT 0 COMMENT '转出人数',
|
||
`dropout_count` int(11) DEFAULT 0 COMMENT '退学人数',
|
||
`graduate_count` int(11) DEFAULT 0 COMMENT '毕业人数',
|
||
|
||
-- 联系信息
|
||
`office_location` varchar(200) DEFAULT NULL COMMENT '班级办公室位置',
|
||
`class_location` varchar(100) DEFAULT NULL COMMENT '班级教室位置',
|
||
`contact_phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
|
||
`qq_group` varchar(20) DEFAULT NULL COMMENT 'QQ群号',
|
||
`wechat_group` varchar(100) DEFAULT NULL COMMENT '微信群',
|
||
`email` varchar(100) DEFAULT NULL COMMENT '班级邮箱',
|
||
|
||
-- 班级管理
|
||
`class_schedule` text DEFAULT NULL COMMENT '课程安排(JSON格式)',
|
||
`class_culture` text DEFAULT NULL COMMENT '班级文化建设',
|
||
`class_rules` text DEFAULT NULL COMMENT '班级规章制度',
|
||
`class_description` varchar(500) DEFAULT NULL COMMENT '班级描述',
|
||
|
||
-- 统计信息
|
||
`last_count_update` datetime DEFAULT NULL COMMENT '最后统计更新时间',
|
||
|
||
-- 扩展字段
|
||
`ext_field1` varchar(200) DEFAULT NULL COMMENT '扩展字段1',
|
||
`ext_field2` varchar(200) DEFAULT NULL COMMENT '扩展字段2',
|
||
`ext_field3` varchar(200) DEFAULT NULL COMMENT '扩展字段3',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_class_code_tenant` (`class_code`, `tenant_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_college_code` (`college_code`),
|
||
KEY `idx_enrollment_year` (`enrollment_year`),
|
||
KEY `idx_grade` (`grade`),
|
||
KEY `idx_major_code` (`major_code`),
|
||
KEY `idx_counselor_id` (`counselor_id`),
|
||
KEY `idx_class_teacher_id` (`class_teacher_id`),
|
||
KEY `idx_class_status` (`class_status`),
|
||
KEY `idx_college_grade` (`college_code`, `grade`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='班级信息表';
|
||
|
||
-- ===========================================
|
||
-- 3. 信息采集批次表
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_collection_batch`;
|
||
CREATE TABLE `xg_collection_batch` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_dept` bigint(20) DEFAULT NULL COMMENT '创建部门',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 批次基本信息
|
||
`batch_code` varchar(32) NOT NULL COMMENT '批次编码',
|
||
`batch_name` varchar(100) NOT NULL COMMENT '批次名称',
|
||
`batch_type` varchar(20) DEFAULT 'annual' COMMENT '批次类型:annual-年度采集,semester-学期采集,monthly-月度采集,custom-自定义',
|
||
`academic_year` varchar(20) NOT NULL COMMENT '学年,如2024-2025',
|
||
`semester` varchar(10) DEFAULT NULL COMMENT '学期:spring-春季,autumn-秋季',
|
||
|
||
-- 批次状态
|
||
`batch_status` char(1) DEFAULT '1' COMMENT '批次状态:1-草稿,2-发布,3-进行中,4-已结束,5-已归档',
|
||
`publish_time` datetime DEFAULT NULL COMMENT '发布时间',
|
||
`start_time` datetime DEFAULT NULL COMMENT '开始时间',
|
||
`end_time` datetime DEFAULT NULL COMMENT '结束时间',
|
||
`archive_time` datetime DEFAULT NULL COMMENT '归档时间',
|
||
|
||
-- 批次配置
|
||
`target_colleges` text DEFAULT NULL COMMENT '目标学院(JSON格式)',
|
||
`target_grades` text DEFAULT NULL COMMENT '目标年级(JSON格式)',
|
||
`target_majors` text DEFAULT NULL COMMENT '目标专业(JSON格式)',
|
||
`required_fields` text DEFAULT NULL COMMENT '必填字段(JSON格式)',
|
||
`optional_fields` text DEFAULT NULL COMMENT '可选字段(JSON格式)',
|
||
`audit_levels` text DEFAULT NULL COMMENT '审核级别配置(JSON格式)',
|
||
|
||
-- 统计信息
|
||
`total_students` int(11) DEFAULT 0 COMMENT '总学生数',
|
||
`submitted_count` int(11) DEFAULT 0 COMMENT '已提交数',
|
||
`approved_count` int(11) DEFAULT 0 COMMENT '已审核数',
|
||
`rejected_count` int(11) DEFAULT 0 COMMENT '已驳回数',
|
||
`completion_rate` decimal(5,2) DEFAULT 0.00 COMMENT '完成率',
|
||
|
||
-- 权限配置
|
||
`edit_permissions` text DEFAULT NULL COMMENT '编辑权限(JSON格式)',
|
||
`audit_permissions` text DEFAULT NULL COMMENT '审核权限(JSON格式)',
|
||
`view_permissions` text DEFAULT NULL COMMENT '查看权限(JSON格式)',
|
||
|
||
-- 其他配置
|
||
`auto_reminder` tinyint(1) DEFAULT 1 COMMENT '自动提醒:0-关闭,1-开启',
|
||
`reminder_frequency` int(11) DEFAULT 7 COMMENT '提醒频率(天)',
|
||
`allow_modify_after_submit` tinyint(1) DEFAULT 0 COMMENT '提交后允许修改:0-不允许,1-允许',
|
||
|
||
-- 描述和备注
|
||
`description` varchar(500) DEFAULT NULL COMMENT '批次描述',
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_batch_code_tenant` (`batch_code`, `tenant_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_batch_status` (`batch_status`),
|
||
KEY `idx_academic_year` (`academic_year`),
|
||
KEY `idx_start_end_time` (`start_time`, `end_time`),
|
||
KEY `idx_publish_time` (`publish_time`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='信息采集批次表';
|
||
|
||
-- ===========================================
|
||
-- 4. 审核记录表
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_audit_record`;
|
||
CREATE TABLE `xg_audit_record` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 关联信息
|
||
`batch_id` bigint(20) NOT NULL COMMENT '批次ID',
|
||
`student_id` bigint(20) NOT NULL COMMENT '学生ID',
|
||
`student_no` varchar(32) NOT NULL COMMENT '学号',
|
||
`student_name` varchar(50) NOT NULL COMMENT '学生姓名',
|
||
|
||
-- 审核信息
|
||
`audit_level` tinyint(1) NOT NULL COMMENT '审核级别:1-辅导员,2-班主任,3-学院,4-学生处',
|
||
`audit_result` char(1) NOT NULL COMMENT '审核结果:1-通过,2-驳回,3-退回',
|
||
`auditor_id` bigint(20) NOT NULL COMMENT '审核人ID',
|
||
`auditor_name` varchar(50) NOT NULL COMMENT '审核人姓名',
|
||
`audit_time` datetime NOT NULL COMMENT '审核时间',
|
||
`audit_comment` varchar(500) DEFAULT NULL COMMENT '审核意见',
|
||
|
||
-- 审核详情
|
||
`audit_type` varchar(20) DEFAULT 'submit' COMMENT '审核类型:submit-提交审核,modify-修改审核,batch-批量审核',
|
||
`modified_fields` text DEFAULT NULL COMMENT '修改字段(JSON格式)',
|
||
`reject_reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
|
||
`next_auditor_id` bigint(20) DEFAULT NULL COMMENT '下一级审核人ID',
|
||
`next_auditor_name` varchar(50) DEFAULT NULL COMMENT '下一级审核人姓名',
|
||
|
||
-- 状态信息
|
||
`is_final` tinyint(1) DEFAULT 0 COMMENT '是否最终审核:0-否,1-是',
|
||
`workflow_status` varchar(20) DEFAULT 'pending' COMMENT '流程状态:pending-待审核,processing-审核中,completed-已完成,rejected-已驳回',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_batch_id` (`batch_id`),
|
||
KEY `idx_student_id` (`student_id`),
|
||
KEY `idx_auditor_id` (`auditor_id`),
|
||
KEY `idx_audit_time` (`audit_time`),
|
||
KEY `idx_audit_result` (`audit_result`),
|
||
KEY `idx_workflow_status` (`workflow_status`),
|
||
KEY `idx_batch_level` (`batch_id`, `audit_level`, `audit_result`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审核记录表';
|
||
|
||
-- ===========================================
|
||
-- 5. 班级学生关联表
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_class_student`;
|
||
CREATE TABLE `xg_class_student` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 关联信息
|
||
`class_id` bigint(20) NOT NULL COMMENT '班级ID',
|
||
`student_id` bigint(20) NOT NULL COMMENT '学生ID',
|
||
`student_no` varchar(32) NOT NULL COMMENT '学号',
|
||
`student_name` varchar(50) NOT NULL COMMENT '学生姓名',
|
||
|
||
-- 班级职务
|
||
`class_position` varchar(20) DEFAULT 'member' COMMENT '班级职务:monitor-班长,deputy-副班长,secretary-学习委员,organizer-组织委员,publicity-宣传委员,sports-体育委员,life-生活委员,member-普通成员',
|
||
`position_level` tinyint(1) DEFAULT 9 COMMENT '职务级别:1-班长,2-副班长,3-委员,9-普通成员',
|
||
`appointment_time` datetime DEFAULT NULL COMMENT '任职时间',
|
||
`term_end_time` datetime DEFAULT NULL COMMENT '任期结束时间',
|
||
|
||
-- 状态信息
|
||
`relation_status` char(1) DEFAULT '1' COMMENT '关系状态:1-正常,2-转出,3-转入,4-休学,5-退学',
|
||
`join_time` datetime DEFAULT NULL COMMENT '加入时间',
|
||
`leave_time` datetime DEFAULT NULL COMMENT '离开时间',
|
||
`transfer_reason` varchar(200) DEFAULT NULL COMMENT '转班原因',
|
||
|
||
-- 学号顺序
|
||
`student_order` int(11) DEFAULT 0 COMMENT '班级内学号顺序',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_class_student_tenant` (`class_id`, `student_id`, `tenant_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_student_id` (`student_id`),
|
||
KEY `idx_class_position` (`class_position`),
|
||
KEY `idx_relation_status` (`relation_status`),
|
||
KEY `idx_student_order` (`student_order`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='班级学生关联表';
|
||
|
||
-- ===========================================
|
||
-- 6. 学生信息变更申请表(新增)
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_student_info_change_request`;
|
||
CREATE TABLE `xg_student_info_change_request` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 申请基本信息
|
||
`student_id` bigint(20) NOT NULL COMMENT '学生ID',
|
||
`student_no` varchar(32) NOT NULL COMMENT '学号',
|
||
`student_name` varchar(50) NOT NULL COMMENT '学生姓名',
|
||
`change_type` varchar(20) NOT NULL COMMENT '变更类型:info_update-信息更新,status_change-状态变更',
|
||
`change_fields` text NOT NULL COMMENT '变更字段(JSON格式)',
|
||
`old_values` text NOT NULL COMMENT '原值(JSON格式)',
|
||
`new_values` text NOT NULL COMMENT '新值(JSON格式)',
|
||
`change_reason` varchar(500) NOT NULL COMMENT '变更原因',
|
||
`supporting_documents` text DEFAULT NULL COMMENT '支撑材料(JSON格式)',
|
||
|
||
-- 申请状态
|
||
`request_status` char(1) DEFAULT '1' COMMENT '申请状态:1-待审核,2-审核中,3-已通过,4-已驳回,5-已撤回',
|
||
`submit_time` datetime NOT NULL COMMENT '提交时间',
|
||
`approve_time` datetime DEFAULT NULL COMMENT '审批时间',
|
||
`approver_id` bigint(20) DEFAULT NULL COMMENT '审批人ID',
|
||
`approver_name` varchar(50) DEFAULT NULL COMMENT '审批人姓名',
|
||
`approve_comment` varchar(500) DEFAULT NULL COMMENT '审批意见',
|
||
|
||
-- 关联信息
|
||
`batch_id` bigint(20) DEFAULT NULL COMMENT '关联批次ID',
|
||
`urgency_level` tinyint(1) DEFAULT 2 COMMENT '紧急程度:1-紧急,2-一般,3-不急',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_student_id` (`student_id`),
|
||
KEY `idx_request_status` (`request_status`),
|
||
KEY `idx_change_type` (`change_type`),
|
||
KEY `idx_submit_time` (`submit_time`),
|
||
KEY `idx_batch_id` (`batch_id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='学生信息变更申请表';
|
||
|
||
-- ===========================================
|
||
-- 7. 数据导入导出记录表(新增)
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_data_operation_log`;
|
||
CREATE TABLE `xg_data_operation_log` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 操作基本信息
|
||
`operation_type` varchar(20) NOT NULL COMMENT '操作类型:import-导入,export-导出,backup-备份,restore-恢复',
|
||
`data_type` varchar(20) NOT NULL COMMENT '数据类型:student-学生信息,class-班级信息,batch-批次信息,all-全部',
|
||
`operation_name` varchar(100) NOT NULL COMMENT '操作名称',
|
||
`operation_description` varchar(500) DEFAULT NULL COMMENT '操作描述',
|
||
|
||
-- 操作状态
|
||
`operation_status` char(1) DEFAULT '1' COMMENT '操作状态:1-进行中,2-成功,3-失败,4-部分成功',
|
||
`start_time` datetime NOT NULL COMMENT '开始时间',
|
||
`end_time` datetime DEFAULT NULL COMMENT '结束时间',
|
||
`duration` int(11) DEFAULT NULL COMMENT '耗时(秒)',
|
||
|
||
-- 文件信息
|
||
`source_file_name` varchar(200) DEFAULT NULL COMMENT '源文件名',
|
||
`source_file_path` varchar(500) DEFAULT NULL COMMENT '源文件路径',
|
||
`target_file_name` varchar(200) DEFAULT NULL COMMENT '目标文件名',
|
||
`target_file_path` varchar(500) DEFAULT NULL COMMENT '目标文件路径',
|
||
`file_size` bigint(20) DEFAULT NULL COMMENT '文件大小(字节)',
|
||
|
||
-- 数据统计
|
||
`total_records` int(11) DEFAULT 0 COMMENT '总记录数',
|
||
`success_records` int(11) DEFAULT 0 COMMENT '成功记录数',
|
||
`failed_records` int(11) DEFAULT 0 COMMENT '失败记录数',
|
||
`warning_records` int(11) DEFAULT 0 COMMENT '警告记录数',
|
||
|
||
-- 结果信息
|
||
`result_message` text DEFAULT NULL COMMENT '结果消息',
|
||
`error_details` text DEFAULT NULL COMMENT '错误详情(JSON格式)',
|
||
`warning_details` text DEFAULT NULL COMMENT '警告详情(JSON格式)',
|
||
|
||
-- 操作人信息
|
||
`operator_id` bigint(20) NOT NULL COMMENT '操作人ID',
|
||
`operator_name` varchar(50) NOT NULL COMMENT '操作人姓名',
|
||
|
||
-- 关联信息
|
||
`batch_id` bigint(20) DEFAULT NULL COMMENT '关联批次ID',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_operation_type` (`operation_type`),
|
||
KEY `idx_data_type` (`data_type`),
|
||
KEY `idx_operation_status` (`operation_status`),
|
||
KEY `idx_operator_id` (`operator_id`),
|
||
KEY `idx_start_time` (`start_time`),
|
||
KEY `idx_batch_id` (`batch_id`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据导入导出记录表';
|
||
|
||
-- ===========================================
|
||
-- 8. 统计分析配置表(新增)
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_statistics_config`;
|
||
CREATE TABLE `xg_statistics_config` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 配置基本信息
|
||
`config_name` varchar(100) NOT NULL COMMENT '配置名称',
|
||
`config_code` varchar(50) NOT NULL COMMENT '配置编码',
|
||
`config_type` varchar(20) NOT NULL COMMENT '配置类型:dimension-维度,report-报表,chart-图表',
|
||
`config_content` text NOT NULL COMMENT '配置内容(JSON格式)',
|
||
|
||
-- 配置属性
|
||
`is_system` tinyint(1) DEFAULT 0 COMMENT '是否系统配置:0-否,1-是',
|
||
`is_enabled` tinyint(1) DEFAULT 1 COMMENT '是否启用:0-否,1-是',
|
||
`sort_order` int(11) DEFAULT 0 COMMENT '排序顺序',
|
||
|
||
-- 权限配置
|
||
`view_permissions` text DEFAULT NULL COMMENT '查看权限(JSON格式)',
|
||
`edit_permissions` text DEFAULT NULL COMMENT '编辑权限(JSON格式)',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_config_code_tenant` (`config_code`, `tenant_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_config_type` (`config_type`),
|
||
KEY `idx_is_enabled` (`is_enabled`),
|
||
KEY `idx_sort_order` (`sort_order`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='统计分析配置表';
|
||
|
||
-- ===========================================
|
||
-- 9. 统计结果缓存表(新增)
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_statistics_cache`;
|
||
CREATE TABLE `xg_statistics_cache` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 缓存基本信息
|
||
`cache_key` varchar(200) NOT NULL COMMENT '缓存键',
|
||
`cache_type` varchar(20) NOT NULL COMMENT '缓存类型:dimension-维度统计,report-报表,chart-图表',
|
||
`cache_content` longtext NOT NULL COMMENT '缓存内容(JSON格式)',
|
||
|
||
-- 缓存时间信息
|
||
`cache_time` datetime NOT NULL COMMENT '缓存时间',
|
||
`expire_time` datetime NOT NULL COMMENT '过期时间',
|
||
`is_expired` tinyint(1) DEFAULT 0 COMMENT '是否过期:0-否,1-是',
|
||
|
||
-- 统计信息
|
||
`hit_count` int(11) DEFAULT 0 COMMENT '命中次数',
|
||
`last_hit_time` datetime DEFAULT NULL COMMENT '最后命中时间',
|
||
|
||
-- 数据大小
|
||
`data_size` int(11) DEFAULT 0 COMMENT '数据大小(字节)',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_cache_key_tenant` (`cache_key`, `tenant_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_cache_type` (`cache_type`),
|
||
KEY `idx_expire_time` (`expire_time`),
|
||
KEY `idx_is_expired` (`is_expired`),
|
||
KEY `idx_hit_count` (`hit_count`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='统计结果缓存表';
|
||
|
||
-- ===========================================
|
||
-- 10. 数据权限配置表(新增)
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_data_permission`;
|
||
CREATE TABLE `xg_data_permission` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_by` bigint(20) DEFAULT NULL COMMENT '创建者',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_by` bigint(20) DEFAULT NULL COMMENT '更新者',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 权限基本信息
|
||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||
`user_name` varchar(50) NOT NULL COMMENT '用户姓名',
|
||
`permission_type` varchar(20) NOT NULL COMMENT '权限类型:college-学院,major-专业,class-班级,student-学生',
|
||
`permission_scope` varchar(20) NOT NULL COMMENT '权限范围:all-全部,own-自己负责,custom-自定义',
|
||
`scope_values` text DEFAULT NULL COMMENT '权限范围值(JSON格式)',
|
||
`permission_level` tinyint(1) NOT NULL COMMENT '权限级别:1-查看,2-编辑,3-审核,4-管理',
|
||
|
||
-- 权限状态
|
||
`is_enabled` tinyint(1) DEFAULT 1 COMMENT '是否启用:0-否,1-是',
|
||
`effective_time` datetime DEFAULT NULL COMMENT '生效时间',
|
||
`expire_time` datetime DEFAULT NULL COMMENT '失效时间',
|
||
|
||
-- 备注字段
|
||
`remark` varchar(500) DEFAULT NULL COMMENT '备注信息',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_user_id` (`user_id`),
|
||
KEY `idx_permission_type` (`permission_type`),
|
||
KEY `idx_permission_scope` (`permission_scope`),
|
||
KEY `idx_is_enabled` (`is_enabled`),
|
||
KEY `idx_effective_expire` (`effective_time`, `expire_time`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据权限配置表';
|
||
|
||
-- ===========================================
|
||
-- 11. 移动端用户会话表(新增)
|
||
-- ===========================================
|
||
DROP TABLE IF EXISTS `xg_mobile_user_session`;
|
||
CREATE TABLE `xg_mobile_user_session` (
|
||
-- 标准基础字段(必须)
|
||
`id` bigint(20) NOT NULL COMMENT '主键ID(雪花ID)',
|
||
`tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
|
||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||
`deleted` tinyint(1) DEFAULT 0 COMMENT '删除标志(0代表存在 1代表删除)',
|
||
|
||
-- 会话基本信息
|
||
`user_id` bigint(20) NOT NULL COMMENT '用户ID',
|
||
`user_name` varchar(50) NOT NULL COMMENT '用户姓名',
|
||
`user_type` varchar(20) NOT NULL COMMENT '用户类型:student-学生,teacher-教师,admin-管理员',
|
||
`session_id` varchar(100) NOT NULL COMMENT '会话ID',
|
||
|
||
-- 设备信息
|
||
`device_id` varchar(100) DEFAULT NULL COMMENT '设备ID',
|
||
`device_type` varchar(20) DEFAULT NULL COMMENT '设备类型:ios-苹果,android-安卓,h5-网页',
|
||
`app_version` varchar(20) DEFAULT NULL COMMENT '应用版本',
|
||
`user_agent` varchar(500) DEFAULT NULL COMMENT '用户代理',
|
||
|
||
-- 会话时间信息
|
||
`login_time` datetime NOT NULL COMMENT '登录时间',
|
||
`last_activity_time` datetime DEFAULT NULL COMMENT '最后活动时间',
|
||
`logout_time` datetime DEFAULT NULL COMMENT '退出时间',
|
||
|
||
-- 网络信息
|
||
`ip_address` varchar(50) DEFAULT NULL COMMENT 'IP地址',
|
||
`location` varchar(100) DEFAULT NULL COMMENT '地理位置',
|
||
|
||
-- 会话状态
|
||
`is_active` tinyint(1) DEFAULT 1 COMMENT '是否活跃:0-否,1-是',
|
||
`session_duration` int(11) DEFAULT 0 COMMENT '会话时长(分钟)',
|
||
|
||
-- 主键和索引
|
||
PRIMARY KEY (`id`) USING BTREE,
|
||
UNIQUE KEY `uk_session_id` (`session_id`),
|
||
KEY `idx_tenant_id` (`tenant_id`),
|
||
KEY `idx_deleted` (`deleted`),
|
||
KEY `idx_user_id` (`user_id`),
|
||
KEY `idx_device_id` (`device_id`),
|
||
KEY `idx_is_active` (`is_active`),
|
||
KEY `idx_login_time` (`login_time`),
|
||
KEY `idx_user_type` (`user_type`)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='移动端用户会话表';
|
||
|
||
-- ===========================================
|
||
-- 创建表完成提示
|
||
-- ===========================================
|
||
SELECT 'XG学生信息管理模块完整优化数据表创建完成!' as message;
|
||
SELECT '共创建11个核心业务表,包含5个原有表优化和6个新增补充表' as summary;
|
||
SELECT '所有表都遵循雪花ID、逻辑删除、多租户规范' as features;
|
||
|
||
SET FOREIGN_KEY_CHECKS = 1; |