
-- id,开始时间,结束时间,右上角的类别,中间竖线左边内容,中间竖线右边地点,底部类别,名称,参与人id
DROP VIEW IF EXISTS today_schedule;
CREATE VIEW today_schedule AS
SELECT t1.id,CONCAT(t1.schedule_date, ' ', t1.start_time) AS start_time,CONCAT(t1.schedule_date, ' ', t1.end_time) AS end_time,t1.adjust_type,t1.class_name AS title,t2.name AS place,t1.course_name AS schedule_name,'课程' AS category,t1.teacher_id AS user_id FROM course_table t1
INNER JOIN base_classroom t2 ON t1.site_id = t2.id
WHERE t1.schedule_date = DATE_FORMAT(NOW(), '%Y-%m-%d')
UNION ALL
SELECT t1.id,CONCAT(t1.event_start_time, ' 00:00:00'),CONCAT(t1.event_end_time, ' 23:59:59'),NULL,t1.event_type,t1.event_address,t1.moral_event_name,'活动' AS category,t1.attend_teacher FROM moral_event t1
WHERE DATE_FORMAT(NOW(), '%Y-%m-%d') BETWEEN DATE_FORMAT(t1.event_start_time, '%Y-%m-%d') AND DATE_FORMAT(t1.event_end_time, '%Y-%m-%d')
UNION ALL
SELECT t1.id,CONCAT(t1.event_start_time, ' 00:00:00'),CONCAT(t1.event_end_time, ' 23:59:59'),NULL,t1.event_type,t1.event_address,t1.party_tissue_name,'活动' AS category,t1.participant_teacher_name FROM party_build_event t1
WHERE DATE_FORMAT(NOW(), '%Y-%m-%d') BETWEEN DATE_FORMAT(t1.event_start_time, '%Y-%m-%d') AND DATE_FORMAT(t1.event_end_time, '%Y-%m-%d')
UNION ALL
SELECT t1.id,t1.start_time,t1.end_time,NULL,t1.activity_type,t1.activity_location,t1.club_activities_name,'活动' AS category,t1.user_id FROM club_activities t1
WHERE DATE_FORMAT(NOW(), '%Y-%m-%d') BETWEEN DATE_FORMAT(t1.start_time, '%Y-%m-%d') AND DATE_FORMAT(t1.end_time, '%Y-%m-%d')
UNION ALL
SELECT t1.id,t1.start_date,t1.end_date,t1.type,REPLACE(REPLACE(t1.category,1,'校企合作活动'),2,'赛事活动'),t1.place,t1.name,'活动' AS category,t2.user_id FROM activity_info t1
INNER JOIN activity_enroll t2 ON t2.activity_info_id = t1.id
WHERE DATE_FORMAT(NOW(), '%Y-%m-%d') BETWEEN DATE_FORMAT(t1.start_date, '%Y-%m-%d') AND DATE_FORMAT(t1.end_date, '%Y-%m-%d')
UNION ALL
SELECT t1.id,CONCAT(t1.meeting_apply_date, t1.meeting_apply_s),CONCAT(t1.meeting_apply_date,t1.meeting_apply_e),'会议',CONCAT(t4.name,t3.name) AS place,'会议',t1.meeting_apply_theme,'会议' AS category,t2.user_id FROM wf_meeting_apply t1
INNER JOIN meeting_conferee t2 ON t2.wf_meeting_apply_id = t1.id
LEFT JOIN meeting_room t3 ON t1.meeting_room_id = t3.id
LEFT JOIN base_office_build t4 ON t3.office_build_id = t4.id
WHERE t1.meeting_apply_date = DATE_FORMAT(NOW(), '%Y-%m-%d');