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.

151 lines
6.3 KiB

5 months ago
<?php
namespace App\Http\Controllers\Admin;
use App\Exports\BaseExport;
1 month ago
use App\Exports\CommonExport;
5 months ago
use App\Helpers\ResponseCode;
use App\Models\AppointmentType;
use App\Models\Book;
use App\Models\Calendar;
use App\Models\CourseContentEvaluationAsk;
use App\Models\CourseContentEvaluationForm;
use App\Models\CustomForm;
use App\Models\CustomFormField;
use App\Models\SupplyDemand;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Facades\Excel;
use Rap2hpoutre\FastExcel\FastExcel;
class CalendarsController extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
parent::__construct(new Calendar());
}
/**
* @OA\Get(
* path="/api/admin/calendars/index",
* tags={"日历管理"},
* summary="列表",
* description="",
1 month ago
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是"),
* @OA\Parameter(name="export_fields", in="query", @OA\Schema(type="string"), required=false, description="需要导出的字段数组"),
* @OA\Parameter(name="file_name", in="query", @OA\Schema(type="string"), required=false, description="导出文件名"),
5 months ago
* @OA\Parameter(name="month", in="query", @OA\Schema(type="string"), required=true, description="月份"),
5 months ago
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function index()
{
5 months ago
$all = \request()->all();
$messages = [
'month.required' => '月份必填',
];
$validator = Validator::make($all, [
'month' => 'required',
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
5 months ago
}
4 months ago
$list = Calendar::with('course', 'courseContent')->where('start_time', 'like', $all['month'] . '%')->orderBy('date')->get();
1 month ago
if (isset($all['is_export']) && $all['is_export'] == 1) {
$list = $list->toArray();
return Excel::download(new CommonExport($list, $all['export_fields'] ?? ''), ($all['file_name'] ?? '') . date('YmdHis') . '.xlsx');
}
5 months ago
return $this->success($list);
}
/**
* @OA\Get(
* path="/api/admin/calendars/show",
* tags={"日历管理"},
* summary="详情",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="show_relation", in="query", @OA\Schema(type="string"), required=false, description="需要输出的关联关系数组,填写输出指定数据"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function show()
{
$all = \request()->all();
$messages = [
'id.required' => 'Id必填',
];
$validator = Validator::make($all, [
'id' => 'required'
], $messages);
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
5 months ago
$detail = $this->model->with('courseContent')->find($all['id']);
5 months ago
return $this->success($detail);
}
/**
* @OA\Post(
* path="/api/admin/calendars/save",
* tags={"日历管理"},
* summary="保存",
* description="",
5 months ago
* @OA\Parameter(name="id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="ID存在则更新不存在则新增"),
5 months ago
* @OA\Parameter(name="type", in="query", @OA\Schema(type="integer"), required=false, description="类型1课程2课堂3事件"),
* @OA\Parameter(name="course_id", in="query", @OA\Schema(type="integer"), required=false, description="课程ID"),
5 months ago
* @OA\Parameter(name="course_content_id", in="query", @OA\Schema(type="integer"), required=false, description="课程课堂ID"),
* @OA\Parameter(name="date", in="query", @OA\Schema(type="string", format="date"), required=false, description="日期YYYY-MM-DD"),
* @OA\Parameter(name="title", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="标题"),
5 months ago
* @OA\Parameter(name="url", in="query", @OA\Schema(type="string", maxLength=255), required=false, description="url"),
5 months ago
* @OA\Parameter(name="content", in="query", @OA\Schema(type="string", format="mediumtext"), required=false, description="内容"),
* @OA\Parameter(name="start_time", in="query", @OA\Schema(type="string", format="date-time"), required=false, description="开始时间YYYY-MM-DD HH:MM:SS"),
* @OA\Parameter(name="end_time", in="query", @OA\Schema(type="string", format="date-time"), required=false, description="结束时间YYYY-MM-DD HH:MM:SS"),
4 months ago
* @OA\Parameter(name="is_publish", in="query", @OA\Schema(type="string"), required=true, description="是否向用户发布0否1是"),
* @OA\Parameter(name="address", in="query", @OA\Schema(type="string"), required=true, description="地址"),
3 weeks ago
* @OA\Parameter(name="days", in="query", @OA\Schema(type="string"), required=true, description="天数"),
5 months ago
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"),
* @OA\Response(
* response="200",
* description="操作成功"
* )
* )
*/
public function save()
{
return parent::save();
}
/**
* @OA\Get(
* path="/api/admin/calendars/destroy",
* tags={"日历管理"},
* summary="删除",
* description="",
* @OA\Parameter(name="id", in="query", @OA\Schema(type="string"), required=true, description="id"),
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="暂无"
* )
* )
*/
public function destroy()
{
return parent::destroy();
}
}