DiverseYouthNightSchool/application/api/controller/school/Classes.php

119 lines
2.8 KiB
PHP
Raw Normal View History

<?php
namespace app\api\controller\school;
use app\common\model\school\classes\ClassesLib;
use think\Cache;
use think\Log;
/**
* 课程接口
*/
class Classes extends Base
{
protected $noNeedLogin = ["detail",'people','spec'];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new ClassesLib;
parent::_initialize();
//判断登录用户是否是员工
}
public function index()
{
}
/**
* @ApiTitle(课程详情接口)
* @ApiSummary(课程详情接口)
* @ApiRoute(/api/school/classes/detail)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "课程id")
* @ApiReturn({
*
*})
*/
public function detail(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = $this->model->detail($id);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['detail' => $res]);
}
/**
* @ApiTitle(课程参与者和报名者)
* @ApiSummary(课程参与者和报名者)
* @ApiRoute(/api/school/classes/people)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "课程id")
* @ApiReturn({ unpaid_user_data 参与中 paid_user_data 已报名 })
*/
public function people(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = $this->model->virtualParticipants($id);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', $res);
}
/**
* @ApiTitle(课程课时规格)
* @ApiSummary(课程课时规格)
* @ApiRoute(/api/school/classes/spec)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "课程id")
* @ApiReturn({ spec 课时规格 })
*/
public function spec(){
$id = $this->request->get('id/d','');
if(empty($id)){
$this->error(__('缺少必要参数'));
}
try {
$res = $this->model->spec($id);
} catch (\Exception $e){
// Log::log($e->getMessage());
$this->error($e->getMessage(),['errcode'=>$e->getCode()]);
}
$this->success('获取成功', ['spec'=>$res]);
}
}