From eae7394952309e88543c15f957d7cfd6b8bc74ab Mon Sep 17 00:00:00 2001 From: Dai Date: Sat, 18 Jan 2025 14:20:59 +0800 Subject: [PATCH 1/5] =?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 */ From c632ee7011e4199dbab0dc3c19f5ece9c6707169 Mon Sep 17 00:00:00 2001 From: Dai Date: Sat, 18 Jan 2025 14:39:15 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E8=AF=BE=E7=A8=8B=E8=A1=A8=E4=B8=AD=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/StudentController.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin/admin/app/controller/StudentController.php b/plugin/admin/app/controller/StudentController.php index 6a52d06..69bb39b 100644 --- a/plugin/admin/app/controller/StudentController.php +++ b/plugin/admin/app/controller/StudentController.php @@ -56,11 +56,11 @@ class StudentController extends Crud if (isset($data['id']) && $data['id']) { $student->where(['id' => $data['id']]); } - if(isset($data['account']) && $data['account']){ - $student->where('account' ,'like', '%' . $data['account'] . '%'); + if (isset($data['account']) && $data['account']) { + $student->where('account', 'like', '%' . $data['account'] . '%'); } - if(isset($data['student_name']) && $data['student_name']){ - $student->where('student_name' ,'like', '%' . $data['student_name'] . '%'); + if (isset($data['student_name']) && $data['student_name']) { + $student->where('student_name', 'like', '%' . $data['student_name'] . '%'); } $limit = (int)$request->get('limit', 10); @@ -169,6 +169,11 @@ class StudentController extends Crud $student->save($update); + if ($request_data['student_name']) { + //更改其他表中所有学生名称 + StudentSchedule::where(['student_id' => $request_data['id']])->save(['student_name' => $request_data['student_name']]); + } + return json([ 'code' => ResponseCode::WEB_API_SUCCESS, 'msg' => 'success' @@ -245,8 +250,6 @@ class StudentController extends Crud } - - /** * @desc 重置openid * @param Request $request @@ -258,7 +261,7 @@ class StudentController extends Crud $request_data = $request->post(); $student = \app\common\model\Student::where(['id' => $request_data['id']])->findOrEmpty(); - if($student->isEmpty()){ + if ($student->isEmpty()) { throw new Exception('未找到学生信息'); } @@ -376,7 +379,7 @@ class StudentController extends Crud // 遍历每一列 $account = trim($currSheet->getCell('A' . $row)->getValue() ?: ''); $student_name = trim($currSheet->getCell('B' . $row)->getValue() ?: ''); - if($account && $student_name){ + if ($account && $student_name) { $password = trim($currSheet->getCell('C' . $row)->getValue() ?: ''); $salt = random_str(16); if (empty($password)) { From 23ab42b3718fc2422d5efeac2a01df13ecb8727e Mon Sep 17 00:00:00 2001 From: Dai Date: Sat, 18 Jan 2025 15:04:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E9=99=90=E5=88=B6=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E4=B8=AD=E6=96=87=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/admin/app/controller/StudentController.php | 13 +++++++++++++ .../app/controller/StudentParentController.php | 7 +++++++ plugin/admin/app/controller/TeacherController.php | 8 +++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/plugin/admin/app/controller/StudentController.php b/plugin/admin/app/controller/StudentController.php index 69bb39b..f96cbe3 100644 --- a/plugin/admin/app/controller/StudentController.php +++ b/plugin/admin/app/controller/StudentController.php @@ -141,6 +141,10 @@ class StudentController extends Crud throw new Exception('未找到学生信息,操作失败'); } + if (check_chinese_chars($request_data['student_name'])){ + throw new Exception('名字中不能包含中文'); + } + if (empty($request_data['password'])) { $update = [ 'student_name' => $request_data['student_name'], @@ -373,12 +377,18 @@ class StudentController extends Crud $success_count = 0; $error_count = 0; $msg = ''; + $check_msg = ''; // 遍历每一行 for ($row = 2; $row <= $rowCnt; $row++) { // 遍历每一列 $account = trim($currSheet->getCell('A' . $row)->getValue() ?: ''); $student_name = trim($currSheet->getCell('B' . $row)->getValue() ?: ''); + + if(check_chinese_chars($student_name)){ + $check_msg .= '【'+ $student_name +'】'; + } + if ($account && $student_name) { $password = trim($currSheet->getCell('C' . $row)->getValue() ?: ''); $salt = random_str(16); @@ -409,6 +419,9 @@ class StudentController extends Crud if ($error_count) { $return_msg .= ',失败数据' . $msg . '已存在'; } + if($check_msg){ + $return_msg .= ',包含中文字符数据' . $check_msg; + } return json([ 'code' => ResponseCode::WEB_API_SUCCESS, diff --git a/plugin/admin/app/controller/StudentParentController.php b/plugin/admin/app/controller/StudentParentController.php index 30f443f..2d01067 100644 --- a/plugin/admin/app/controller/StudentParentController.php +++ b/plugin/admin/app/controller/StudentParentController.php @@ -293,12 +293,16 @@ class StudentParentController extends Crud $success_count = 0; $error_count = 0; $msg = ''; + $check_msg = ''; // 遍历每一行 for ($row = 2; $row <= $rowCnt; $row++) { // 遍历每一列 $account = trim($currSheet->getCell('A' . $row)->getValue() ?: ''); $parent_name = trim($currSheet->getCell('B' . $row)->getValue() ?: ''); +// if(check_chinese_chars($parent_name)){ +// $check_msg .= '【'+ $parent_name +'】'; +// } if($account && $parent_name){ $password = trim($currSheet->getCell('C' . $row)->getValue() ?: ''); $salt = random_str(16); @@ -329,6 +333,9 @@ class StudentParentController extends Crud if ($error_count) { $return_msg .= ',失败数据' . $msg . '已存在'; } + if($check_msg){ + $return_msg .= ',包含中文字符数据' . $check_msg; + } return json([ 'code' => ResponseCode::WEB_API_SUCCESS, diff --git a/plugin/admin/app/controller/TeacherController.php b/plugin/admin/app/controller/TeacherController.php index 0346708..b48d4b9 100644 --- a/plugin/admin/app/controller/TeacherController.php +++ b/plugin/admin/app/controller/TeacherController.php @@ -461,13 +461,16 @@ class TeacherController extends Crud $success_count = 0; $error_count = 0; $msg = ''; + $check_msg = ''; // 遍历每一行 for ($row = 2; $row <= $rowCnt; $row++) { // 遍历每一列 $account = trim($currSheet->getCell('A' . $row)->getValue() ?: ''); $teacher_name = trim($currSheet->getCell('B' . $row)->getValue() ?: ''); - +// if(check_chinese_chars($teacher_name)){ +// $check_msg .= '【'+ $teacher_name +'】'; +// } if ($account && $teacher_name) { $password = trim($currSheet->getCell('C' . $row)->getValue() ?: ''); @@ -498,6 +501,9 @@ class TeacherController extends Crud if ($error_count) { $return_msg .= ',失败数据' . $msg . '已存在'; } + if($check_msg){ + $return_msg .= ',包含中文字符数据' . $check_msg; + } return json([ 'code' => ResponseCode::WEB_API_SUCCESS, From 398f93dd9e60ea208bc346f995a2fb6c16fb5c35 Mon Sep 17 00:00:00 2001 From: Dai Date: Sat, 18 Jan 2025 15:09:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E9=99=90=E5=88=B6=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E8=B4=A6=E5=8F=B7=E4=B8=8D=E8=83=BD=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/admin/app/controller/StudentController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/admin/app/controller/StudentController.php b/plugin/admin/app/controller/StudentController.php index f96cbe3..f6369f9 100644 --- a/plugin/admin/app/controller/StudentController.php +++ b/plugin/admin/app/controller/StudentController.php @@ -97,6 +97,10 @@ class StudentController extends Crud $request_data = $request->post(); $salt = random_str(16); + + if (check_chinese_chars($request_data['account'])){ + throw new Exception('账号中不能包含中文'); + } if (empty($request_data['password'])) { $password = trim(explode(' ', $request_data['account'])[0]) . '001'; $password = md5($password . $salt); @@ -141,8 +145,8 @@ class StudentController extends Crud throw new Exception('未找到学生信息,操作失败'); } - if (check_chinese_chars($request_data['student_name'])){ - throw new Exception('名字中不能包含中文'); + if (check_chinese_chars($request_data['account'])){ + throw new Exception('账号中不能包含中文'); } if (empty($request_data['password'])) { @@ -385,8 +389,8 @@ class StudentController extends Crud $account = trim($currSheet->getCell('A' . $row)->getValue() ?: ''); $student_name = trim($currSheet->getCell('B' . $row)->getValue() ?: ''); - if(check_chinese_chars($student_name)){ - $check_msg .= '【'+ $student_name +'】'; + if(check_chinese_chars($account)){ + $check_msg .= '【'+ $account +'】'; } if ($account && $student_name) { From e186fd7c384bdda71aabd951369647edcb7973b5 Mon Sep 17 00:00:00 2001 From: Dai Date: Sat, 18 Jan 2025 17:33:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20=E8=8E=B7=E5=8F=96=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StudentHomeworkController.php | 8 +++ app/common/service/StudentHomeworkService.php | 53 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/app/api/controller/StudentHomeworkController.php b/app/api/controller/StudentHomeworkController.php index 9568210..b7993c7 100644 --- a/app/api/controller/StudentHomeworkController.php +++ b/app/api/controller/StudentHomeworkController.php @@ -36,6 +36,14 @@ class StudentHomeworkController extends BaseController } + public function getStudentHomeworkDetail(Request $request) + { + $service = new StudentHomeworkService(); + $result = $service->getStudentHomeworkDetail($request); + return $this->json($result); + } + + /** * @desc 获取学生所有的家庭作业的课程 * @param Request $request diff --git a/app/common/service/StudentHomeworkService.php b/app/common/service/StudentHomeworkService.php index 69160af..d367d77 100644 --- a/app/common/service/StudentHomeworkService.php +++ b/app/common/service/StudentHomeworkService.php @@ -92,6 +92,59 @@ class StudentHomeworkService } + /** + * @desc 获取学生家庭作业详情 + * @param $request + * @return array + */ + public function getStudentHomeworkDetail($request) + { + try { + + if (empty((array)$request->student) && empty((array)$request->parent)) { + throw new Exception('请登陆后再查看'); + } + 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('未找到用户信息'); + } + + } + + $data = $request->post(); + + $studentHomework = StudentHomework::where(['student_id' => $student->id, 'teacher_schedule_time_id'=>$data['teacher_schedule_time_id']]) + ->withoutField('feedback_version_file_url') + ->findOrEmpty(); + + if($studentHomework->feedback_file_url){ + $studentHomework->feedback_file_url = json_decode($studentHomework->feedback_file_url, true); + }else{ + $studentHomework->feedback_file_url = ''; + } + + return [ + 'code' => ResponseCode::SUCCESS, + 'data'=>$studentHomework, + 'msg' => 'success', + ]; + + }catch (Exception $e) { + return [ + 'code' => ResponseCode::FAIL, + 'msg' => $e->getMessage() + ]; + } + } + + /** * @desc 获取学生的课程作业 * @param $request