0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray(); }else{ $list = SeriesArticleCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray(); } $list = make_tree($list); $this->success('ok',['list'=>$list]); } /** * @title 图文推荐 * @desc 图文推荐 * @author qc * @method GET * @url /api/Article/getRecommendList * @header name:Authorization require:1 desc:Token * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:id type:string default:-- desc:图文item_id * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:系列id * @return name:cover type:string default:-- desc:封面 * @return name:images_arr type:string default:-- desc:图片 * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是) * @return name:read_num type:int default:-- desc:阅读量 * @return name:app_name type:string default:-- desc:平台名称 * @return name:app_logo type:string default:-- desc:平台头像 */ public function getRecommendList() { $app_name = sysconf('app_name'); $app_logo = sysconf('app_logo'); $search_log = UserSearch::getSearchTitle($this->user_id,2); $search_arr = []; $where_str = 'b.id > 0'; foreach ($search_log as $t){ $search_arr[] = " b.title like '".'%'.$t."%'" .' '; $search_arr[] = " b.label like '".'%'.$t."%'" .' '; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); $field = ' a.id,a.title,a.cover,a.images,a.user_id,a.is_vip,a.read_num,a.article_id ,IFNULL(is_recommend,0) is_recommend '; $table = 'dd_article_item'; $order_by_two = 'a.read_num'; $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id LEFT JOIN dd_article_intro as k ON k.id = a.article_id WHERE a.is_deleted = 0 AND a.status =1 AND k.status = 1 AND k.is_deleted = 0 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}"; $list = Db::query($sql); array_walk($list,function (&$v,$k)use ($app_name,$app_logo){ if(!$v['user_id']){ $v['app_name'] = $app_name; $v['app_logo'] = $app_logo; }else{ $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find(); $v['app_name'] = $user_info ? $user_info->name : ''; $v['app_logo'] = $user_info ? $user_info->headimg : ''; } $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null; }); $this->success('ok',['list'=>$list]); } /** * @title 获取图文列表(平台发布) * @desc 获取图文列表 * @author qc * @method GET * @url /api/Article/getArticleList * @header name:Authorization require:1 desc:Token * @param name:type type:int default:0 desc:类型1单个2系列 * @param name:is_tj type:int default:0 desc:是否推荐0否1是 * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序 * @param name:first_classify type:int default:0 desc:一级分类 * @param name:second_classify type:int default:0 desc:二级分类 * @return name:id type:string default:-- desc:ID[请求/api/Article/getArticleDetail用] * @return name:title type:string default:-- desc:标题 * @return name:type type:int default:0 desc:类型1单个2系列 * @return name:cover type:string default:-- desc:封面() * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是) * @return name:is_over type:int default:-- desc:是否完结(0否,1是) * @return name:read_num type:int default:-- desc:阅读量 * @return name:label type:string default:-- desc:标签 * @return name:item_list type:array default:-- desc:图文 * @return name:item_list.title type:string default:-- desc:图文标题 * @return name:item_list.is_vip type:int default:-- desc:是否是vip * @return name:item_list.cover type:string default:-- desc:图文封面 * @return name:item_list.images type:string default:-- desc:图片(多张用|隔开) * @return name:item_list.content type:string default:-- desc:内容 */ public function getArticleList() { $sel_where = []; $title = input('get.title'); $type = input('get.type',0); $is_tj = input('get.is_tj',0); $sort_type = input('get.sort_type',1); $first_classify = input('get.first_classify'); $second_classify = input('get.second_classify'); $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['status','=',1]; $sel_where[] = ['item_num','>',0]; if($title) $sel_where[] = ['title|label','like','%'.$title.'%']; if($type) $sel_where[] = ['type','=',$type]; if($first_classify) $sel_where[] = ['first_classify','=',$first_classify]; if($second_classify) $sel_where[] = ['second_classify','=',$second_classify]; switch ($sort_type) { case 1: $order = ['sort'=>'desc','id'=>'desc']; break; case 2: $order = ['id'=>'asc','sort'=>'desc']; break; case 3: $order = ['id'=>'desc','sort'=>'desc']; break; } if($title && $this->user_id)UserSearch::saveSearchTitle($this->user_id,$title,2); $where_str = 'id > 0'; if($is_tj) { $search_log = UserSearch::getSearchTitle($this->user_id,2); $search_arr = []; foreach ($search_log as $t){ $search_arr[] = " title like '".'%'.$t."%'" .' '; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); } $list = ArticleIntro::where($sel_where)->with('itemList') ->limit($this->off_set,$this->page_num) ->where($where_str) ->order($order) ->select()->toArray(); array_walk($list,function (&$v,$k){ }); $this->success('ok',['list'=>$list]); } /** * @title 获取图文详情(平台) * @desc 获取图文详情 * @author qc * @method GET * @url /api/Article/getArticleDetail * @header name:Authorization require:1 desc:Token * @param name:id type:int default:0 desc:图文id * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:images type:string default:-- desc:图片 * @return name:is_vip type:string default:-- desc:是否VIP * @return name:item_list type:array default:-- desc:图文 * @return name:item_list.id type:string default:-- desc:[请求/api/Article/getArticleItemInfo用,请求图文模块其他接口参数:item_id] * @return name:item_list.title type:string default:-- desc:图文标题 * @return name:item_list.is_vip type:int default:-- desc:是否是vip * @return name:item_list.cover type:string default:-- desc:封面 * @return name:item_list.images type:int default:-- desc:图片 * @return name:item_list.content type:int default:-- desc:内容 * @return name:item_list.transmit_num type:int default:-- desc:转发量 * @return name:item_list.read_num type:int default:-- desc:阅读量 * @return name:item_list.comment_num type:int default:-- desc:评论量 * @return name:item_list.collect_num type:int default:-- desc:收藏量 * @return name:item_list.is_collect type:int default:-- desc:是否收藏 * @return name:item_list.video_id type:int default:-- desc:关联视频id【单个id||系列id】 * @return name:item_list.video_item type:int default:-- desc:关联视频详情id【video_arr.id】 * @return name:item_list.datum_id type:int default:-- desc:资料id【单个id||系列id】 * @return name:item_list.datum_item type:int default:-- desc:资料详情id【url_arr.id】 */ public function getArticleDetail() { $sel_where = []; $sel_where[] = ['id','=',input('get.id')]; $detail = ArticleIntro::where($sel_where)->with('itemList')->find()->toArray(); if($detail['is_deleted'] == 1 || $detail['status'] == 0)$this->error('该图文已下线'); foreach ($detail['item_list'] as &$dv) { $dv['comment_num'] = ArticleComment::where(['article_id'=>$detail['id'],'item_id'=>$dv['id']])->count(); $dv['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count(); $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['id'],$dv['id']); } $detail['read_num'] = array_sum(array_column($detail['item_list'],'read_num')); $this->success('ok',['detail'=>$detail]); } /** * @title 获取图文ITEM详情(平台) * @desc 获取图文ITEM详情 * @author qc * @method GET * @url /api/Article/getArticleItemInfo * @header name:Authorization require:1 desc:Token * @param name:item_id type:int default:0 desc:item_list * @return name:title type:string default:-- desc:图文标题 * @return name:is_vip type:int default:-- desc:是否是vip * @return name:cover type:string default:-- desc:封面 * @return name:images type:int default:-- desc:图片 * @return name:content type:int default:-- desc:内容 * @return name:transmit_num type:int default:-- desc:转发量 * @return name:read_num type:int default:-- desc:阅读量 * @return name:comment_num type:int default:-- desc:评论量 * @return name:collect_num type:int default:-- desc:收藏量 * @return name:is_collect type:int default:-- desc:是否收藏 * @return name:like_num type:int default:-- desc:点赞量 * @return name:is_like type:int default:-- desc:是否点赞 * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】 * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】 * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】 * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】 */ public function getArticleItemInfo() { $item_id = input('get.item_id'); $detail = ArticleItem::where('id',$item_id)->find()->toArray(); $detail['comment_num'] = ArticleComment::where(['article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count(); $detail['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['article_id'],'children_id'=>$detail['id']])->count(); $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['article_id'],$detail['id']); $detail['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count(); $detail['like_num'] = ArticleLike::where(['article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count(); UserTrack::crateTrack($this->user_id,3,$detail['article_id'],$item_id); //var_dump($this->user_id,3,$detail['article_id'],$item_id); $this->success('ok',['detail'=>$detail]); } /** * @title 获取图文评论列表 * @desc 获取图文评论列表 * @author qc * @method GET * @url /api/Article/getArticleCommentList * @header name:Authorization require:1 desc:Token * @param name:article_id type:int default:-- desc:图文id * @param name:item_id type:int default:-- desc:item_id * @param name:sort_type type:int default:1 desc:排序1默认2时间升序3时间降序 * @param name:page type:int default:-- desc:页数 * @return name:name type:string default:-- desc:会员名称 * @return name:headimg type:string default:-- desc:会员头像 * @return name:content type:string default:-- desc:内容 * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】) * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】) * @return name:like_num type:int default:-- desc:点赞数量 * @return name:is_like type:int default:-- desc:是否点赞(0否1是) * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是) * @return name:total_num type:int default:-- desc:总评论数(仅一级) */ public function getArticleCommentList() { $where = []; $where[] = ['c.article_id','=',input('get.article_id')]; $where[] = ['c.is_deleted','=',0]; $user_id = $this->user_id; $sort_type= input('sort_type',1); if(input('get.item_id')) $where[] = ['c.item_id','=',input('get.item_id')]; switch ($sort_type) { case 1: $order = ['sort'=>'desc','id'=>'desc']; break; case 2: $order = ['id'=>'asc','sort'=>'desc']; break; case 3: $order = ['id'=>'desc','sort'=>'desc']; break; } $list =ArticleComment::where($where) ->alias('c') ->field('c.*,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->order($order) ->limit($this->off_set,$this->page_num) ->select()->toArray(); array_walk($list,function (&$val,$k)use($user_id){ $children = ArticleComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0]) ->alias('c')->field('c.*,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->order('c.id asc') ->select()->toArray(); $val['children'] = $children; $val['like_num'] = ArticleCommentLike::where('like_id',$val['id'])->count(); $val['is_like'] = ArticleCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id])->count(); $parent = ArticleComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0]) ->alias('c')->field('c.*,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->find(); $val['parent'] = $parent ? $parent->toArray() : null; $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0; }); $total_num = ArticleComment::where($where)->alias('c')->count(); $this->success('ok',['list'=>$list,'total_num'=>$total_num]); } /** * @title 以下接口调用验证登录【需要header传Authorization】 * @desc 转发成功后调用 * @author qc * @method * @url /api/Article/needLogin() */ public function needLogin(){} /** * @title 图文转发(转发数量统计) * @desc 转发成功后调用 * @author qc * @method POST * @url /api/Article/articleTransmit * @header name:Authorization require:1 desc:Token * @param name:item_id type:int default:-- desc:item_list的id */ public function articleTransmit() { $item_id = input('post.item_id',0); ArticleItem::where('id',$item_id)->setInc('transmit_num'); $this->success('ok'); } /** * @title 图文阅读(阅读数量统计) * @desc 图文阅读 * @author qc * @method POST * @url /api/Article/articleRead * @header name:Authorization require:1 desc:Token * @param name:item_id type:int default:-- desc:item_list的id */ public function articleRead() { $item_id = input('post.item_id',0); ArticleItem::where('id',$item_id)->setInc('read_num'); $this->success('ok'); } /** * @title 图文点赞||取消点赞 * @desc 点赞||取消点赞 * @author qc * @method POST * @url /api/Article/articleTags * @header name:Authorization require:1 desc:Token * @param name:article_id type:int default:1 desc:图文id * @param name:item_id type:int default:1 desc:item_id * @return name:tags type:int default:1 desc:0取消成功,1点赞成功 */ public function articleTags() { $article_id = input('post.article_id'); $item_id = input('post.item_id'); $ret_val = 0; $check_tags = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id])->value('id'); if($check_tags) { ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id])->delete(); }else{ Data::save('ArticleLike', ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id],'user_id', ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id]); $ret_val = 1; } $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]); } /** * @title 图文评论 * @desc 图文评论 * @author qc * @method POST * @url /api/Article/articleComment * @header name:Authorization require:1 desc:Token * @param name:article_id type:int default:1 desc:图文id * @param name:item_id type:int default:1 desc:item_id * @param name:content type:string default:-- desc:内容 * @return name:name type:string default:-- desc:会员名称 * @return name:headimg type:string default:-- desc:会员头像 * @return name:content type:string default:-- desc:内容 */ public function articleComment() { $article_id = input('post.article_id'); $item_id = input('post.item_id'); $content = input('post.content',0); if(!$content) $this->error('请输入评论内容'); $res = ArticleComment::create(['user_id'=>$this->user_id,'content'=>$content,'article_id'=>$article_id,'item_id'=>$item_id]); $detail =ArticleComment::where('c.id',$res->id) ->alias('c') ->field('c.id,c.content,c.create_at,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->find()->toArray(); $send_user = ArticleItem::where('id',$item_id)->value('user_id'); $user_info = $this->userInfo('name'); if($send_user) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$item_id,$user_info['name'].'评论了您的图文'); $this->success('评论成功',['detail'=>$detail]); } /** * @title 删除评论 * @desc 删除评论 * @author qc * @method POST * @url /api/Article/delComment * @header name:Authorization require:1 desc:Token * @param name:id type:int default:1 desc:评论id */ public function delComment(){ ArticleComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]); $this->success('删除成功'); } /** * @title 图文二级评论 * @desc 图文二级评论 * @author qc * @method POST * @url /api/Article/secondCommend * @header name:Authorization require:1 desc:Token * @param name:id type:int default:1 desc:评论id * @param name:content type:string default:-- desc:内容 * @return name:name type:string default:-- desc:会员名称 * @return name:headimg type:string default:-- desc:会员头像 * @return name:content type:string default:-- desc:内容 */ public function secondCommend() { $comment = ArticleComment::where('id',input('post.id'))->find()->toArray(); $user_info = $this->userInfo('name'); UserMessage:: sendUserMessage($comment['user_id'],'article',3,0,$this->user_id,$comment['id'],$user_info['name'].'回复了您的评论'); $send_user = ArticleItem::where('id',$comment['item_id'])->value('user_id'); if($send_user) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$comment['item_id'],$user_info['name'].'评论了您的图文'); unset($comment['id']); unset($comment['create_at']); $comment['pid'] = input('post.id'); $comment['user_id'] = $this->user_id; $comment['content'] = input('post.content'); $comment['lev']++; if(!$comment['source_id']) $comment['source_id'] = input('post.id'); $res = ArticleComment::create($comment); $detail = ArticleComment::where('c.id',$res->id) ->alias('c') ->field('c.id,c.content,c.create_at,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->find()->toArray(); $this->success('评论成功',['detail'=>$detail]); } /** * @title 评论点赞||取消点赞 * @desc 评论 * @author qc * @method POST * @url /api/Article/commentTags * @header name:Authorization require:1 desc:Token * @param name:comment_id type:int default:1 desc:评论记录id * @return name:tags type:int default:1 desc:0取消成功,1点赞成功 */ public function commentTags() { $comment_id = input('post.comment_id'); $ret_val = 0; $check_tags = ArticleCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$comment_id])->value('id'); if($check_tags) { ArticleCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$comment_id])->delete(); }else{ Data::save('ArticleCommentLike', ['user_id'=>$this->user_id,'like_id'=>$comment_id,],'user_id', ['user_id'=>$this->user_id,'like_id'=>$comment_id]); $ret_val = 1; } $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]); } /** * @title 图文收藏||取消收藏 * @desc 用户收藏 * @author qc * @method POST * @url /api/Article/articleCollect * @header name:Authorization require:1 desc:Token * @param name:article_id type:int require:1 default:-- desc:记录id[图文id] * @param name:item_id type:int default:1 desc:item_id * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏) */ public function articleCollect() { $coll_type = input('post.coll_type',3); $coll_id = input('post.article_id',0); $item_id = input('post.item_id',0); $collect_check = UserCollect::checkCollectByType($this->user_id,$coll_type,$coll_id,$item_id); if($collect_check) { UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$coll_id,'children_id'=>$item_id])->delete(); $this->success('取消收藏成功',['status'=>0]); }else{ Data::save('UserCollect', [ 'user_id'=>$this->user_id, 'coll_type'=>$coll_type, 'coll_id'=>$coll_id, 'children_id'=>$item_id, 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$coll_id,'children_id'=>$item_id]); $this->success('收藏成功',['status'=>1]); } } /** * @title 用户提交或修改图文【个人】 * @desc 用户提交或修改图文【个人】 * @author qc * @method POST * @url /api/Article/userReferArticle * @header name:Authorization require:1 desc:Token * @param name:id type:int default:-- desc:id(修改时必传) * @param name:title type:string default:-- desc:标题 * @param name:images type:string default:-- desc:图片(多张用|隔开) * @param name:desc type:string default:-- desc:简介 * @param name:label type:string default:-- desc:图文标签 * @param name:document type:string default:-- desc:文件路径【单文件】 */ public function userReferArticle() { $id = input('post.id',0); $title = input('post.title'); $desc = input('post.desc'); $images = input('post.images'); $label = input('post.label'); $document = input('post.document'); //if(!$images) $this->error('请上传图文'); if($id){ $check_status = UserArticle::where('id',$id)->value('status'); if($check_status == 1) $this->error('已审核通过,不允许修改'); } $data = [ 'title' => $title, 'user_id' => $this->user_id, 'desc' => $desc, 'images' => $images, 'label' => $label, 'document' => $document, 'cover' => $images ? explode('|',$images)[0] : '', 'status' => 0, 'remark' => '', ]; if($id) $data['id'] = $id; if($id){ UserArticle::where('id',$id)->update($data); }else{ $res= UserArticle::create($data) ; } UserMessage::sendUserMessage($this->user_id,'article',1,0,0,$id ? $id:$res->id); $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]); } /** * @title 获取我的图文列表【个人--我的发布列表】 * @desc 获取我的图文列表【个人】 * @author qc * @method GET * @url /api/Article/getMyArticleList * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:desc type:string default:-- desc:简介 * @return name:images type:string default:-- desc:图文【多张|隔开】 * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过 * @return name:remark type:string default:-- desc:审核备注 */ public function getMyArticleList() { $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['user_id','=',$this->user_id]; $title = input('get.title'); if($title) $sel_where[] = ['title|label','like','%'.$title.'%']; $list = UserArticle::where($sel_where) ->field('id,title,desc,images,status,remark') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 获取我的图文详情【个人】 * @desc 获取我的图文列表【个人】 * @author qc * @method GET * @url /api/Article/getUserArticleDetail * @header name:Authorization require:1 desc:Token * @param name:id type:string default:-- desc:记录id * @return name:title type:string default:-- desc:标题 * @return name:desc type:string default:-- desc:简介 * @return name:images type:string default:-- desc:图文[多张|隔开] * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过 * @return name:remark type:string default:-- desc:审核备注 * @return name:label type:string default:-- desc:标签 * @return name:document type:string default:-- desc:文件路径 */ public function getUserArticleDetail() { $detail =UserArticle::where('id',input('get.id'))->field('id,title,desc,images,status,remark,label,document')->find(); if(!$detail) $this->error('图文有误'); $this->success('ok',['detail'=>$detail->toArray()]); } /** * @title 用户删除图文记录【个人】 * @desc 用户删除图文记录【个人】 * @author qc * @method POST * @url /api/Article/delUserArticle * @header name:Authorization require:1 desc:Token * @param name:id type:int default:-- desc:id */ public function delUserArticle() { UserArticle::where(['user_id'=>$this->user_id,'id'=>input('post.id')])->delete(); $this->success('删除成功'); } /** * @title 以下接口学习服务模块的 * @desc * @author qc * @method * @url /api/Article/learn() */ public function learn(){} /** * @title 图文学习历史 * @desc 图文学习历史 * @author qc * @method GET * @url /api/Article/getLearnHistory * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:time type:string default:-- desc:时间 */ public function getLearnHistory() { $sel_where = []; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.type','=',3]; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $list = UserTrack::where($sel_where) ->alias('t') ->field('t.id,t.update_int,t.first_id article_id,t.second_id item_id,i.title,i.cover') ->leftJoin('ArticleItem i','t.second_id = i.id') ->order('update_int desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['time'] = date("Y-m-d H:i:s",$v['update_int']); } $this->success('ok',['list'=>$list]); } /** * @title 图文收藏记录 * @desc 图文收藏记录 * @author qc * @method GET * @url /api/Article/getArticleCollect * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 */ public function getArticleCollect() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.coll_type','=',3]; $list = UserCollect::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.coll_id article_id,t.children_id item_id,i.title,i.cover') ->leftJoin('ArticleItem i','t.children_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 我的评论【学习服务--我评论过的图文】 * @desc 我的评论 * @author qc * @method GET * @url /api/Article/getCommentArticle * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名【用户自己的】 * @return name:headimg type:string default:-- desc:用户头像【用户自己的】 */ public function getCommentArticle() { $user_info = $this->userInfo(); $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['t.lev','=',1]; $list = ArticleComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.article_id,t.item_id,t.lev,t.content,i.title,i.cover') ->leftJoin('ArticleItem i','t.item_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['user_name'] = $user_info['name']; $v['headimg'] = $user_info['headimg']; } $this->success('ok',['list'=>$list]); } /** * @title 评论我的【学习服务--评论我的】 * @desc 评论我的 * @author qc * @method GET * @url /api/Article/commentMyArticle * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名 * @return name:headimg type:string default:-- desc:用户头像 */ public function commentMyArticle() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['i.user_id','=',$this->user_id]; $list = ArticleComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.article_id,t.item_id,t.lev,t.content,i.title,i.cover,u.name user_name,u.headimg') ->leftJoin('ArticleItem i','t.item_id = i.id') ->leftJoin('store_member u','t.user_id = u.id') ->order('t.id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 已购图文列表 * @desc 已购图文列表 * @author qc * @method GET * @url /api/Article/getPurchaseArticle * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 */ public function getPurchaseArticle() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.type','=',3]; $sel_where[] = ['t.end_int','>',time()]; $list = UserLearn::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.first_id article_id,t.second_id item_id,i.title,i.cover') ->leftJoin('ArticleItem i','t.second_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 我的回复【我的回复--我回复过的评论】 * @desc 我的评论 * @author qc * @method GET * @url /api/Article/getReplyArticle * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名【用户自己的】 * @return name:headimg type:string default:-- desc:用户头像【用户自己的】 * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】 * @return name:parent_comment.content type:string default:-- desc:内容 * @return name:parent_comment.name type:string default:-- desc:会员名称 * @return name:parent_comment.title type:string default:-- desc:图文标题 * @return name:parent_comment.article_id type:string default:-- desc:文章id * @return name:parent_comment.item_id type:string default:-- desc:item_id */ public function getReplyArticle() { $user_info = $this->userInfo(); $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['t.lev','=',2]; $list = ArticleComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.lev,t.content,i.title,t.pid') ->leftJoin('ArticleItem i','t.item_id = i.id') ->order('t.id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['user_name'] = $user_info['name']; $v['headimg'] = $user_info['headimg']; $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]]) ->field('t.id,t.article_id,t.item_id,t.content,i.title,i.cover,t.pid,u.name') ->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id') ->leftJoin('store_member u','t.user_id = u.id') ->find()->toArray(); $v['parent_comment'] = $parent_comment; } $this->success('ok',['list'=>$list]); } /** * @title 回复我的【回复我的--回复过我的评论】 * @desc 回复我的 * @author qc * @method GET * @url /api/Article/getReplyComment * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名【其他会员】 * @return name:headimg type:string default:-- desc:用户头【其他会员】 * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】 * @return name:parent_comment.content type:string default:-- desc:内容 * @return name:parent_comment.name type:string default:-- desc:会员名称 * @return name:parent_comment.title type:string default:-- desc:图文标题 * @return name:parent_comment.article_id type:string default:-- desc:文章id * @return name:parent_comment.item_id type:string default:-- desc:item_id */ public function getReplyComment() { $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id'); if(empty($all_comment)) $this->success('ok',['list'=>null]); $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['t.lev','=',2]; $sel_where[] = ['t.user_id','<>',$this->user_id]; $sel_where[] = ['t.pid','in',implode(',',$all_comment)]; $list = ArticleComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg') ->leftJoin('store_member u','t.user_id = u.id') ->leftJoin('ArticleItem i','t.item_id = i.id') ->order('t.id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]]) ->field('t.id,t.article_id,t.item_id,t.content,i.title,i.cover,t.pid,u.name') ->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id') ->leftJoin('store_member u','t.user_id = u.id') ->find()->toArray(); $v['parent_comment'] = $parent_comment; } $this->success('ok',['list'=>$list]); } /** * @title 图文点赞列表【我的点赞】 * @desc 图文点赞列表 * @author qc * @method GET * @url /api/Article/getTagsArticle * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:article_id type:string default:-- desc:文章id * @return name:item_id type:string default:-- desc:item_id * @return name:cover type:string default:-- desc:封面 * @return name:is_vip type:int default:-- desc:是否vip[0否1是] * @return name:create_at type:string default:-- desc:时间 * @return name:read_num type:int default:-- desc:阅读量 * @return name:images_arr type:array default:-- desc:图片 */ public function getTagsArticle() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $list = ArticleLike::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.article_id,t.item_id,i.title,i.cover,i.is_vip,images,i.read_num') ->leftJoin('ArticleItem i','t.item_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null; } $this->success('ok',['list'=>$list]); } }