课堂接口优化

master
秀才 11 months ago
parent feace51b5c
commit b4d6efac5c
  1. 27
      application/wap/controller/Special.php
  2. 8
      application/wap/model/special/Special.php

@ -1829,7 +1829,7 @@ class Special extends AuthController
}
/**
* NEW 课堂首页
* NEW 梦想课堂
*/
public function grade_index()
{
@ -1839,8 +1839,7 @@ class Special extends AuthController
$offlineCourse = (new \app\wap\model\special\OfflineCourse)->order('id desc')->limit(4)->select();
$uid = $this->uid;
$is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0;
$hot = SpecialModel::getSpecialList(['grade_id' => 0, 'subject_id' => 0, 'search' => '', 'page' => 1, 'limit' => 4, 'type' => 0, 'uid' => $uid, 'is_member' => $is_member, 'is_hot' => 1]);
$hot = SpecialModel::getSpecialList(['grade_id' => 0, 'subject_id' => 0, 'search' => '', 'page' => 1, 'limit' => 4, 'type' => 0, 'uid' => $uid, 'is_hot' => 1]);
return JsonService::successful('ok', [
'banner' => GroupDataService::getData('mxtk_banner') ?: [],
@ -1851,6 +1850,23 @@ class Special extends AuthController
]);
}
/**
* NEW 专题首页
*/
public function special_index($grade_id = 0, $subject_id = 0)
{
$offlineCourse = (new \app\wap\model\special\OfflineCourse)->where(['subject_id' => $subject_id])->order('id desc')->limit(4)->select();
$hot = SpecialModel::getSpecialList(['grade_id' => $grade_id, 'subject_id' => $subject_id, 'page' => 1, 'limit' => 4, 'type' => 0, 'is_hot' => 1, 'is_member' => 0, 'search' => '']);
$video = SpecialModel::getSpecialList(['grade_id' => $grade_id, 'subject_id' => $subject_id, 'page' => 1, 'limit' => 4, 'type' => 3, 'special_type' => 3, 'is_member' => 0, 'search' => '', 'uid'=>0]);
return JsonService::successful('ok', [
'video_list' => $video,
'hot_course' => $hot,
'offline_courses' => $offlineCourse,
]);
}
/**
* 线下课详情
* @param $id
@ -1908,12 +1924,13 @@ class Special extends AuthController
* @param int $page
* @param int $limit
* @param int $type 学习记录获取专题使用
* @param int $special_type 专题类型
*/
public function get_special_list($grade_id = 0, $subject_id = 0, $search = '', $page = 1, $limit = 10, $type = 0)
public function get_special_list($grade_id = 0, $subject_id = 0, $search = '', $page = 1, $limit = 10, $type = 0, $special_type = '')
{
$uid = $this->uid;
$is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0;
return JsonService::successful(SpecialModel::getSpecialList(compact('grade_id', 'subject_id', 'search', 'page', 'limit', 'type', 'uid', 'is_member')));
return JsonService::successful(SpecialModel::getSpecialList(compact('grade_id', 'subject_id', 'search', 'page', 'limit', 'type', 'uid', 'is_member', 'special_type')));
}
/**

@ -339,11 +339,16 @@ class Special extends ModelBasic
*/
public static function setWhere($where)
{
// 专题类型
$specialType = isset($where['special_type']) ? $where['special_type'] : '';
if ($where['type']) {
$model = self::PreWhere('a');
if ($where['subject_id'] && $where['grade_id']) {
$model = $model->where('a.subject_id', $where['subject_id']);
}
if($specialType){
$model = $model->where('a.type', $specialType);
}
if ($where['search']) {
$model = $model->where('a.title', 'LIKE', "%$where[search]%");
}
@ -353,6 +358,9 @@ class Special extends ModelBasic
->group('a.id')->where('uid', $where['uid']);
} else {
$model = self::PreWhere();
if($specialType){
$model = $model->where('type', $specialType);
}
if ($where['subject_id'] && $where['grade_id'] > 0) {
$model = $model->where('subject_id', $where['subject_id']);
} else if ($where['subject_id'] == 0 && $where['grade_id'] > 0) {

Loading…
Cancel
Save