#!/bin/bash

source head.sh

echo '
    <div class="container mt-5">
        <h1 class="mb-4">课程表</h1>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>课节号</th>
                    <th>班级</th>
                    <th>教师</th>
                    <th>科目</th>
                    <th>时间</th>
                </tr>
            </thead>
            <tbody>
'
# 尝试从缓存读取
sql="select jx_lesson.id, jx_class.name, jx_teacher.name, jx_subject.name, DATE_FORMAT(FROM_UNIXTIME(jx_lesson.time), '%Y/%m/%d_%H:%i') from jx_lesson  join jx_class on jx_lesson.classId=jx_class.id  join jx_teacher on jx_lesson.teacherId=jx_teacher.id  join jx_subject on jx_lesson.subjectId=jx_subject.id;"
source cache.sh

for stu in ${stuList[@]}; do
  # 获取学号、姓名、班级、年龄
  id=$(echo $stu | awk -F "@" '{print $1}')
  class=$(echo $stu | awk -F "@" '{print $2}')
  teacher=$(echo $stu | awk -F "@" '{print $3}')
  subject=$(echo $stu | awk -F "@" '{print $4}')
  time=$(echo $stu | awk -F "@" '{print $5}')
  echo "
                  <tr>
                      <td>$id</td>
                      <td>$class</td>
                      <td>$teacher</td>
                      <td>$subject</td>
                      <td>$time</td>
                  </tr>
  "
done
echo '
            </tbody>
        </table>
    </div>
    
    <!-- 引入Bootstrap的JavaScript文件，用于一些表格交互效果 -->
    <script src="/static/js/bootstrap.min.js"></script>
</body>
</html>
'
