智慧教务系统 PHP-NiuCloud框架开发
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.
 
 
 
 
 
 

124 lines
3.5 KiB

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace addon\zhjw\app\service\admin\schedules;
use addon\zhjw\app\model\schedules\Schedules;
use addon\zhjw\app\model\staff\Staff;
use addon\zhjw\app\model\classes\Classes;
use core\base\BaseAdminService;
/**
* 排班管理服务层
* Class SchedulesService
* @package addon\zhjw\app\service\admin\schedules
*/
class SchedulesService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
$this->model = new Schedules();
}
/**
* 获取排班管理列表
* @param array $where
* @return array
*/
public function getPage(array $where = [])
{
$field = 'id,staff_id,class_id,date_time,time_slot,task,is_deleted,create_time,update_time,created_by,created_role,updated_by,updated_role';
$order = 'id desc';
$search_model = $this->model->withSearch(["staff_id","class_id","date_time","task","create_time"], $where)->with(['staff','classes'])->field($field)->order($order);
$list = $this->pageQuery($search_model);
return $list;
}
/**
* 获取排班管理信息
* @param int $id
* @return array
*/
public function getInfo(int $id)
{
$field = 'id,staff_id,class_id,date_time,time_slot,task,is_deleted,create_time,update_time,created_by,created_role,updated_by,updated_role';
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['staff','classes'])->findOrEmpty()->toArray();
return $info;
}
public function get_info(array $data)
{
$field = 'id,staff_id,class_id,courses_id,date_time,time_slot,task';
$info = $this->model->field($field)->where($data)->findOrEmpty()->toArray();
if(isset($info['time_slot'])){
$info['time_slot'] = explode(",",$info['time_slot']);
}
return $info;
}
/**
* 添加排班管理
* @param array $data
* @return mixed
*/
public function add(array $data)
{
$data['time_slot'] = implode(",",$data['time_slot']);
$res = $this->model->create($data);
return $res->id;
}
/**
* 排班管理编辑
* @param int $id
* @param array $data
* @return bool
*/
public function edit(int $id, array $data)
{
$data['time_slot'] = implode(",",$data['time_slot']);
$this->model->where([['id', '=', $id]])->update($data);
return true;
}
/**
* 删除排班管理
* @param int $id
* @return bool
*/
public function del(int $id)
{
$model = $this->model->where([['id', '=', $id]])->find();
$res = $model->delete();
return $res;
}
public function getStaffAll(){
$staffModel = new Staff();
return $staffModel->select()->toArray();
}
public function getClassesAll(){
$classesModel = new Classes();
return $classesModel->select()->toArray();
}
}