master
cody 3 months ago
parent 766b66e188
commit 0c3ab1cd18

@ -39,6 +39,7 @@ class CourseContentController extends BaseController
* @OA\Parameter(name="page", in="query", @OA\Schema(type="string"), required=false, description="页码"),
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="direction", 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",
@ -51,11 +52,25 @@ class CourseContentController extends BaseController
$all = request()->all();
$list = $this->model->with($all['show_relation'] ?? [])
->withCount('courseKeeps')
->withCount(['courseKeeps as user_sign_total' => function ($query) {
->withCount([
'courseKeeps as user_sign_total' => function ($query) {
$query->where('status', 1);
}])->withCount(['courseKeeps as user_lack_sign_total' => function ($query) {
}
])->withCount([
'courseKeeps as user_lack_sign_total' => function ($query) {
$query->where('status', 0);
}])->where(function ($query) use ($all) {
}
])->where(function ($query) use ($all) {
// 课程方向筛选(支持多选,多个英文逗号分隔)
if (isset($all['direction']) && !empty($all['direction'])) {
$directions = explode(',', $all['direction']);
$query->where(function ($q) use ($directions) {
foreach ($directions as $direction) {
$q->orWhereRaw('FIND_IN_SET(?, direction)', [trim($direction)]);
}
});
}
if (isset($all['filter']) && !empty($all['filter'])) {
foreach ($all['filter'] as $condition) {
$key = $condition['key'] ?? null;
@ -280,7 +295,7 @@ class CourseContentController extends BaseController
if (!in_array('日期', $keyList)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '日期字段不存在']);
}
// if (!in_array('时间', $keyList)) {
// if (!in_array('时间', $keyList)) {
// return $this->fail([ResponseCode::ERROR_BUSINESS, '时间字段不存在']);
// }
if (!in_array('授课老师', $keyList)) {
@ -292,7 +307,7 @@ class CourseContentController extends BaseController
if (!in_array('课程主题', $keyList)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '课程主题字段不存在']);
}
// if (!in_array('主题方向', $keyList)) {
// if (!in_array('主题方向', $keyList)) {
// return $this->fail([ResponseCode::ERROR_BUSINESS, '主题方向字段不存在']);
// }
// if (!in_array('上课地点', $keyList)) {

Loading…
Cancel
Save