peixue-dev/Archive/sql/[一次性]检查成长记录表.sql

60 lines
3.8 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 检查成长记录表是否存在
SHOW TABLES LIKE 'growth_record';
-- 如果表不存在,创建成长记录表
CREATE TABLE IF NOT EXISTS `growth_record` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`order_id` bigint(20) DEFAULT NULL COMMENT '订单ID',
`teacher_id` bigint(20) DEFAULT NULL COMMENT '教师ID',
`student_id` bigint(20) DEFAULT NULL COMMENT '学生ID',
`student_name` varchar(100) DEFAULT NULL COMMENT '学生姓名(冗余字段)',
`record_date` date DEFAULT NULL COMMENT '记录日期',
`record_type` varchar(20) DEFAULT NULL COMMENT '记录类型daily-每日weekly-每周monthly-每月',
`content` text COMMENT '文字内容',
`supplement` text COMMENT '管理师补充内容',
`images` text COMMENT '图片URL列表JSON数组',
`videos` text COMMENT '视频URL列表JSON数组',
`pdf_url` varchar(500) DEFAULT NULL COMMENT 'PDF文件URL',
`status` int(11) DEFAULT '0' COMMENT '状态0-草稿1-已提交',
`tenant_id` bigint(20) DEFAULT NULL COMMENT '租户ID',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` int(11) DEFAULT '0' COMMENT '逻辑删除0-未删除1-已删除',
`is_archived` int(11) DEFAULT '0' COMMENT '是否已归档0-未归档1-已归档',
`archived_to_id` bigint(20) DEFAULT NULL COMMENT '归档到的上级记录ID',
`archived_time` datetime DEFAULT NULL COMMENT '归档时间',
`week_start_date` date DEFAULT NULL COMMENT '周开始日期(周反馈使用)',
`month_year` varchar(10) DEFAULT NULL COMMENT '月份月反馈使用格式2026-01',
`summary` text COMMENT '总结内容(周/月反馈使用)',
`review_status` int(11) DEFAULT '0' COMMENT '审核状态0=待审核, 1=通过, 2=需修改',
`review_note` text COMMENT '审核备注',
`review_time` datetime DEFAULT NULL COMMENT '审核时间',
`reviewer_id` bigint(20) DEFAULT NULL COMMENT '审核人ID',
`parent_satisfaction` int(11) DEFAULT NULL COMMENT '家长满意度1-5星',
`parent_note` text COMMENT '家长备注',
`parent_view_time` datetime DEFAULT NULL COMMENT '家长查看时间',
`has_question` int(11) DEFAULT '0' COMMENT '是否有疑问0=无, 1=有',
`handle_status` int(11) DEFAULT '0' COMMENT '处理状态0=无需处理, 1=待处理, 2=处理中, 3=已解决',
`handle_note` text COMMENT '处理记录(支持追加)',
`handle_time` datetime DEFAULT NULL COMMENT '处理时间',
`handler_id` bigint(20) DEFAULT NULL COMMENT '处理人ID',
`archive_status` int(11) DEFAULT '0' COMMENT '归档状态0=未归档, 1=已归档',
`archive_time` datetime DEFAULT NULL COMMENT '归档时间',
PRIMARY KEY (`id`),
KEY `idx_order_id` (`order_id`),
KEY `idx_teacher_id` (`teacher_id`),
KEY `idx_student_id` (`student_id`),
KEY `idx_record_date` (`record_date`),
KEY `idx_record_type` (`record_type`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='成长记录表';
-- 插入一些测试数据
INSERT INTO `growth_record` (`order_id`, `teacher_id`, `student_id`, `student_name`, `record_date`, `record_type`, `content`, `status`, `create_time`) VALUES
(1, 1, 1, '测试学生1', '2026-01-27', 'daily', '今天学生学习了数学,表现很好,掌握了加减法运算。', 1, NOW()),
(2, 2, 2, '测试学生2', '2026-01-27', 'daily', '学生学习了语文,能够背诵古诗,理解能力有所提升。', 1, NOW()),
(3, 1, 3, '测试学生3', '2026-01-26', 'weekly', '本周学生学习了英语单词,词汇量有所增加,建议多练习口语。', 1, NOW());
-- 查询测试数据
SELECT * FROM `growth_record` ORDER BY `create_time` DESC LIMIT 5;