Browse Source
- 添加 Assignment 控制器,实现作业列表查询功能 - 新增 AssignmentService 服务类,负责作业数据处理 - 在路由配置中添加学生作业列表接口 - 修正 Assignment 模型的命名空间master
4 changed files with 156 additions and 1 deletions
@ -0,0 +1,47 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\Request; |
|||
use app\service\api\apiService\AssignmentService; |
|||
use app\service\api\apiService\CampusService; |
|||
use app\service\api\apiService\ChatService; |
|||
use app\service\api\apiService\CommonService; |
|||
use core\base\BaseApiService; |
|||
|
|||
/** |
|||
* 学生作业表-控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class Assignment extends BaseApiService |
|||
{ |
|||
|
|||
//列表 |
|||
public function index(Request $request) |
|||
{ |
|||
$resources_id = $request->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); |
|||
} |
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\service\api\apiService; |
|||
|
|||
use app\model\assignment\Assignment; |
|||
use app\model\campus\Campus; |
|||
use app\model\campus_person_role\CampusPersonRole; |
|||
use app\model\chat_friends\ChatFriends; |
|||
use app\model\chat_messages\ChatMessages; |
|||
use app\model\customer_resources\CustomerResources; |
|||
use app\model\dict\Dict; |
|||
use app\model\member\Member; |
|||
use app\model\student\Student; |
|||
use core\base\BaseApiService; |
|||
use think\facade\Db; |
|||
|
|||
/** |
|||
* 学员作业表-控制器服务层 |
|||
* Class MemberService |
|||
* @package app\service\api\member |
|||
*/ |
|||
class AssignmentService extends BaseApiService |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
//查询列表 |
|||
public function getList(array $where) |
|||
{ |
|||
$page_params = $this->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; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue