From eae7394952309e88543c15f957d7cfd6b8bc74ab Mon Sep 17 00:00:00 2001 From: Dai Date: Sat, 18 Jan 2025 14:20:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=B6=E9=95=BF=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=AF=BE=E8=A1=A8=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/StudentController.php | 19 +++++++++++++++++-- .../controller/SubjectHomeworkController.php | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/api/controller/StudentController.php b/app/api/controller/StudentController.php index ee6a7ce..ae1224c 100644 --- a/app/api/controller/StudentController.php +++ b/app/api/controller/StudentController.php @@ -3,10 +3,12 @@ namespace app\api\controller; use app\BaseController; +use app\common\model\Student; use app\common\model\StudentSchedule; use app\common\service\StudentService; use app\constant\ResponseCode; use support\Request; +use think\Exception; class StudentController extends BaseController { @@ -96,9 +98,22 @@ class StudentController extends BaseController public function downloadSchedule(Request $request) { + if (!empty((array)$request->student)) { + $student = Student::where(['id' => $request->student->id])->findOrEmpty(); + if ($student->isEmpty()) { + throw new Exception('未找到用户信息'); + } + } + if (!empty((array)$request->parent)) { + $student = Student::where(['parent_id' => $request->parent->id])->findOrEmpty(); + if ($student->isEmpty()) { + throw new Exception('未找到用户信息'); + } + } + $request_data = $request->post(); $month = date('Y-m', strtotime($request_data['date'])); - $student_schedule = StudentSchedule::where(['student_id' => $request->student->id, 'is_publish' => 1]) + $student_schedule = StudentSchedule::where(['student_id' => $student->id, 'is_publish' => 1]) ->where(['month' => $month]) ->with(['teacher', 'subject']) ->order('start_time asc') @@ -126,7 +141,7 @@ class StudentController extends BaseController 'table_time' => $month, 'data' => $array, ]; - $file_path = '/files/images/student_schedule/' . $month . "/{$request->student->id}/"; + $file_path = '/files/images/student_schedule/' . $month . "/{$student->id}/"; $base = [ 'border' => 10,//图片外边框 'file_path' => public_path($file_path),//图片保存路径 diff --git a/plugin/admin/app/controller/SubjectHomeworkController.php b/plugin/admin/app/controller/SubjectHomeworkController.php index e044b3e..ec4e793 100644 --- a/plugin/admin/app/controller/SubjectHomeworkController.php +++ b/plugin/admin/app/controller/SubjectHomeworkController.php @@ -341,7 +341,7 @@ class SubjectHomeworkController extends Crud /** - * @desc 更改课程报告发布状态 + * @desc 更改课程发布状态 * @param Request $request * @return Response */