diff --git a/app/Http/Controllers/Admin/CalendarsController.php b/app/Http/Controllers/Admin/CalendarsController.php index c8e8068..34032e3 100644 --- a/app/Http/Controllers/Admin/CalendarsController.php +++ b/app/Http/Controllers/Admin/CalendarsController.php @@ -54,7 +54,7 @@ class CalendarsController extends BaseController public function index() { $all = request()->all(); - $list = $this->model->with('user')->where(function ($query) use ($all) { + $list = $this->model->with('courseContent')->where(function ($query) use ($all) { if (isset($all['filter']) && !empty($all['filter'])) { foreach ($all['filter'] as $condition) { $key = $condition['key'] ?? null; @@ -147,7 +147,7 @@ class CalendarsController extends BaseController if ($validator->fails()) { return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]); } - $detail = $this->model->with('user')->find($all['id']); + $detail = $this->model->with('courseContent')->find($all['id']); return $this->success($detail); } @@ -157,14 +157,13 @@ class CalendarsController extends BaseController * tags={"日历管理"}, * summary="保存", * description="", - * @OA\Parameter(name="id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="课程内容评价字段ID(存在则更新,不存在则新增)"), - * @OA\Parameter(name="course_content_id", in="query", @OA\Schema(type="integer", format="int32"), required=true, description="课程排课ID"), - * @OA\Parameter(name="title", in="query", @OA\Schema(type="string"), required=true, description="标题"), - * @OA\Parameter(name="type", in="query", @OA\Schema(type="string"), required=true, description="字段类型。单选radio,多选checkbox,问答text,评分number,日期date,日期时间datetime"), - * @OA\Parameter(name="key", in="query", @OA\Schema(type="string"), required=true, description="英文标识"), - * @OA\Parameter(name="remark", in="query", @OA\Schema(type="string"), required=false, description="备注"), - * @OA\Parameter(name="sort", in="query", @OA\Schema(type="integer", format="int32"), required=false, description="排序"), - * @OA\Parameter(name="options", in="query", @OA\Schema(type="string"), required=false, description="选项,以英文逗号分隔"), + * @OA\Parameter(name="id", in="query", @OA\Schema(type="integer", format="int64"), required=true, description="ID(存在则更新,不存在则新增)"), + * @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="标题"), + * @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)"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="认证token"), * @OA\Response( * response="200", diff --git a/app/Http/Controllers/Admin/CourseContentController.php b/app/Http/Controllers/Admin/CourseContentController.php index 3fb189a..d422e8a 100755 --- a/app/Http/Controllers/Admin/CourseContentController.php +++ b/app/Http/Controllers/Admin/CourseContentController.php @@ -141,7 +141,8 @@ class CourseContentController extends BaseController * @OA\Parameter(name="id", in="query", @OA\Schema(type="integer"), required=true, description="课程ID(存在则更新,不存在则新增)"), * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="验证token"), * @OA\Parameter(name="course_id", in="query", @OA\Schema(type="integer"), description="课程ID"), - * @OA\Parameter(name="period", in="query", @OA\Schema(type="string"), description="时段"), + * @OA\Parameter(name="start_time", in="query", @OA\Schema(type="string"), description="开始时间"), + * @OA\Parameter(name="end_time", in="query", @OA\Schema(type="string"), description="结束时间"), * @OA\Parameter(name="date", in="query", @OA\Schema(type="string", format="date"), description="日期"), * @OA\Parameter(name="teacher_id", in="query", @OA\Schema(type="integer"), description="老师ID"), * @OA\Parameter(name="address", in="query", @OA\Schema(type="string"), description="地址"), diff --git a/app/Http/Controllers/Mobile/CourseController.php b/app/Http/Controllers/Mobile/CourseController.php index bc9d41e..3230fee 100755 --- a/app/Http/Controllers/Mobile/CourseController.php +++ b/app/Http/Controllers/Mobile/CourseController.php @@ -8,6 +8,7 @@ namespace App\Http\Controllers\Mobile; use App\Helpers\ResponseCode; use App\Models\AccompanyOrder; use App\Models\AppointmentTotalLog; +use App\Models\Calendar; use App\Models\Config; use App\Models\Course; use App\Models\CourseAppointmentTotal; @@ -785,4 +786,34 @@ class CourseController extends CommonController $response->send(); } + + /** + * @OA\Get( + * path="/api/mobile/course/calendars", + * tags={"小程序-课程"}, + * summary="日历", + * @OA\Parameter(name="month", in="query", @OA\Schema(type="string"), required=false, description="月份,例如:2025-01"), + * @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"), + * @OA\Response( + * response="200", + * description="暂无" + * ) + * ) + */ + public function calendars() + { + $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())]); + } + $list = Calendar::with('courseContent')->where('date', 'like', $all['month'] . '%')->orderBy('date')->get(); + return $this->success($list); + } + } diff --git a/app/Models/Calendar.php b/app/Models/Calendar.php index 4748ebe..7c14afc 100755 --- a/app/Models/Calendar.php +++ b/app/Models/Calendar.php @@ -11,7 +11,7 @@ class Calendar extends SoftDeletesModel public function courseContent() { - return $this->hasMany(CourseContent::class, '', ''); + return $this->hasMany(CourseContent::class, 'id', 'course_content_id'); } } diff --git a/database/migrations/2025_06_24_111502_alert_course_contents_table.php b/database/migrations/2025_06_24_111502_alert_course_contents_table.php index 8c500ea..2f938cd 100644 --- a/database/migrations/2025_06_24_111502_alert_course_contents_table.php +++ b/database/migrations/2025_06_24_111502_alert_course_contents_table.php @@ -18,6 +18,10 @@ return new class extends Migration $table->string('longitude')->nullable()->comment('经度'); // 纬度 $table->string('latitude')->nullable()->comment('纬度'); + // 开始时间 + $table->dateTime('start_time')->nullable()->comment('开始时间'); + // 结束时间 + $table->dateTime('end_time')->nullable()->comment('结束时间'); }); } diff --git a/routes/api.php b/routes/api.php index 694c070..6894e74 100755 --- a/routes/api.php +++ b/routes/api.php @@ -261,6 +261,8 @@ Route::group(["namespace" => "Mobile", "prefix" => "mobile"], function () { Route::get('course/content-check-list', [\App\Http\Controllers\Mobile\CourseController::class, "contentCheckList"]); // 校友库 Route::get('course/user-list', [\App\Http\Controllers\Mobile\CourseController::class, "userList"]); + // 日历 + Route::get('course/calendars', [\App\Http\Controllers\Mobile\CourseController::class, "calendars"]); // 预约 Route::get('schedule/index', [\App\Http\Controllers\Mobile\ScheduleController::class, "index"]);