www_fpvone_cn/application/index/controller/Schedule.php

54 lines
1.5 KiB
PHP
Raw Normal View History

2024-12-20 12:29:51 +08:00
<?php
/**
* @Created by PhpStorm.
* @Author:Soar
* @Time:2023/11/21 16:28
*/
namespace app\index\controller;
use app\common\controller\Frontend;
use app\index\service\ScheduleService;
class Schedule extends Frontend
{
protected $layout = 'defaults';
protected $noNeedLogin = ['getSchedule'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->scheduleService = new ScheduleService();
}
public function getSchedule()
{
// 解决跨域请求接口问题
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
header('Access-Control-Expose-Headers: *'); //服务器 headers 白名单,可以让客户端进行访问
header('Access-Control-Allow-Headers: *');
$param['match_id'] = $this->request->param('match_id');
if (!$param['match_id']) {
$this->error(__('赛事id不可为空'));
}
$matchSchedules = $this->scheduleService->getByWhere($param);
if (@$matchSchedules) {
$result['code'] = 1;
$result['data'] = $matchSchedules;
$result['msg'] = "获取成功";
} else {
$result['code'] = 1;
$result['data'] = $matchSchedules;
$result['msg'] = "获取失败";
}
return json($result);
}
}