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

105 lines
2.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\controller\school;
use app\common\model\school\classes\ActivityDemo;
use app\common\model\school\classes\Teacher as Teachermodel;
/**
* 活动接口
*/
class Activity extends Base
{
protected $noNeedLogin = ["demo_detail","demo_list"];
protected $noNeedRight = '*';
protected $model = null;
/**
* 初始化操作
* @access protected
*/
protected function _initialize()
{
$this->model = new ActivityDemo();
parent::_initialize();
//判断登录用户是否是员工
}
/**
* @ApiTitle( 活动demo数据详情)
* @ApiSummary(活动demo数据详情)
* @ApiMethod(GET)
* @ApiParams(name = "id", type = "int",required=true,description = "活动demo数据id")
* @ApiReturn({
*
*})
*/
public function demo_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( 活动demo数据列表取决于搜索条件)
* @ApiSummary(活动demo数据列表取决于搜索条件)
* @ApiMethod(GET)
* @ApiParams(name = "keywords", type = "string",required=false,description = "搜索关键字")
* @ApiParams(name = "page", type = "string",required=true,description = "页数")
* @ApiParams(name = "limit", type = "string",required=true,description = "条数")
* @ApiParams(name = "status", type = "string",required=false,description = "状态:1=报名中,2=已结束")
* @ApiReturn({
*
*})
*/
public function demo_list()
{
$user_id = 0;
$user = $this->auth->getUser();//登录用户
if($user)$user_id = $user['id'];
$params=[];
$page = $this->request->get('page/d', 0); //页数
$limit = $this->request->get('limit/d', 0); //条数
$params['keywords'] = $this->request->get('keywords/s', ''); //搜索关键字
$params['status'] = $this->request->get('status/s', ''); //搜索关键字
// $type = $this->request->get('type/s', ''); //筛选学员和教练单
try{
//当前申请状态
$res = $this->model::allList($page, $limit,$params);
// if($user_id =='670153'){
// file_put_contents("ceshi66.txt",(new AppointmentOrder())->getLastSql());
// }
}catch (\Exception $e){
$this->error($e->getMessage());
}
$this->success('查询成功', $res);
}
}