diff --git a/app/Http/Controllers/Admin/CourseContentEvaluationsController.php b/app/Http/Controllers/Admin/CourseContentEvaluationsController.php index f162ea8..ed997bf 100644 --- a/app/Http/Controllers/Admin/CourseContentEvaluationsController.php +++ b/app/Http/Controllers/Admin/CourseContentEvaluationsController.php @@ -53,7 +53,9 @@ class CourseContentEvaluationsController extends BaseController public function index() { $all = request()->all(); - $list = $this->model->with('course','courseContent')->where(function ($query) use ($all) { + $list = $this->model->with('course','courseContent') + ->withCount('courseContentEvaluationAsks','courseContentEvaluationForms') + ->where(function ($query) use ($all) { if (isset($all['filter']) && !empty($all['filter'])) { foreach ($all['filter'] as $condition) { $key = $condition['key'] ?? null; diff --git a/app/Http/Controllers/Admin/EmailTemplateController.php b/app/Http/Controllers/Admin/EmailTemplateController.php new file mode 100644 index 0000000..3686f6f --- /dev/null +++ b/app/Http/Controllers/Admin/EmailTemplateController.php @@ -0,0 +1,198 @@ +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; + $op = $condition['op'] ?? null; + $value = $condition['value'] ?? null; + if (!isset($key) || !isset($op) || !isset($value)) { + continue; + } + // 等于 + if ($op == 'eq') { + $query->where($key, $value); + } + // 不等于 + if ($op == 'neq') { + $query->where($key, '!=', $value); + } + // 大于 + if ($op == 'gt') { + $query->where($key, '>', $value); + } + // 大于等于 + if ($op == 'egt') { + $query->where($key, '>=', $value); + } + // 小于 + if ($op == 'lt') { + $query->where($key, '<', $value); + } + // 小于等于 + if ($op == 'elt') { + $query->where($key, '<=', $value); + } + // 模糊搜索 + if ($op == 'like') { + $query->where($key, 'like', '%' . $value . '%'); + } + // 否定模糊搜索 + if ($op == 'notlike') { + $query->where($key, 'not like', '%' . $value . '%'); + } + // 范围搜索 + if ($op == 'range') { + list($from, $to) = explode(',', $value); + if (empty($from) || empty($to)) { + continue; + } + $query->whereBetween($key, [$from, $to]); + } + } + } + })->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc'); + if (isset($all['is_export']) && !empty($all['is_export'])) { + $list = $list->get()->toArray(); + $export_fields = $all['export_fields'] ?? []; + // 导出文件名字 + $tableName = $this->model->getTable(); + $filename = (new CustomForm())->getTableComment($tableName); + return Excel::download(new BaseExport($export_fields, $list, $tableName), $filename . date('YmdHis') . '.xlsx'); + } else { + // 输出 + $list = $list->paginate($all['page_size'] ?? 20); + } + 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())]); + } + $detail = $this->model->with('courseContent')->find($all['id']); + return $this->success($detail); + } + + /** + * @OA\Post( + * path="/api/admin/calendars/save", + * 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"), 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", + * 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(); + } + +} diff --git a/app/Models/CourseContentEvaluation.php b/app/Models/CourseContentEvaluation.php index ec220a0..1a210ea 100644 --- a/app/Models/CourseContentEvaluation.php +++ b/app/Models/CourseContentEvaluation.php @@ -20,4 +20,8 @@ class CourseContentEvaluation extends SoftDeletesModel return $this->hasMany(CourseContentEvaluationAsk::class, 'course_content_evaluation_id', 'id'); } + public function courseContentEvaluationForms(){ + return $this->hasMany(CourseContentEvaluationForm::class, 'course_content_evaluation_id', 'id'); + } + } diff --git a/app/Models/EmailRecord.php b/app/Models/EmailRecord.php new file mode 100755 index 0000000..089aedc --- /dev/null +++ b/app/Models/EmailRecord.php @@ -0,0 +1,13 @@ + "Admin", "prefix" => "admin"], function () { Route::post('calendars/save', [\App\Http\Controllers\Admin\CalendarsController::class, "save"]); Route::get('calendars/destroy', [\App\Http\Controllers\Admin\CalendarsController::class, "destroy"]); + // 邮件模版 + Route::get('email-template/index', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "index"]); + Route::get('email-template/show', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "show"]); + Route::post('email-template/save', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "save"]); + Route::get('email-template/destroy', [\App\Http\Controllers\Admin\EmailTemplatesController::class, "destroy"]); + }); });