123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715 |
- <?php
- namespace app\api\controller;
- use app\common\model\PressComment;
- use app\common\model\PlatformLike;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserMessage;
- use app\common\model\UserReport;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use library\tools\Data;
- /**
- * @title 新闻
- * @controller Press
- * @group base
- */
- class Press extends Base
- {
- // 需要登录的
- protected $need_login = ['pressCollect','pressTransmit','pressRead','PressTags','pressComment','pressCommend','delComment'];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- }
- /**
- * @title 新闻接口说明
- * @desc 新闻接口说明
- * @author qc
- * @url /api/Press/classIntro
- * @method GET
- * @return name:1 type:string default:-- desc:该模块没有视频!!
- */
- public function classIntro(){}
- /**
- * @title 获取新闻列表
- * @desc 获取新闻列表
- * @author qc
- * @method GET
- * @url /api/Press/getPressList
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
- * @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:images type:string default:-- desc:图片多张|隔开
- * @return name:images_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:read_num type:int default:-- desc:阅读
- * @return name:is_collect type:int default:-- desc:是否收藏
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:praise_num type:int default:-- desc:点赞量
- * @return name:is_praise type:int default:-- desc:是否点赞
- * @return name:comment_num type:int default:-- desc:评论量
- */
- public function getPressList(){
- $title = input('get.title');
- $sort_type = input('get.sort_type',1);
- 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,4);
- $list = \app\common\model\Press::where(['is_deleted'=>0])
- ->field('id,images,title,content,read_num,create_at,transmit_num')
- ->when($title,function ($query)use($title){
- if($title) $query->where('title|label','like','%'.$title.'%');
- })->order($order)->limit($this->off_set,$this->page_num)->select()->toArray();
- foreach ($list as &$v) {
- $v['comment_num'] = PressComment::where(['first_id'=>$v['id'],'type'=>1,'is_deleted'=>0])->count();
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,4,$v['id']);
- $v['collect_num'] = UserCollect::getCollectNum(4,$v['id']);
- $v['is_praise'] = PlatformLike::checkTags($this->user_id,$v['id'],1);
- $v['praise_num'] = PlatformLike::getPraiseNum($v['id'],1);
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 获取新闻详情
- * @desc 获取新闻详情
- * @author qc
- * @method GET
- * @url /api/Press/getPressDetail
- * @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:images type:string default:-- desc:图片多张|隔开
- * @return name:images_arr type:array default:-- desc:图片多张[数组]
- * @return name:content type:string default:-- desc:详情
- * @return name:create_at type:string default:-- desc:时间
- * @return name:read_num type:int default:-- desc:阅读
- * @return name:is_collect type:int default:-- desc:是否收藏
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:praise_num type:int default:-- desc:点赞量
- * @return name:is_praise type:int default:-- desc:是否点赞
- * @return name:comment_num type:int default:-- desc:评论量
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- */
- public function getPressDetail()
- {
- $sel_where[] = ['id','=',input('get.id')];
- $detail = \app\common\model\Press::field('id,images,title,content,read_num,create_at,transmit_num,user_id')->where($sel_where)->find()->toArray();
- $detail['comment_num'] = PressComment::where(['first_id'=>$detail['id'],'type'=>1,'is_deleted'=>0])->count();
- $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,4,$detail['id']);
- $detail['collect_num'] = UserCollect::getCollectNum(4,$detail['id']);
- $detail['is_praise'] = PlatformLike::checkTags($this->user_id,$detail['id'],1);
- $detail['praise_num'] = PlatformLike::getPraiseNum($detail['id'],1);
- $app_name = sysconf('app_name');
- $app_logo = sysconf('app_logo');
- if(!$detail['user_id']){
- $detail['app_name'] = $app_name;
- $detail['app_logo'] = $app_logo;
- }else{
- $user_info = User::where('id',$detail['user_id'])->field('name,headimg')->find();
- $detail['app_name'] = $user_info ? $user_info->name : '';
- $detail['app_logo'] = $user_info ? $user_info->headimg : '';
- }
- UserTrack::crateTrack($this->user_id,4,input('get.id'),0);
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 获取新闻评论列表
- * @desc 获取新闻评论列表
- * @author qc
- * @method GET
- * @url /api/Press/getPressCommentList
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:新闻id
- * @param name:sort_type type:int default:1 desc:排序规则1时间2热点
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num 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:total_num type:int default:-- desc:总评论数(仅一级)
- */
- public function getPressCommentList()
- {
- $where = [];
- $where[] = ['c.first_id','=',input('get.id')];
- $where[] = ['c.is_deleted','=',0];
- $where[] = ['c.type','=',1];
- $user_id = $this->user_id;
- $sort_type= input('sort_type',1);
- switch ($sort_type) {
- case 1:
- $order = ['c.id'=>'desc'];
- break;
- default:
- $order = ['c.like_times'=>'desc'];
- break;
- }
- $list =PressComment::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 = PressComment::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 ? $children : null;
- $val['like_num'] = PlatformLike::getPraiseNum($val['id'],2);
- $val['is_like'] = PlatformLike::checkTags($user_id,$val['id'],2);
- $parent = PressComment::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;
- });
- $total_num = PressComment::where($where)->alias('c')->count();
- $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
- }
- /**
- * @title 删除评论
- * @desc 删除评论
- * @author qc
- * @method POST
- * @url /api/Press/delComment
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:评论id
- */
- public function delComment(){
- PressComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
- $this->success('删除成功');
- }
-
- /**
- * @title 以下接口调用验证登录【需要header传Authorization】
- * @desc 以下接口调用验证登录
- * @author qc
- * @method
- * @url /api/Press/needLogin()
- */
- public function needLogin(){}
- /**
- * @title 收藏||取消收藏
- * @desc 用户收藏
- * @author qc
- * @method POST
- * @url /api/Press/pressCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int require:1 default:-- desc:新闻id
- * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function pressCollect(){
- $coll_status = UserCollect::plateCollect($this->user_id,4,input('post.id',0));
- $coll_status ? $this->success('收藏成功',['status'=>1]) : $this->success('取消收藏成功',['status'=>0]);
- }
- /**
- * @title 新闻转发(转发数量统计)
- * @desc 转发成功后调用
- * @author qc
- * @method POST
- * @url /api/Press/pressTransmit
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:新闻id
- */
- public function pressTransmit()
- {
- $press_id = input('post.id',0);
- \app\common\model\Press::where('id',$press_id)->setInc('transmit_num');
- $this->success('ok');
- }
- /**
- * @title 新闻举报
- * @desc 新闻举报
- * @author qc
- * @url /api/Press/pressReport
- * @method POST
- * @header name:Authorization require:1 desc:Token
- * @param name:report_id type:int default:-- desc:举报内容的id
- * @param name:case_ids type:string default:-- desc:举报类目id串(逗号隔开)
- */
- public function pressReport()
- {
- $report_id= input('post.report_id');
- $case_ids= input('post.case_ids');
- if(!$report_id) $this->error('请现在举报内容');
- if(!$case_ids) $this->error('请选择举报原因');
- UserReport::report($this->user_id,7,$report_id,$case_ids);
- $this->success('举报成功');
- }
- /**
- * @title 新闻阅读(阅读数量统计)
- * @desc 新闻阅读
- * @author qc
- * @method POST
- * @url /api/Press/pressRead
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:-- desc:新闻id
- */
- public function pressRead()
- {
- $press_id = input('post.id',0);
- \app\common\model\Press::where('id',$press_id)->setInc('read_num');
- $this->success('ok');
- }
- /**
- * @title 新闻点赞||取消点赞
- * @desc 点赞||取消点赞
- * @author qc
- * @method POST
- * @url /api/Press/PressTags
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:新闻id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function pressTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),1);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 新闻评论点赞||取消点赞
- * @desc 新闻评论点赞
- * @author qc
- * @method POST
- * @url /api/Press/pressCommentTags
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:1 desc:评论id
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function pressCommentTags()
- {
- $ret_val = PlatformLike::userTags($this->user_id,input('post.id'),2);
- $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
- }
- /**
- * @title 新闻评论
- * @desc 新闻评论
- * @author qc
- * @method POST
- * @url /api/Press/pressComment
- * @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:内容
- * @return name:create_at type:string default:-- desc:时间
- */
- public function pressComment()
- {
- $id = input('post.id');
- $content = input('post.content',0);
- if(!$content) $this->error('请输入评论内容');
- $res = PressComment::create(['user_id'=>$this->user_id,'content'=>$content,'first_id'=>$id,'type'=>1]);
- $detail =PressComment::where('p.id',$res->id)
- ->alias('p')
- ->field('p.id,p.content,p.create_at,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = p.user_id')
- ->find()->toArray();
- $this->success('评论成功',['detail'=>$detail]);
- }
- /**
- * @title 新闻二级评论
- * @desc 新闻二级评论
- * @author qc
- * @method POST
- * @url /api/Press/pressSecondComment
- * @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 pressSecondComment()
- {
- $comment = PressComment::where('id',input('post.id'))->find()->toArray();
- $user_info = $this->userInfo('name');
- UserMessage:: sendUserMessage($comment['user_id'],'press',1,0,$this->user_id,$comment['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 = PressComment::create($comment);
- $detail = PressComment::where('p.id',$res->id)
- ->alias('p')
- ->field('p.id,p.content,p.create_at,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = p.user_id')
- ->find()->toArray();
- $this->success('评论成功',['detail'=>$detail]);
- }
- /**
- * @title 回复我的【回复我的--回复过我的评论】
- * @desc 回复我的
- * @author qc
- * @method GET
- * @url /api/Press/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:cover type:string default:-- desc:封面
- * @return name:iamges_arr type:array 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.press_id type:string default:-- desc:新闻id
- */
- public function getReplyComment()
- {
- $all_comment = PressComment::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 = PressComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.cover,i.images')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->leftJoin('Press i','t.first_id = i.id')
- ->order('t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
- $v['cover'] = $v['images_arr'] ? $v['images_arr'][0] : null;
- $parent_comment = PressComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.first_id press_id,t.content,i.title,i.cover,t.pid,u.name')
- ->alias('t')
- ->leftJoin('Press i','t.first_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/Press/commentMyPress
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:press_id type:string default:-- desc:新闻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 commentMyPress()
- {
- $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 = PressComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.first_id press_id,t.content,i.title,i.cover,u.name user_name,u.headimg')
- ->leftJoin('Press i','t.first_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/Press/getMyPressComment
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:press_id type:string default:-- desc:新闻id
- * @return name:cover type:string default:-- desc:封面
- * @return name:images_arr type:array 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 getMyPressComment()
- {
- $where = [];
- $where[] = ['t.is_deleted','=',0];
- $where[] = ['t.type','=',1];
- $where[] = ['t.user_id','=',$this->user_id];
- $list = PressComment::where($where)
- ->alias('t')
- ->field('t.id,t.create_at,t.first_id press_id,i.images,t.content,i.title,i.cover,u.name user_name,u.headimg')
- ->leftJoin('Press i','t.first_id = i.id')
- ->leftJoin('store_member u','u.id = t.user_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;
- $v['cover'] = $v['images_arr'] ? $v['images_arr'][0] : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的回复【我的回复--我回复过的评论】
- * @desc 我的评论
- * @author qc
- * @method GET
- * @url /api/Press/getReplyPress
- * @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:press_id type:int default:-- desc:新闻id
- * @return name:cover type:string default:-- desc:封面
- * @return name:images_arr type:array 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.press_id type:string default:-- desc:新闻id
- */
- public function getReplyPress()
- {
- $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 = PressComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.first_id press_id,t.lev,t.content,t.pid,i.title,i.cover,images')
- ->leftJoin('Press i','t.first_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'];
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
- $v['cover'] = $v['images_arr'] ? $v['images_arr'][0] : null;
- $parent_comment = PressComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.first_id press_id,t.content,i.title,i.cover,i.images,t.pid,u.name')
- ->alias('t')
- ->leftJoin('Press i','t.first_id = i.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $parent_comment['images_arr'] = $parent_comment['images'] ? explode('|',$parent_comment['images']) : null;
- $v['parent_comment'] = $parent_comment;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的收藏【新闻】
- * @desc 我的收藏
- * @author qc
- * @method GET
- * @url /api/Press/getPressCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:press_id type:string default:-- desc:新闻id
- * @return name:cover type:string default:-- desc:封面
- * @return name:create_at type:string default:-- desc:时间
- */
- public function getPressCollect()
- {
- $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','=',4];
- $list = UserCollect::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.coll_id press_id,i.title,i.cover,images')
- ->leftJoin('Press i','t.coll_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;
- $v['cover'] = $v['images_arr'] ? $v['images_arr'][0] : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的点赞列表【新闻】
- * @desc 我的点赞
- * @author qc
- * @method GET
- * @url /api/Press/getTagsPress
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:press_id type:string default:-- desc:新闻id
- * @return name:cover type:string default:-- desc:封面
- * @return name:create_at type:string default:-- desc:时间
- */
- public function getTagsPress()
- {
- $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','=',1];
- $list = PlatformLike::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.like_id press_id,i.title,i.cover,images')
- ->leftJoin('Press i','t.like_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;
- $v['cover'] = $v['images_arr'] ? $v['images_arr'][0] : null;
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @title 我的浏览历史【新闻】
- * @desc 我的浏览历史
- * @author qc
- * @method GET
- * @url /api/Press/getPressTrack
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:title type:string default:-- desc:标题
- * @return name:press_id type:string default:-- desc:新闻id
- * @return name:cover type:string default:-- desc:封面
- * @return name:create_at type:string default:-- desc:时间
- */
- public function getPressTrack()
- {
- $sel_where = [];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.type','=',4];
- $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 press_id,i.title,i.cover,i.images')
- ->leftJoin('Press i','t.first_id = i.id')
- ->order('update_int desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']) : null;
- $v['cover'] = $v['images_arr'] ? $v['images_arr'][0] : null;
- $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
- }
- $this->success('ok',['list'=>$list]);
- }
- }
|