From 5c96485889828c351e9e6a2ccd42cba3081b5805 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Tue, 10 Jun 2025 18:05:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=96=B0=E5=A2=9E=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E4=BD=9C=E4=B8=9A=E6=8E=A5=E5=8F=A3=E5=92=8C=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 Assignment 控制器,实现作业列表查询功能 - 新增 AssignmentService 服务类,负责作业数据处理 - 在路由配置中添加学生作业列表接口 - 修正 Assignment 模型的命名空间 --- .../controller/apiController/Assignment.php | 47 ++++++++ niucloud/app/api/route/route.php | 3 + niucloud/app/model/assignment/Assignment.php | 2 +- .../api/apiService/AssignmentService.php | 105 ++++++++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 niucloud/app/api/controller/apiController/Assignment.php create mode 100644 niucloud/app/service/api/apiService/AssignmentService.php diff --git a/niucloud/app/api/controller/apiController/Assignment.php b/niucloud/app/api/controller/apiController/Assignment.php new file mode 100644 index 00000000..7021a5dd --- /dev/null +++ b/niucloud/app/api/controller/apiController/Assignment.php @@ -0,0 +1,47 @@ +param('resources_id', '');//学生资源表id + $status = $request->param('status', '');//状态 1待批改 2未提交 3已提交 + if (empty($resources_id)) { + return fail('缺少参数'); + } + + $where = [ + 'resources_id' => $resources_id, + 'status' => $status, + ]; + + $res = (new AssignmentService())->getList($where); + + return success($res); + } +} diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 9bd2d779..b8c870f9 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -374,6 +374,9 @@ Route::group(function () { //学生端-学生课程安排-学员课时消费记录 Route::get('xy/personCourseSchedule/getStudentCourseUsageList', 'apiController.PersonCourseSchedule/getStudentCourseUsageList'); + //学生端-学生作业-作业列表 + Route::get('xy/assignment', 'apiController.Assignment/index'); + diff --git a/niucloud/app/model/assignment/Assignment.php b/niucloud/app/model/assignment/Assignment.php index e61c6873..facc8ebc 100644 --- a/niucloud/app/model/assignment/Assignment.php +++ b/niucloud/app/model/assignment/Assignment.php @@ -9,7 +9,7 @@ // | Author: Niucloud Team // +---------------------------------------------------------------------- -namespace app\model\Assignment; +namespace app\model\assignment; use core\base\BaseModel; use think\model\concern\SoftDelete; diff --git a/niucloud/app/service/api/apiService/AssignmentService.php b/niucloud/app/service/api/apiService/AssignmentService.php new file mode 100644 index 00000000..2d1e023b --- /dev/null +++ b/niucloud/app/service/api/apiService/AssignmentService.php @@ -0,0 +1,105 @@ +getPageParam();//获取请求参数中的页码+分页数 + $page = $page_params['page']; + $limit = $page_params['limit']; + $student_id = Student::where('id',$where['resources_id'])->value('id');//学生id + $data = Assignment::where('student_id',$student_id); + if(!empty($where['status'])){ + $data = $data->where('status',$where['status']); + } + + $data = $data + ->order('created_at', 'desc') + ->with([ + 'student' => function ($query) { + $query->with([ + 'customerResources' => function ($query2) { + $query2->with([ + 'member' + ]); + } + ]); + }, + ]) + ->paginate([ + 'list_rows' => $limit, + 'page' => $page, + ])->toArray(); + + return $data; + } + + //查询详情 + public function getTestInfo(array $where) + { + $model = new ChatFriends(); + //判断用没有员工id + if (!empty($where['personnel_id'])) { + $model = $model->where('personnel_id', $where['personnel_id']); + } + if (!empty($where['customer_resources_id'])) { + $model = $model->where('customer_resources_id', $where['customer_resources_id']); + } + $data = $model->find(); + + + if ($data) { + $data = $data->toArray(); + $res = [ + 'code' => 1, + 'msg' => '操作成功', + 'data' => $data + ]; + return $res; + } else { + $res = [ + 'code' => 0, + 'msg' => '暂无数据', + 'data' => [] + ]; + return $res; + } + } +}