Browse Source
- 新增 PersonCourseSchedule 控制器,实现学生课程安排列表接口 - 新增 PersonCourseScheduleService 服务类,提供课程安排查询功能 - 在路由文件中添加学生课程安排相关路由master
3 changed files with 145 additions and 0 deletions
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\api\controller\apiController; |
||||
|
|
||||
|
use app\Request; |
||||
|
use app\service\api\apiService\PersonCourseScheduleService; |
||||
|
use core\base\BaseApiService; |
||||
|
|
||||
|
/** |
||||
|
* 学生课程安排-控制器相关接口 |
||||
|
* Class Personnel |
||||
|
* @package app\api\controller\apiController |
||||
|
*/ |
||||
|
class PersonCourseSchedule extends BaseApiService |
||||
|
{ |
||||
|
|
||||
|
//列表 |
||||
|
public function index(Request $request) |
||||
|
{ |
||||
|
$resources_id = $request->param('resources_id', '');//客户资源ID |
||||
|
if (empty($resources_id)) { |
||||
|
return fail('缺少参数'); |
||||
|
} |
||||
|
|
||||
|
$where = [ |
||||
|
'resources_id' => $resources_id, |
||||
|
]; |
||||
|
|
||||
|
$res = (new PersonCourseScheduleService())->getList($where); |
||||
|
|
||||
|
return success($res); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,98 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\api\apiService; |
||||
|
|
||||
|
use app\model\chat_friends\ChatFriends; |
||||
|
use app\model\course_schedule\CourseSchedule; |
||||
|
use app\model\person_course_schedule\PersonCourseSchedule; |
||||
|
use core\base\BaseApiService; |
||||
|
use think\facade\Db; |
||||
|
|
||||
|
/** |
||||
|
* 测试-控制器服务层 |
||||
|
* Class MemberService |
||||
|
* @package app\service\api\member |
||||
|
*/ |
||||
|
class PersonCourseScheduleService extends BaseApiService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
//查询列表 |
||||
|
public function getList(array $where) |
||||
|
{ |
||||
|
$page_params = $this->getPageParam();//获取请求参数中的页码+分页数 |
||||
|
$page = $page_params['page']; |
||||
|
$limit = $page_params['limit']; |
||||
|
|
||||
|
$model = new PersonCourseSchedule(); |
||||
|
//判断有没有客户资源id |
||||
|
if (!empty($where['resources_id'])) { |
||||
|
$model = $model->where('resources_id', $where['resources_id']); |
||||
|
} |
||||
|
$schedule_id = $model->distinct(true)->column('schedule_id');//课程安排id |
||||
|
if(!$schedule_id){ |
||||
|
return []; |
||||
|
} |
||||
|
|
||||
|
$data = CourseSchedule::whereIn('id', $schedule_id) |
||||
|
->order('course_date','desc') |
||||
|
->with([ |
||||
|
'venue',//场地 |
||||
|
'campus',//校区 |
||||
|
'course',//课程 |
||||
|
]) |
||||
|
|
||||
|
->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