作者 何书鹏
1 个管道 的构建 通过 耗费 2 秒

合并分支 'heshupeng' 到 'master'

课程收藏



查看合并请求 !180
... ... @@ -9,6 +9,7 @@ use app\mobile\model\CourseCatalog;
use app\mobile\model\CourseAppraise;
use app\mobile\model\CourseSpec;
use app\mobile\model\CourseOrder;
use app\mobile\model\CourseCollect;
use app\mobile\model\Company;
use app\mobile\model\CompanyUser;
use addons\epay\library\Service;
... ... @@ -134,6 +135,7 @@ class Course extends Api
"video": "https://vd2.bdstatic.com/mda-jkptk0q9euab5v41/sc/mda-jkptk0q9euab5v41.mp4?auth_key=1599909914-0-0-1b5b778ac7883d30cf78883ff8884b7e&bcevod_channel=searchbox_feed&pd=1&pt=3" //视频
},
"is_buy": 0, //是否已购买:0=否,1=是
"is_collect": 0, //是否已收藏:0=否,1=是
}
})
*/
... ... @@ -194,6 +196,9 @@ class Course extends Api
->field('id')
->find();
$info['is_buy'] = !empty($order) ? 1 : 0;
// 是否已收藏
$collect = CourseCollect::where('user_id',$this->auth->id)->where('course_id',$course_id)->field('id')->find();
$info['is_collect'] = !empty($collect) ? 1 : 0;
$this->success('成功',$info->visible([
'id',
'title',
... ... @@ -203,11 +208,44 @@ class Course extends Api
'content'
])->append([
'video',
'is_buy'
'is_buy',
'is_collect'
]));
}
/**
* @ApiTitle (课程详情-收藏)
* @ApiSummary (课程详情-收藏)
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="course_id", type="int", required=true, description="课程ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1599032660",
"data": null
})
*/
public function collect()
{
$course_id = $this->request->param('course_id');
empty($course_id) && $this->error('缺少必要参数');
$info = CourseCollect::get(['course_id'=>$course_id,'user_id'=>$this->auth->id]);
if(!empty($info)){
$info->delete();
$this->success('取消收藏成功');
}
CourseCollect::create([
'course_id' => $course_id,
'user_id' => $this->auth->id,
]);
$this->success('收藏成功');
}
/**
* @ApiTitle (课程详情-目录)
* @ApiSummary (课程详情-目录)
* @ApiMethod (POST)
... ...
此 diff 太大无法显示。