From cce32a420372625d5d52ac381bc014e8c30617bf Mon Sep 17 00:00:00 2001 From: Dai Date: Tue, 23 Jul 2024 23:29:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=99=BB=E5=BD=95=EF=BC=8C?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=AE=B6=E5=BA=AD=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/SubjectHomeworkService.php | 5 + app/common/service/TeacherFreeTimeService.php | 105 ++-- app/common/service/UploadService.php | 2 +- .../controller/SubjectHomeworkController.php | 99 ++++ .../admin/app/controller/UploadController.php | 21 + plugin/admin/app/model/SubjectHomework.php | 50 ++ .../app/view/subject-homework/index.html | 466 ++++++++++++++++++ .../app/view/subject-homework/insert.html | 330 +++++++++++++ .../app/view/subject-homework/update.html | 366 ++++++++++++++ .../app/view/teacher-free-time/index.html | 5 +- .../upload/files/20240723/669fc73dc9a1.txt | 0 .../upload/files/20240723/669fc751cf9b.txt | 1 + .../upload/files/20240723/669fc9378a28.txt | 1 + .../upload/files/20240723/669fc941abab.txt | 1 + 14 files changed, 1417 insertions(+), 35 deletions(-) create mode 100644 plugin/admin/app/controller/SubjectHomeworkController.php create mode 100644 plugin/admin/app/model/SubjectHomework.php create mode 100644 plugin/admin/app/view/subject-homework/index.html create mode 100644 plugin/admin/app/view/subject-homework/insert.html create mode 100644 plugin/admin/app/view/subject-homework/update.html create mode 100644 plugin/admin/public/upload/files/20240723/669fc73dc9a1.txt create mode 100644 plugin/admin/public/upload/files/20240723/669fc751cf9b.txt create mode 100644 plugin/admin/public/upload/files/20240723/669fc9378a28.txt create mode 100644 plugin/admin/public/upload/files/20240723/669fc941abab.txt diff --git a/app/common/service/SubjectHomeworkService.php b/app/common/service/SubjectHomeworkService.php index b550b68..4877bab 100644 --- a/app/common/service/SubjectHomeworkService.php +++ b/app/common/service/SubjectHomeworkService.php @@ -47,6 +47,11 @@ class SubjectHomeworkService $res = SubjectHomework::create([ 'teacher_id' => $teacher->id, 'teacher_schedule_time_id' => $data['teacher_schedule_time_id'], + 'date' => $teacher_schedule_time->date, + 'time' => $teacher_schedule_time->time, + 'start_time' => $teacher_schedule_time->start_time, + 'end_time' => $teacher_schedule_time->end_time, + 'month' => $teacher_schedule_time->month, 'subject_id' => $teacher_schedule_time->subject_id, 'homework_file_url' => $data['homework_file_url'], 'homework_file_name' => $data['homework_file_name'], diff --git a/app/common/service/TeacherFreeTimeService.php b/app/common/service/TeacherFreeTimeService.php index d17fe58..6e9ac46 100644 --- a/app/common/service/TeacherFreeTimeService.php +++ b/app/common/service/TeacherFreeTimeService.php @@ -31,50 +31,89 @@ class TeacherFreeTimeService } $data = $request->post(); + if(empty($data['free_time'])){ + throw new Exception('请选择时间后提交'); + } + $free_time = json_decode($data['free_time'], true); - - if (empty($free_time)) { - throw new Exception('请选择时间段之后再提交'); - } $total_count = 0; $exit_count = 0; $err_free_count = 0; - foreach ($free_time as $free_date => $times) { - if ($times) { - foreach ($times as $time) { - $time_period = explode(' - ', $time); - $firstDate = new DateTime($free_date . ' ' . trim($time_period[0])); - $secondDate = new DateTime($free_date . ' ' . trim($time_period[1])); - $diff = $secondDate->diff($firstDate); - $h = $diff->h; - $m = round($diff->i / 60, 2); - $hour = round($h + $m, 2); - $time = $time_period[0] . ' - ' . $time_period[1]; - $free_data = [ - 'teacher_id' => $request->teacher->id, - 'date' => $free_date, - 'time' => $time, - 'hour' => $hour, - 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), - 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), - 'month' => date('Y-m', strtotime($free_date)), - ]; + foreach ($free_time as $item) { + $free_date = $item['day']; + foreach ($item['times'] as $val){ + $time = $val['zh']; + $en_time = $val['en']; + $time_period = explode('-', $time); + $en_time_period = explode('-', $en_time); + $firstDate = new DateTime($free_date . ' ' . trim($time_period[0])); + $secondDate = new DateTime($free_date . ' ' . trim($time_period[1])); + $diff = $secondDate->diff($firstDate); + $h = $diff->h; + $m = round($diff->i / 60, 2); + $hour = round($h + $m, 2); + $time = $time_period[0] . ' - ' . $time_period[1]; + $free_data = [ + 'teacher_id' => $request->teacher->id, + 'date' => $free_date, + 'time' => $time, + 'en_time' => implode(' - ', $en_time_period), + 'hour' => $hour, + 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), + 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), + 'month' => date('Y-m', strtotime($free_date)), + ]; - //判断是否已经存在 - $exit = TeacherFreeTime::where($free_data)->findOrEmpty(); - if(!$exit->isEmpty()){ - continue; - } - $res = TeacherFreeTime::create($free_data); - if(!$res){ - throw new Exception('保存失败'); - } + //判断是否已经存在 + $exit = TeacherFreeTime::where($free_data)->findOrEmpty(); + if(!$exit->isEmpty()){ + continue; } + $res = TeacherFreeTime::create($free_data); + if(!$res){ + throw new Exception('保存失败'); + } + } } + +// foreach ($free_time as $free_date => $times) { +// if ($times) { +// foreach ($times as $time) { +// $time_period = explode(' - ', $time); +// $firstDate = new DateTime($free_date . ' ' . trim($time_period[0])); +// $secondDate = new DateTime($free_date . ' ' . trim($time_period[1])); +// $diff = $secondDate->diff($firstDate); +// $h = $diff->h; +// $m = round($diff->i / 60, 2); +// $hour = round($h + $m, 2); +// $time = $time_period[0] . ' - ' . $time_period[1]; +// $free_data = [ +// 'teacher_id' => $request->teacher->id, +// 'date' => $free_date, +// 'time' => $time, +// 'hour' => $hour, +// 'start_time' => date('Y-m-d H:i:s', $firstDate->getTimestamp()), +// 'end_time' => date('Y-m-d H:i:s', $secondDate->getTimestamp()), +// 'month' => date('Y-m', strtotime($free_date)), +// ]; +// +// //判断是否已经存在 +// $exit = TeacherFreeTime::where($free_data)->findOrEmpty(); +// if(!$exit->isEmpty()){ +// continue; +// } +// $res = TeacherFreeTime::create($free_data); +// if(!$res){ +// throw new Exception('保存失败'); +// } +// } +// } +// } + return [ 'code' => ResponseCode::SUCCESS, 'msg' => '保存成功' diff --git a/app/common/service/UploadService.php b/app/common/service/UploadService.php index 2cf7d57..71a29d7 100644 --- a/app/common/service/UploadService.php +++ b/app/common/service/UploadService.php @@ -67,7 +67,7 @@ class UploadService if ($file && $file->isValid()) { $ext = $file->getUploadExtension(); - if (in_array($ext, ['pdf', 'doc', 'docx', 'xlsx', 'xls', 'csv', 'pptx', 'ppt', 'zip', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PBG'])) { + if (in_array($ext, ['pdf', 'doc', 'docx', 'xlsx', 'xls', 'csv', 'pptx', 'ppt', 'zip', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PBG', 'txt'])) { $type = 'files'; } else { $type = 'other'; diff --git a/plugin/admin/app/controller/SubjectHomeworkController.php b/plugin/admin/app/controller/SubjectHomeworkController.php new file mode 100644 index 0000000..1d8dced --- /dev/null +++ b/plugin/admin/app/controller/SubjectHomeworkController.php @@ -0,0 +1,99 @@ +model = new SubjectHomework; + } + + /** + * 浏览 + * @return Response + */ + public function index(): Response + { + return view('subject-homework/index'); + } + + public function select(Request $request): Response + { + try { + $homework = \app\common\model\SubjectHomework::order('id desc'); + if(1){ + + } + $limit = (int)$request->get('limit', 10); + $limit = $limit <= 0 ? 10 : $limit; + $page = (int)$request->get('page'); + $page = $page > 0 ? $page : 1; + + $total = $homework->count(); + $list = $homework->page($page, $limit)->with(['teacher', 'subject'])->select(); + + return json([ + 'code' => ResponseCode::WEB_API_SUCCESS, + 'data' => $list, + 'count' => $total + ]); + }catch (Exception $e){ + + return json([ + 'code' => ResponseCode::WEB_API_FAIL, + 'msg' => $e->getMessage() + ]); + } + } + + /** + * 插入 + * @param Request $request + * @return Response + * @throws BusinessException + */ + public function insert(Request $request): Response + { + if ($request->method() === 'POST') { + return parent::insert($request); + } + return view('subject-homework/insert'); + } + + /** + * 更新 + * @param Request $request + * @return Response + * @throws BusinessException + */ + public function update(Request $request): Response + { + if ($request->method() === 'POST') { + return parent::update($request); + } + return view('subject-homework/update'); + } + +} diff --git a/plugin/admin/app/controller/UploadController.php b/plugin/admin/app/controller/UploadController.php index e7105e1..166fe99 100644 --- a/plugin/admin/app/controller/UploadController.php +++ b/plugin/admin/app/controller/UploadController.php @@ -2,6 +2,7 @@ namespace plugin\admin\app\controller; +use app\common\service\UploadService; use app\constant\ResponseCode; use app\utils\QiniuUtils; use Exception; @@ -132,6 +133,26 @@ class UploadController extends Crud ]); } + + + /** + * @desc 上传图片 + * @param Request $request + * @return \support\Response + */ + public function uploadFile(Request $request) + { + $service = new UploadService(); + $res = $service->uploadFile($request->file('file')); + if($res['code'] == ResponseCode::SUCCESS){ + return $this->json(0, '上传成功', [ + 'url' => $res['data']['url'], + 'name' => $res['data']['origin_name'] + ]); + } + return $this->json($res); + } + /** * 上传文件 * @param Request $request diff --git a/plugin/admin/app/model/SubjectHomework.php b/plugin/admin/app/model/SubjectHomework.php new file mode 100644 index 0000000..f84b63c --- /dev/null +++ b/plugin/admin/app/model/SubjectHomework.php @@ -0,0 +1,50 @@ + + + + + 浏览页面 + + + + + + +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+ + +
+
+
+ +
+ +
+
+
+
+ +
+ + + +
+
+ 展开 + 收起 +
+
+
+
+ + +
+
+
+
+
+ + + + + + + + + + + + + + + diff --git a/plugin/admin/app/view/subject-homework/insert.html b/plugin/admin/app/view/subject-homework/insert.html new file mode 100644 index 0000000..66fa198 --- /dev/null +++ b/plugin/admin/app/view/subject-homework/insert.html @@ -0,0 +1,330 @@ + + + + + 新增页面 + + + + + + +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+ + + + + + + + + + diff --git a/plugin/admin/app/view/subject-homework/update.html b/plugin/admin/app/view/subject-homework/update.html new file mode 100644 index 0000000..58239e4 --- /dev/null +++ b/plugin/admin/app/view/subject-homework/update.html @@ -0,0 +1,366 @@ + + + + + 更新页面 + + + + + + + +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + + + + + +
+
+ + + + + + + + +
+ +
+ + + + + + +
+
+ + + + + + + + +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+ + + + + + + + + + + diff --git a/plugin/admin/app/view/teacher-free-time/index.html b/plugin/admin/app/view/teacher-free-time/index.html index 31537ea..f4dad50 100644 --- a/plugin/admin/app/view/teacher-free-time/index.html +++ b/plugin/admin/app/view/teacher-free-time/index.html @@ -153,8 +153,11 @@ title: "日期",align: "center", field: "date", },{ - title: "时间",align: "center", + title: "中国时间",align: "center", field: "time", + },{ + title: "当地时间",align: "center", + field: "en_time", },{ title: "课时/h",align: "center", field: "hour", diff --git a/plugin/admin/public/upload/files/20240723/669fc73dc9a1.txt b/plugin/admin/public/upload/files/20240723/669fc73dc9a1.txt new file mode 100644 index 0000000..e69de29 diff --git a/plugin/admin/public/upload/files/20240723/669fc751cf9b.txt b/plugin/admin/public/upload/files/20240723/669fc751cf9b.txt new file mode 100644 index 0000000..f6456b4 --- /dev/null +++ b/plugin/admin/public/upload/files/20240723/669fc751cf9b.txt @@ -0,0 +1 @@ +123123132 \ No newline at end of file diff --git a/plugin/admin/public/upload/files/20240723/669fc9378a28.txt b/plugin/admin/public/upload/files/20240723/669fc9378a28.txt new file mode 100644 index 0000000..f6456b4 --- /dev/null +++ b/plugin/admin/public/upload/files/20240723/669fc9378a28.txt @@ -0,0 +1 @@ +123123132 \ No newline at end of file diff --git a/plugin/admin/public/upload/files/20240723/669fc941abab.txt b/plugin/admin/public/upload/files/20240723/669fc941abab.txt new file mode 100644 index 0000000..f6456b4 --- /dev/null +++ b/plugin/admin/public/upload/files/20240723/669fc941abab.txt @@ -0,0 +1 @@ +123123132 \ No newline at end of file