123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace Content\V1;
- use Dever;
- use Content\Lib\Base;
- class Course extends Base
- {
- /**
- * @api {get} v1/course.list 听课列表
- * @apiVersion 1.0.0
- * @apiName course.list
- * @apiGroup Data
- *
- * @apiDescription 小程序的听课列表接口
- *
- * @apiParam {Number} appid 小程序id
- *
- * @apiSuccess {Object[]} info 小程序基本信息
- * @apiSuccess {Number} info.id 小程序id
- * @apiSuccess {String} info.name 小程序名称
- * @apiSuccess {Number} info.cate_id 小程序所属栏目id
- * @apiSuccess {String} info.logo 小程序logo
- * @apiSuccess {String} info.title 首页标题
- * @apiSuccess {String} info.pic 首页头图
- *
- * @apiSuccess {Object[]} course 听课信息
- * @apiSuccess {Number} course.id 听课id
- * @apiSuccess {String} course.name 听课标题
- * @apiSuccess {String} course.content 听课内容
- * @apiSuccess {String} course.pic 听课封面
- * @apiSuccess {String} course.top 听课详情页头图
- * @apiSuccess {String} course.num_view 阅读数
- * @apiSuccess {String} course.num_watch 观看人数
- * @apiSuccess {String} course.num_review 评论数
- * @apiSuccess {String} course.num_up 赞数
- * @apiSuccess {String} course.video 视频地址
- * @apiSuccess {String} course.audio 音频地址
- * @apiSuccess {String} course.cdate 时间
- *
- * @apiSuccess {Object[]} course.author 作者信息
- * @apiSuccess {Number} course.author.id 作者id
- * @apiSuccess {String} course.author.name 作者姓名
- * @apiSuccess {String} course.author.pic 作者头像
- *
- * @apiSuccessExample 操作成功
- * {"status":1,"code":1,"msg":"success","data":{"info":{"id":"1","name":"\u7279\u8272\u5c0f\u9547\u600e\u4e48\u641e","cate_id":"1","logo":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","title":"test","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","state":"1","cdate":"1521858466"},"course":[{"id":"1","name":"\u662f\u662f\u662f","pic":["http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg"],"top":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","info_id":"1","author_id":"1","content":"<p>23132323<\/p>","num_view":"2","cdate":"1\u5206\u949f\u524d","author":{"id":"1","name":"\u7a0b\u8302","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","state":"1","cdate":"1521858481"}}]},"page":{"total":"1","current_page":1,"total_page":1,"next_page":1,"prev_page":1,"html":"","status":0}}
- *
- * @apiErrorExample 操作失败
- * {"status":2,"code":1,"msg":"\u9519\u8bef\u7684\u5c0f\u7a0b\u5e8fid"}
- */
- public function list_api()
- {
- $this->data['course'] = Dever::load('content/course-getAll', array('option_info_id' => $this->data['info']['id']));
- if ($this->data['course']) {
- foreach ($this->data['course'] as $k => $v) {
- $this->data['course'][$k] = $this->one($v);
- }
- }
- return $this->data;
- }
- /**
- * @api {get} v1/course.view 课程详情
- * @apiVersion 1.0.0
- * @apiName course.view
- * @apiGroup Data
- *
- * @apiDescription 小程序的课程详情接口
- *
- * @apiParam {Number} appid 小程序id
- * @apiParam {Number} id 课程id
- *
- * @apiSuccess {Object[]} info 小程序基本信息
- * @apiSuccess {Number} info.id 小程序id
- * @apiSuccess {String} info.name 小程序名称
- * @apiSuccess {Number} info.cate_id 小程序所属栏目id
- * @apiSuccess {String} info.logo 小程序logo
- * @apiSuccess {String} info.title 首页标题
- * @apiSuccess {String} info.pic 首页头图
- *
- * @apiSuccess {Object[]} course 听课信息
- * @apiSuccess {Number} course.id 听课id
- * @apiSuccess {String} course.name 听课标题
- * @apiSuccess {String} course.content 听课内容
- * @apiSuccess {String} course.pic 听课封面
- * @apiSuccess {String} course.top 听课详情页头图
- * @apiSuccess {String} course.num_watch 观看人数
- * @apiSuccess {String} course.num_view 阅读数
- * @apiSuccess {String} course.num_review 评论数
- * @apiSuccess {String} course.num_up 赞数
- * @apiSuccess {String} course.video 视频地址
- * @apiSuccess {String} course.audio 音频地址
- * @apiSuccess {String} course.cdate 时间
- *
- * @apiSuccess {Object[]} course.author 作者信息
- * @apiSuccess {Number} course.author.id 作者id
- * @apiSuccess {String} course.author.name 作者姓名
- * @apiSuccess {String} course.author.pic 作者头像
- *
- * @apiSuccess {Object[]} course.user 观看用户信息
- * @apiSuccess {Number} course.user.id 用户id
- * @apiSuccess {String} course.user.name 用户姓名
- * @apiSuccess {String} course.user.pic 用户头像
- *
- * @apiSuccessExample 操作成功
- * {"status":1,"code":1,"msg":"success","data":{"info":{"id":"1","name":"\u7279\u8272\u5c0f\u9547\u600e\u4e48\u641e","cate_id":"1","logo":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","title":"test","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","state":"1","cdate":"1521858466"},"course":{"id":"1","name":"\u662f\u662f\u662f","info_id":"1","author_id":"1","video":"123123","audio":"3232","num_add_view":"0","num_up":"0","num_view":"1","num_review":"0","pic":["http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg"],"top":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/da31b5d54d15192fea10406f77f4b0cb.jpg","content":"<p>23132323<\/p>","reorder":"1","state":"1","cdate":"42\u79d2\u524d","author":{"id":"1","name":"\u7a0b\u8302","pic":"http:\/\/192.168.33.10\/plant\/data\/upload\/1\/2018\/03\/24\/1e493a87d4cdddde7fd06ad9762694d2.jpg","state":"1","cdate":"1521858481"}}}}
- *
- * @apiErrorExample 操作失败
- * {"status":2,"code":1,"msg":"\u9519\u8bef\u7684\u5c0f\u7a0b\u5e8fid"}
- */
- public function view_api()
- {
- $id = Dever::input('id');
- if ($id > 0) {
- $course = Dever::load('content/course-one', $id);
- if ($course) {
- $this->data['course'] = $this->one($course);
- $watch = Dever::load('comment/watch-state', array('option_info_id' => $this->data['info']['id'], 'option_course_id' => $id));
- $this->data['course']['user'] = array();
- if ($watch) {
- foreach($watch as $k => $v) {
- $this->data['course']['user'][] = Dever::load('passport/user-one', $v['uid']);
- }
- }
- $this->data['course']['user_count'] = count($this->data['course']['user']);
- # 增加阅读量
- Dever::load('content/course-addView', $id);
- } else {
- Dever::alert('错误的课程id');
- }
- } else {
- Dever::alert('错误的课程id');
- }
- $this->data['vote'] = $this->vote(2, $id);
- return $this->data;
- }
- }
|