You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.1 KiB
142 lines
4.1 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\service\admin\classroom;
|
|
|
|
use app\model\class_grade\ClassGrade;
|
|
use app\model\campus\Campus;
|
|
use app\model\course_schedule\CourseSchedule;
|
|
use app\model\personnel\Personnel;
|
|
|
|
use app\model\rel\ClassPersonnelRel;
|
|
use app\model\student\Student;
|
|
use core\base\BaseAdminService;
|
|
|
|
|
|
/**
|
|
* 场地管理服务层
|
|
* Class ClassroomService
|
|
* @package app\service\admin\classroom
|
|
*/
|
|
class ClassroomService extends BaseAdminService
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->model = new ClassGrade();
|
|
}
|
|
|
|
/**
|
|
* 获取场地管理列表
|
|
* @param array $where
|
|
* @return array
|
|
*/
|
|
public function getPage(array $where = [])
|
|
{
|
|
$field = 'id,campus_id,campus_name,class_name,educational_id,head_coach,age_group,class_type,assistant_coach,created_at,updated_at,deleted_at,status,sort_order,remarks';
|
|
$order = 'id desc';
|
|
|
|
$search_model = $this->model->withSearch(["campus_id", "class_name", "head_coach", "class_type", "assistant_coach", "created_at", "status"], $where)->with(['campus', 'personnel', 'personnel'])->field($field)->order($order);
|
|
$list = $this->pageQuery($search_model);
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* 获取场地管理信息
|
|
* @param int $id
|
|
* @return array
|
|
*/
|
|
public function getInfo(int $id)
|
|
{
|
|
$field = 'id,campus_id,campus_name,class_name,educational_id,head_coach,age_group,class_type,assistant_coach,created_at,updated_at,deleted_at,status,sort_order,remarks';
|
|
|
|
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['campus', 'personnel', 'personnel'])->findOrEmpty()->toArray();
|
|
$info['status'] = strval($info['status']);
|
|
return $info;
|
|
}
|
|
|
|
/**
|
|
* 添加场地管理
|
|
* @param array $data
|
|
* @return mixed
|
|
*/
|
|
public function add(array $data)
|
|
{
|
|
$res = $this->model->create($data);
|
|
return $res->id;
|
|
|
|
}
|
|
|
|
/**
|
|
* 场地管理编辑
|
|
* @param int $id
|
|
* @param array $data
|
|
* @return bool
|
|
*/
|
|
public function edit(int $id, array $data)
|
|
{
|
|
|
|
$this->model->where([['id', '=', $id]])->update($data);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 删除场地管理
|
|
* @param int $id
|
|
*/
|
|
public function del(int $id)
|
|
{
|
|
$student = new Student();
|
|
if($student->where(['class_id' => $id])->find()){
|
|
return fail("班级下有学员禁止删除");
|
|
}
|
|
$model = $this->model->where([['id', '=', $id]])->find();
|
|
$res = $model->delete();
|
|
return success('DELETE_SUCCESS');
|
|
}
|
|
|
|
|
|
public function getCampusAll()
|
|
{
|
|
$campusModel = new Campus();
|
|
return $campusModel->select()->toArray();
|
|
}
|
|
|
|
public function getPersonnelAll()
|
|
{
|
|
$personnelModel = new Personnel();
|
|
return $personnelModel->select()->toArray();
|
|
}
|
|
|
|
public function classroom_all()
|
|
{
|
|
$data = $this->model->where('status', 1)->order('sort_order desc')->select()->toArray();
|
|
return $data;
|
|
}
|
|
|
|
public function getClassroompeople($class_id)
|
|
{
|
|
$listmodel = new ClassPersonnelRel();
|
|
return $listmodel->with(['student','personnel'])->where('class_id', $class_id)->select()->toArray();
|
|
}
|
|
|
|
/**
|
|
* 获取班级当前时段人员安排情况
|
|
*/
|
|
public function getClassroompeopleCount($venue_id,$where = [])
|
|
{
|
|
$listmodel = new CourseSchedule();
|
|
return $listmodel->where('venue_id', $venue_id)
|
|
->where($where)
|
|
->select()
|
|
->toArray();
|
|
}
|
|
}
|
|
|