123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983 |
- <?php
- namespace app\api\controller;
- use app\common\model\ArticleCate;
- use app\common\model\ArticleComment;
- use app\common\model\ArticleCommentLike;
- use app\common\model\ArticleIntro;
- use app\common\model\ArticleItem;
- use app\common\model\ArticleLike;
- use app\common\model\DatumUrl;
- use app\common\model\PlatformSwitch;
- use app\common\model\SeriesArticleCate;
- use app\common\model\TopSearch;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserArticle;
- use app\common\model\UserLearn;
- use app\common\model\UserLevelRank;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\UserTag;
- use app\common\model\UserTrack;
- use app\common\model\VideoUrl;
- use app\common\service\CheckPower;
- use app\common\service\UserSynth;
- use library\tools\Data;
- use think\Db;
- use think\db\Query;
- /**
- * @title 图文
- * @controller Article
- * @group base
- */
- class Article extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'articleTransmit',
- 'articleRead',
- 'articleTags',
- 'articleComment',
- 'delComment',
- 'secondCommend',
- 'commentTags',
- 'articleCollect',
- 'userReferArticle',
- 'getMyArticleList',
- 'getUserArticleDetail',
- 'delUserArticle',
- 'delComment',
- 'getLearnHistory',
- 'getArticleCollect',
- 'getCommentArticle',
- 'commentMyArticle',
- 'getPurchaseArticle',
- 'getReplyArticle',
- 'getReplyComment',
- 'getTagsArticle',
- 'getBoundList',
- 'getFollowUpList',
- 'getFollowUpMessage',
- 'getTagsComment',
- 'getMarkNum',
- 'unreadChange',
- 'batchesDel',
- 'getArticleDetail', //1.5新增
- 'getArticleDetail2', //1.5新增
- 'getArticleItemInfo' //1.5新增
- ];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- $this->source_type= $this->request->header('source-type',1);
- }
- /**
- * @title 图文接口说明
- * @desc 图文接口说明
- * @author qc
- * @url /api/Article/classIntro
- * @method GET
- * @return name:1 type:string default:-- desc:图片(images字段)多图片都用竖线(|)隔开,会员上传多张也用(|)隔开
- * @return name:2 type:string default:-- desc:cover字段值是images的第一个路径【非多张】
- * @return name:3 type:string default:-- desc:单一图文与系列图文区别,type值(1是单一,2是系列),数据:item_list二维数组数据数量不一样(单一的只有一个,系列的可以是多个)【可以将单一图文看做只有一条记录的系列图文!!!!】
- * @return name:4 type:string default:-- desc:单一图文详情的字段(cover,images,is_vip,title)与item_list数组的第一个同字段名的值相同
- * @return name:5 type:string default:-- desc:系列图文详情的字段(cover,images)与item_list的其中一个相同
- * @return name:6 type:string default:-- desc:关于是否的字段(0否,1是)
- * @return name:7 type:string default:-- desc:item_id是数组item_list下的id
- */
- public function classIntro(){}
- /**
- * @title 获取图文分类
- * @desc 获取图文分类
- * @author qc
- * @url /api/Article/getArticleCate
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:type type:int default:2 desc:类型2系列
- * @return name:id type:int default:-- desc:分类id
- * @return name:logo type:string default:-- desc:图标
- * @return name:title type:string default:0 desc:分类名称
- * @return name:children type:array default:0 desc:下级分类
- */
- public function getArticleCate()
- {
- $type = input('type',2);
- if($type == 1) {
- $list = ArticleCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc')->select()->toArray();
- }else{
- $list = SeriesArticleCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc')->select()->toArray();
- }
- $list = make_tree($list);
- foreach ($list as &$v) {
- if(empty($v['children']))$v['children'] = null;
- }
- $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:每页数
- * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
- * @return name:id type:string default:-- desc:图文item_id
- * @return name:title type:string default:-- desc:标题
- * @return name:create_at 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:发布者头像
- * @return name:author type:string default:-- desc:原创作者
- * @return name:content_type type:int default:1 desc:1富文本2pdf
- * @return name:pdf type:string default:-- desc:pdf文件路径
- * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
- * @return name:release_time type:string default:-- desc:上架时间
- * @return name:desc type:string default:-- desc:简介
- * @return name:like_num type:int default:-- desc:点赞量
- * @return name:is_like type:int default:-- desc:是否点赞
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:is_collect type:int default:-- desc:是否收藏
- */
- public function getRecommendList()
- {
- $user_id = $this->user_id ? $this->user_id : input('rand_user');
- if(!$user_id) $this->error('参数错误');
- $list = UserSynth::getRecommendList($user_id,'article',$this->page,$this->page_num);
- if($list['code'] != 200) $this->error($list['msg']);
- $this->success('ok',$list);
- $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.content_type,a.pdf,a.images,a.create_at,a.user_id,a.is_vip,a.read_num,a.article_id ,a.author,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_article_item';
- $order_by_two = 'a.read_num';
- $time_str = date("Y-m-d H:i:s");
- $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.release_time < '". $time_str ."' 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);
- $list = dispose_recommend($list);
- array_walk($list,function (&$v,$k){
- $v['read_num'] = numTransform($v['read_num']);
- $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
- $v['create_at'] = substr($v['create_at'],0,10);
- $v['is_release'] = UserLearn::checkRelease($this->user_id,3,$v['id']);
- });
- $sql2 = "SELECT count(a.id) num 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.release_time < '". $time_str ."' AND a.status =1 AND k.status = 1 AND k.is_deleted = 0 ";
- $total = Db::query($sql2);
- $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取图文列表(平台发布)
- * @desc 获取图文列表
- * @author qc
- * @method GET
- * @url /api/Article/getArticleList
- * @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:每页数
- * @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:recently_title 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:内容
- * @return name:item_list.app_name type:string default:-- desc:发布方名称
- * @return name:item_list.app_logo type:string default:-- desc:发布方头像
- * @return name:item_list.content_type type:int default:1 desc:1富文本2pdf
- * @return name:item_list.pdf type:string default:-- desc:pdf文件路径【加密】
- * @return name:item_list.pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
- */
- public function getArticleList()
- {
- $sel_where = [];
- $title = input('get.title');
- $type = input('get.type',2);
- $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','read_num'=>'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';
- $list = ArticleIntro::where($sel_where)->with('itemList2')
- ->limit($this->off_set,$this->page_num)
- ->where($where_str)
- ->order($order)
- ->select()->toArray();
- array_walk($list,function (&$v,$k){
- $v['item_list'] = $v['item_list2'];
- $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$v['id']);
- $v['recently_title'] = ArticleItem::where('id',$recently_id)->value('title');
- unset($v['item_list2']);
- $v['read_num']= array_sum(array_column($v['item_list'],'read_num'));
- $v['read_num'] = numTransform($v['read_num']);
- $v['cate'] = SeriesArticleCate::where('id',$v['second_classify'])->value('title');
- unset($v['content']);
- foreach ($v['item_list'] as &$iv) {
- //unset($iv['content']);
- if(in_array($this->source_type,[1])) unset($iv['pdf_clear']);
- $iv['read_num'] = numTransform($iv['read_num']);
- $article_auth = ArticleItem::getArticleAuth($iv['user_id'],APPNAME,APPLOGO);
- $iv['app_name'] = $article_auth['app_name'];
- $iv['app_logo'] = $article_auth['app_logo'];
- }
- });
- $total_num = ArticleIntro::where($sel_where) ->where($where_str)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取系列列表
- * @desc 获取系列列表
- * @author qc
- * @method GET
- * @url /api/Article/getSeriesList
- * @header name:Authorization require:1 desc:Token
- * @param name:first_classify type:int default:0 desc:一级分类
- * @param name:second_classify type:int default:0 desc:二级分类
- * @return name:second_classify type:int default:-- desc:二级分类
- * @return name:title type:int default:-- desc:二级分类名称
- * @return name:series_list type:array default:-- desc:系列列表
- * @return name:series_list.id type:string default:-- desc:系列id
- * @return name:series_list.title type:string default:-- desc:标题
- * @return name:series_list.cover type:string default:-- desc:封面
- * @return name:series_list.is_vip type:int default:-- desc:是否是vip(0否,1是)
- * @return name:series_list.is_over type:int default:-- desc:是否完结(0否,1是)
- */
- public function getSeriesList()
- {
- $type = input('get.type',2);
- $first_classify = input('get.first_classify');
- $second_classify = input('get.second_classify');
- $list = SeriesArticleCate::where(['is_deleted'=>0,'status'=>1])
- ->field('id second_classify,title')->where('pid',$first_classify)
- ->when($second_classify,function ($query)use ($second_classify){if($second_classify){$query->where('id',$second_classify);}})
- ->order('sort desc,id asc')->select()->toArray();
- foreach ($list as &$v) {
- $v['series_list'] = ArticleIntro::field('id,title,cover,is_vip,is_over,create_at')
- ->where('second_classify',$v['second_classify'])
- ->where('type',$type)
- ->where('status',1)
- ->where('is_deleted',0)
- ->where('item_num','>',0)
- ->limit($this->off_set,100)
- ->order('sort desc,id desc')->select()->toArray();
- }
- $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
- * @param name:sort_type type:int default:1 desc:排序1默认2时间升序3时间降序
- * @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:user_level type:int default:-- desc:会员等级id
- * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
- * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买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.switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @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.desc type:int default:-- desc:简介
- * @return name:item_list.desc_text 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】
- * @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】
- * @return name:item_list.datum_item type:int default:-- desc:资料详情id【url_arr.id】
- * @return name:item_list.goods_id type:int default:-- desc:供应商商品id
- * @return name:item_list.video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:item_list.datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
- *
- * @return name:item_list.author type:string default:-- desc:原创作者
- * @return name:item_list.content_type type:int default:1 desc:1富文本2pdf
- * @return name:item_list.pdf type:string default:-- desc:pdf文件路径【加密】
- * @return name:item_list.pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
- * @return name:item_list.is_recently type:int default:-- desc:是否最近观看【0否1是】
- * @return name:item_list.like_num type:int default:-- desc:点赞量
- * @return name:item_list.is_like type:int default:-- desc:是否点赞
- * @return name:item_list.app_name type:string default:-- desc:发布者
- * @return name:item_list.app_logo type:string default:-- desc:发布者头像
- * @return name:item_list.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- * @return name:item_list.release_time type:string default:-- desc:上架时间
- *
- *
- */
- public function getArticleDetail()
- {
- $form = input('get.from','H5');
- $sel_where = [];
- $sel_where[] = ['id','=',input('get.id')];
- $sort_type = input('get.sort_type',1);
- $is_release = UserLearn::checkRelease($this->user_id,3,input('get.id'));
- $detail = ArticleIntro::where($sel_where)->with(['itemList3'=>function($query)use($sort_type,$is_release){
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'asc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- //->force('item')
- return $is_release ? $query->field('id,article_id,create_at,is_vip,read_num,title,sort,user_id,status,release_time')->order($order) : $query->field('id,article_id,create_at,is_vip,read_num,title,sort,user_id,status,release_time')->where('status',1)->order($order);
- }])->find()->toArray();
- $detail['item_list'] = $detail['item_list3'];
- unset($detail['item_list3']);
- $detail['is_release'] = $is_release;
- if($is_release && $detail['is_deleted'] )$this->error('该图文已下线');
- if(!$detail['is_release'] && ($detail['is_deleted'] == 1 || $detail['status'] == 0))$this->error('该图文已下线');
- if(in_array($this->source_type,[1])) $detail['content'] = openssl_encrypt($detail['content'],'DES-ECB',123456,0);
- $detail['read_num'] = array_sum(array_column($detail['item_list'],'read_num'));
- $detail['read_num'] = numTransform($detail['read_num']);
- $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],3);
- $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$detail['id']);
- $level_id = UserLevelRank::getUserVip($this->user_id);
- $detail['user_level'] = $level_id;
- foreach ($detail['item_list'] as &$dv) {
- if(in_array($this->source_type,[1])) unset($dv['pdf_clear']);
- if(in_array($this->source_type,[1])) $dv['content'] = openssl_encrypt($dv['content'],'DES-ECB',123456,0);
- $dv['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$dv['id'],8);
- $dv['comment_num'] = ArticleComment::getArticleCommentNum($dv['id']);
- $dv['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
- $dv['collect_num'] = numTransform($dv['collect_num']);
- $dv['transmit_num'] = numTransform($dv['transmit_num']);
- $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['id'],$dv['id']);
- $dv['read_num'] = numTransform($dv['read_num']);
- $dv['is_recently'] = $dv['id'] == $recently_id ? 1 : 0;
- $dv['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
- $dv['like_num'] = ArticleLike::where(['article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
- $article_auth = ArticleItem::getArticleAuth($dv['user_id'],APPNAME,APPLOGO);
- $dv['app_name'] = $article_auth['app_name'];
- $dv['app_logo'] = $article_auth['app_logo'];
- $dv['video_jump'] = VideoUrl::checkVip($dv['video_item'],$this->user_id);
- $dv['datum_jump'] = DatumUrl::checkVip($dv['datum_item'],$this->user_id);
- }
- if($this->user_id){
- $General = new General();
- $General->label($detail['label']);
- }
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 获取图文系列详情(【系列的合集列表,不含富文本】)
- * @desc 获取图文系列详情
- * @author qc
- * @method GET
- * @url /api/Article/getArticleDetail2
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:int default:0 desc:图文id
- * @param name:sort_type type:int default:1 desc:排序1默认2时间升序3时间降序
- * @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:user_level type:int default:-- desc:会员等级id
- * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
- * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买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.switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @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.desc type:int default:-- desc:简介
- * @return name:item_list.desc_text 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】
- * @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】
- * @return name:item_list.datum_item type:int default:-- desc:资料详情id【url_arr.id】
- * @return name:item_list.goods_id type:int default:-- desc:供应商商品id
- * @return name:item_list.video_jump type:int default:-- desc:关联视频是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:item_list.datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:item_list.release_time type:string default:-- desc:上架时间
- * @return name:item_list.author type:string default:-- desc:原创作者
- * @return name:item_list.content_type type:int default:1 desc:1富文本2pdf
- * @return name:item_list.pdf type:string default:-- desc:pdf文件路径【加密】
- * @return name:item_list.pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
- * @return name:item_list.is_recently type:int default:-- desc:是否最近观看【0否1是】
- * @return name:item_list.like_num type:int default:-- desc:点赞量
- * @return name:item_list.is_like type:int default:-- desc:是否点赞
- * @return name:item_list.app_name type:string default:-- desc:发布者
- * @return name:item_list.app_logo type:string default:-- desc:发布者头像
- * @return name:item_list.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- */
- public function getArticleDetail2()
- {
- $form = input('get.from','H5');
- $sel_where = [];
- $sel_where[] = ['id','=',input('get.id')];
- $sort_type = input('get.sort_type',1);
- $is_release = UserLearn::checkRelease($this->user_id,3,input('get.id'));
- $detail = ArticleIntro::where($sel_where)->with(['itemList2'=>function($query)use($sort_type,$is_release){
- switch ($sort_type) {
- case 1:
- $order = ['sort'=>'desc','id'=>'asc'];
- break;
- case 2:
- $order = ['id'=>'asc','sort'=>'desc'];
- break;
- case 3:
- $order = ['id'=>'desc','sort'=>'desc'];
- break;
- }
- return $is_release ? $query->order($order) : $query->where('status',1)->order($order);
- }])->find()->toArray();
- $detail['item_list'] = $detail['item_list2'];
- unset($detail['item_list2']);
- $detail['is_release'] = $is_release;
- if($is_release && $detail['is_deleted'] )$this->error('该图文已下线');
- if(!$detail['is_release'] && ($detail['is_deleted'] == 1 || $detail['status'] == 0))$this->error('该图文已下线');
- $detail['read_num'] = array_sum(array_column($detail['item_list'],'read_num'));
- $detail['read_num'] = numTransform($detail['read_num']);
- $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],3);
- $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$detail['id']);
- $level_id = UserLevelRank::getUserVip($this->user_id);
- $detail['user_level'] = $level_id;
- foreach ($detail['item_list'] as &$dv) {
- if(in_array($this->source_type,[1])) unset($dv['pdf_clear']);
- $dv['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$dv['id'],8);
- $dv['comment_num'] = ArticleComment::getArticleCommentNum($dv['id']);
- $dv['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
- $dv['collect_num'] = numTransform($dv['collect_num']);
- $dv['transmit_num'] = numTransform($dv['transmit_num']);
- $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['id'],$dv['id']);
- $dv['read_num'] = numTransform($dv['read_num']);
- $dv['is_recently'] = $dv['id'] == $recently_id ? 1 : 0;
- $dv['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
- $dv['like_num'] = ArticleLike::where(['article_id'=>$dv['article_id'],'item_id'=>$dv['id']])->count();
- $article_auth = ArticleItem::getArticleAuth($dv['user_id'],APPNAME,APPLOGO);
- $dv['app_name'] = $article_auth['app_name'];
- $dv['app_logo'] = $article_auth['app_logo'];
- $dv['video_jump'] = VideoUrl::checkVip($dv['video_item'],$this->user_id);
- $dv['datum_jump'] = DatumUrl::checkVip($dv['datum_item'],$this->user_id);
- }
- if($this->user_id){
- $General = new General();
- $General->label($detail['label']);
- }
- $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:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
- * @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:desc type:int default:-- desc:简介
- * @return name:desc_text 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】
- * @return name:author type:string default:-- desc:原创作者
- * @return name:content_type type:int default:1 desc:1富文本2pdf
- * @return name:pdf type:string default:-- desc:pdf文件路径[加密]
- * @return name:pdf_clear type:string default:-- desc:pdf文件路径【未加密H5未返回】
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- * @return name:follow_switch type:int default:-- desc:订阅开关状态【0关闭1开启】
- * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @return name:article_title type:string default:-- desc:系列标题
- * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- * @return name:release_time type:string default:-- desc:上架时间
- */
- public function getArticleItemInfo()
- {
- $item_id = input('get.item_id');
- $form = input('get.from','H5');
- $detail = ArticleItem::field('a.*,t.is_deleted td,t.status tus,t.title article_title')->where('a.id',$item_id)->alias('a')->leftJoin('ArticleIntro t','t.id= a.article_id')->find()->toArray();
- $is_release = UserLearn::checkRelease($this->user_id,3,$detail['article_id']);
- if($is_release && ($detail['is_deleted'] == 1 || $detail['td'] == 1))$this->error('图文已下架');
- if(!$is_release && ($detail['is_deleted'] == 1 || $detail['status'] == 0 || $detail['td'] == 1 || $detail['tus']==0) ) $this->error('图文已下架');
- $detail['series_title'] = $detail['article_title'];
- if(in_array($this->source_type,[1])) unset($detail['pdf_clear']);
- $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();
- if(in_array($this->source_type,[1])) $detail['content'] = openssl_encrypt($detail['content'],'DES-ECB',123456,0);
- $detail['like_num'] = ArticleLike::where(['article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count();
- $detail['like_num'] = numTransform($detail['like_num']);
- $detail['read_num'] = numTransform($detail['read_num']);
- $detail['comment_num'] =ArticleComment::getArticleCommentNum($detail['id']);
- $detail['collect_num'] = numTransform($detail['collect_num']);
- $detail['transmit_num'] = numTransform($detail['transmit_num']);
- $detail['is_release'] = $is_release;
- UserTrack::crateTrack($this->user_id,3,$detail['article_id'],$item_id);
- $article_auth = ArticleItem::getArticleAuth($detail['user_id'],APPNAME,APPLOGO);
- $detail['app_name'] = $article_auth['app_name'];
- $detail['app_logo'] = $article_auth['app_logo'];
- $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['article_id'],3);
- $detail['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],8);
- //var_dump($this->user_id,3,$detail['article_id'],$item_id);
- ArticleItem::where('id',$item_id)->setInc('read_num');
- ArticleIntro::where('id',$detail['article_id'])->setInc('read_num');
- if($this->user_id){
- TopSearch::seIncHotNum($item_id,$this->request->controller());
- }
- $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最热
- * @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:is_deleted type:int default:-- desc:是否删除(大于0为删除状态)
- * @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:is_top 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 = ['is_top'=>'desc','id'=>'desc'];
- break;
- default:
- $order = ['is_top'=>'desc','like_times'=>'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']])
- ->alias('c')->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('c.is_top desc,c.id asc')
- ->select()->toArray();
- $val['children'] = $children;
- $val['like_num'] = ArticleCommentLike::where('like_id',$val['id'])->count();
- $val['like_num'] = numTransform($val['like_num']);
- $val['is_like'] = ArticleCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id])->count();
- $parent = ArticleComment::where(['c.id'=>$val['pid']])
- ->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['parent_comment'] = $val['parent'] ;
- $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0;
- });
- $total_num = ArticleComment::where($where)->alias('c') ->leftJoin('store_member u','u.id = c.user_id')->count();
- $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_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);
- $article_id = ArticleItem::where('id',$item_id)->value('article_id');
- ArticleItem::where('id',$item_id)->setInc('read_num');
- ArticleIntro::where('id',$article_id)->setInc('read_num');
- if($this->user_id){
- TopSearch::seIncHotNum($item_id,$this->request->controller());
- }
- $this->success('ok');
- }
- /**
- * @title 图文点赞||取消点赞
- * @desc 点赞||取消点赞
- * @author qc
- * @method POST
- * @url /api/Article/articleTags
- * @header name:Authorization require:1 desc:Token
- * @param name:item_id type:int default:1 desc:item_id(多个逗号隔开)
- * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
- */
- public function articleTags()
- {
- $ids = input('post.item_id');
- $ret_val = 0;
- foreach (explode(',',$ids) as $item_id) {
- $article_id = ArticleItem::where('id',$item_id)->value('article_id');
- $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{
- $p_user_id = ArticleItem::where('id',$item_id)->value('user_id');
- $is_read = $p_user_id == $this->user_id ? 1 : 0;
- Data::save('ArticleLike',
- ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id,'is_read'=>$is_read],'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('请输入评论内容');
- $comment_switch = ArticleItem::where('id',$item_id)->value('comment_switch');
- $send_user = ArticleItem::where('id',$item_id)->value('user_id');
- if(!$comment_switch) $this->error('评论功能已关闭');
- $res = ArticleComment::create([
- 'user_id'=>$this->user_id,
- 'content'=>$content
- ,'article_id'=>$article_id,
- 'item_id'=>$item_id,
- 'is_read' => $send_user == $this->user_id ? 1 : 0,
- 'source_read' => $send_user == $this->user_id ? 1 : 0,
- ]);
- $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();
- $user_info = $this->userInfo('name');
- if($send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$item_id,$content,$item_id,$article_id);
- $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();
- $content = input('post.content');
- $user_info = $this->userInfo('name');
- if($comment['user_id'] != $this->user_id)UserMessage:: sendUserMessage($comment['user_id'],'article',3,0,$this->user_id,$comment['id'],$content,$comment['item_id'],$comment['article_id']);
- $send_user = ArticleItem::where('id',$comment['item_id'])->value('user_id');
- $comment_switch = ArticleItem::where('id',$comment['item_id'])->value('comment_switch');
- if(!$comment_switch) $this->error('评论功能已关闭');
- //if($send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$comment['item_id'],$content,$comment['item_id'],$comment['article_id']);
- $to_user = $comment['user_id'];
- unset($comment['id']);
- unset($comment['create_at']);
- unset($comment['to_deleted']);
- unset($comment['is_top']);
- unset($comment['is_deleted']);
- $comment['pid'] = input('post.id');
- $comment['user_id'] = $this->user_id;
- $comment['content'] = $content;
- $comment['lev']++;
- $comment['is_read']= $this->user_id == $to_user ? 1 :0 ;
- $comment['source_read'] = $this->user_id == $send_user ? 1 :0 ;
- 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();
- // ArticleItem::where('id',$comment_id)->setDec('like_times');
- }else{
- $p_user_id = ArticleComment::where('id',$comment_id)->value('user_id');
- $is_read = $p_user_id == $this->user_id ? 1 : 0;
- Data::save('ArticleCommentLike',
- ['user_id'=>$this->user_id,'like_id'=>$comment_id,'is_read'=>$is_read],'user_id',
- ['user_id'=>$this->user_id,'like_id'=>$comment_id]);
- $ret_val = 1;
- // ArticleItem::where('id',$comment_id)->setInc('like_times');
- }
- $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
- * @param name:item_id type:int default:1 desc:item_id【详情的id】
- */
- 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:images_arr type:array default:-- desc:图片数组
- * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
- * @return name:remark type:string default:-- desc:审核备注
- * @return name:create_at type:string default:-- desc:时间
- * @return name:label_name type:array default:-- desc:标签
- * @return name:cover 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,create_at,label')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_map(function (&$v){
- $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')) :null;
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
- },$list);
- $total_num = UserArticle::where($sel_where)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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($this->user_id){
- $General = new General();
- $General->label($detail['label']);
- }
- 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:series_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:时间
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo 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,i.read_num,i.user_id,x.title series_title,x.is_vip')
- ->leftJoin('ArticleItem i','t.second_id = i.id')
- ->leftJoin('ArticleIntro x','t.first_id = x.id')
- ->order('update_int desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['read_num'] = numTransform($v['read_num']);
- $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- }
- $total_num = UserTrack::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.second_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:series_title type:string default:-- desc:系列标题
- * @return name:read_num type:int 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:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:desc type:string default:-- desc:简介
- * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:comment_num type:int default:-- desc:评论量
- * @return name:is_collect type:int default:-- desc:是否收藏
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:like_num type:string default:-- desc:点赞量
- * @return name:is_like type:string default:-- desc:是否点赞[0否1是]
- */
- 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,i.read_num,i.transmit_num,i.desc,x.title series_title,i.user_id')
- ->leftJoin('ArticleItem i','t.children_id = i.id')
- ->leftJoin('ArticleIntro x','t.coll_id = x.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['item_id'],8);
- $v['read_num'] = numTransform($v['read_num']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $v['transmit_num'] = numTransform($v['transmit_num']);
- $v['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$v['article_id'],'children_id'=>$v['item_id']])->count();
- $v['collect_num'] = numTransform($v['collect_num']);
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$v['article_id'],$v['item_id']);
- $v['like_num'] = ArticleLike::where(['article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
- $v['like_num'] = numTransform($v['like_num']);
- $v['comment_num'] = ArticleComment::getArticleCommentNum($v['item_id']);
- $v['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
- $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- });
- $total_num = UserCollect::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.children_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:series_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_top type:int default:-- desc:是否置顶(0否1是)
- * @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:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo 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|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.lev','=',1];
- $sel_where[] = ['t.pid','=',0];
- $list = ArticleComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.article_id,t.item_id,t.is_top,t.lev,t.content,i.title,i.cover,x.title series_title,i.user_id,i.read_num')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->leftJoin('ArticleIntro x','t.article_id = x.id')
- ->order('t.is_top desc,id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v)
- {
- $v['read_num'] = numTransform($v['read_num']);
- $v['user_name'] = $user_info['name'];
- $v['headimg'] = $user_info['headimg'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- }
- $total_num = ArticleComment::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:series_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_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @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:read_num type:int default:-- desc:阅读量
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- */
- public function commentMyArticle()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['i.user_id','=',$this->user_id];
- $sel_where[] = ['t.user_id','<>',$this->user_id];
- $sel_where[] = ['t.source_deleted','=',0];
- $sel_where[] = ['t.pid','=',0];
- $list = ArticleComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_read,t.is_top,t.create_at,i.read_num,t.article_id,t.item_id,t.lev,t.content,i.title,i.label,i.cover,u.name user_name,u.headimg,x.title series_title')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->leftJoin('ArticleIntro x','t.article_id = x.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->order('t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $user_info = $this->userInfo('name,headimg');
- array_walk($list,function (&$v)use ($user_info){
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $v['read_num'] = numTransform($v['read_num']);
- $v['app_name'] = $user_info['name'];
- $v['app_logo'] = $user_info['headimg'];
- });
- $total_num= ArticleComment::where($sel_where)->alias('t')->leftJoin('ArticleItem i','t.item_id = i.id')
- ->leftJoin('store_member u','t.user_id = u.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:时间
- * @return name:total_sequel type:int default:-- desc:期数
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:is_recently type:int default:-- desc:是否最近观看【0否1是】
- * @return name:recently_title 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()];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['a.is_deleted','=',0];
- $list = UserLearn::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.first_id article_id,t.second_id item_id,a.title,a.cover,a.total_sequel')
- ->leftJoin('ArticleIntro a','t.first_id = a.id')
- ->leftJoin('ArticleItem i','t.second_id = i.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['is_normal'] = 1;//CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$v['article_id']);
- $v['is_recently'] = $recently_id ? 1 : 0;
- $v['recently_title'] = ArticleItem::where('id',$recently_id)->value('title');
- });
- $total_num = UserLearn::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.second_id = i.id')
- ->leftJoin('ArticleIntro a','t.first_id = a.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:user_name type:string default:-- desc:用户名【用户自己的】
- * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @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.series_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
- * @return name:parent_comment.app_name type:string default:-- desc:发布方名称
- * @return name:parent_comment.app_logo type:string default:-- desc:发布方头像
- */
- public function getReplyArticle()
- {
- $user_info = $this->userInfo();
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','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.article_id,t.is_top,t.item_id,t.create_at,t.lev,t.content,i.title,t.pid,i.read_num')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->order('t.is_top desc,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['read_num'] = numTransform($v['read_num']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.article_id,t.is_top,t.item_id,t.content,i.title,i.user_id,i.cover,t.pid,u.name,x.title series_title')
- ->alias('t')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->leftJoin('ArticleIntro x','t.article_id = x.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $article_auth = ArticleItem::getArticleAuth($parent_comment['user_id'],APPNAME,APPLOGO);
- $parent_comment['app_name'] = $article_auth['app_name'];
- $parent_comment['app_logo'] = $article_auth['app_logo'];
- $parent_comment['read_num'] = numTransform($v['read_num']);
- $v['parent_comment'] = $parent_comment;
- }
- $total_num = ArticleComment::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:is_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_deleted type:int default:-- desc:0未删除
- * @return name:user_name type:string default:-- desc:用户名【其他会员】
- * @return name:headimg type:string default:-- desc:用户头【其他会员】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @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.series_title type:string default:-- desc:图文标题
- * @return name:parent_comment.read_num 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
- * @return name:parent_comment.is_deleted type:int default:-- desc:0未删除
- * @return name:parent_comment.app_name type:string default:-- desc:发布方名称
- * @return name:parent_comment.app_logo type:string default:-- desc:发布方头像
- */
- 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'=>[]]);
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.lev','>=',2];
- $sel_where[] = ['t.user_id','<>',$this->user_id];
- $sel_where[] = ['t.to_deleted','=',0];
- $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
- $list = ArticleComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_read,t.article_id,t.is_top,t.is_deleted,t.item_id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.user_id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->order('t.is_top desc,t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.article_id,t.is_top,t.item_id,t.content,i.title,i.cover,t.pid,u.name,t.is_deleted,i.user_id,i.read_num,x.title series_title')
- ->alias('t')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->leftJoin('ArticleIntro x','t.article_id = x.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $article_auth = ArticleItem::getArticleAuth($parent_comment['user_id'],APPNAME,APPLOGO);
- $parent_comment['read_num'] = numTransform($parent_comment['read_num']);
- $parent_comment['app_name'] = $article_auth['app_name'];
- $parent_comment['app_logo'] = $article_auth['app_logo'];
- $v['parent_comment'] = $parent_comment;
- }
- $total_num = ArticleComment::where($sel_where)->alias('t') ->leftJoin('store_member u','t.user_id = u.id')
- ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:series_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:like_num type:string default:-- desc:点赞量
- * @return name:is_like type:string default:-- desc:是否点赞[0否1是]
- * @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:图片
- * @return name:app_name type:string default:-- desc:发布方名称
- * @return name:app_logo type:string default:-- desc:发布方头像
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:desc type:string default:-- desc:简介
- * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @return name:transmit_num type:int default:-- desc:转发量
- * @return name:comment_num type:int default:-- desc:评论量
- * @return name:is_collect type:int default:-- desc:是否收藏
- * @return name:collect_num type:int 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,i.images,i.read_num,i.user_id,i.transmit_num,i.desc,x.title series_title')
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->leftJoin('ArticleIntro x','t.article_id = x.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['item_id'],8);
- $v['like_num'] = ArticleLike::where(['article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
- $v['like_num'] = numTransform($v['like_num']);
- $v['read_num'] = numTransform($v['read_num']);
- $v['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$v['article_id'],'item_id'=>$v['item_id']])->count();
- $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $article_auth = ArticleItem::getArticleAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$v['article_id'],$v['item_id']);
- $v['collect_num'] = UserCollect::getCollectNum(3,$v['article_id'],$v['item_id']);
- $v['comment_num'] = ArticleComment::getArticleCommentNum($v['item_id']);
- }
- $total_num = ArticleLike::where($sel_where)->alias('t') ->leftJoin('ArticleItem i','t.item_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 以下接口为二期需求
- * @desc 以下接口为二期需求
- * @author qc
- * @url /api/Article/secondPhase
- * @method
- * @return name:1 type:string default:-- desc:以下接口为二期需求
- */
- public function secondPhase(){}
- /**
- * @title 我的发布[审核成功]--后台图文绑定该会员
- * @desc 后台图文绑定该会员
- * @author qc
- * @method GET
- * @url /api/Article/getBoundList
- * @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:id type:string default:-- desc:记录id【item_id】
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:article_id type:string default:-- desc:图文id
- * @return name:cover type:string default:-- desc:封面
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getBoundList()
- {
- $sel_where = [];
- $title = input('get.title');
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.is_deleted','=',0];
- if($title) $sel_where[] = ['t.title|t.label','like','%'.$title.'%'];
- $list = ArticleItem::where($sel_where)
- ->alias('t')
- ->field('t.id,t.title,t.cover,t.read_num,t.label,t.is_vip,t.article_id,t.create_at,x.title series_title')
- ->leftJoin('ArticleIntro x','t.article_id = x.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['id'],$this->request->controller());;
- $v['label_name'] =$v['label'] ? explode(',',trim($v['label'],',')) :null;
- }
- $total_num = ArticleItem::where($sel_where)->alias('t')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的订阅列表--图文
- * @desc 我的订阅列表
- * @author qc
- * @method GET
- * @url /api/Article/getFollowUpList
- * @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:create_at type:string default:-- desc:追更设置时间
- * @return name:article_id type:int default:-- desc:图文id
- * @return name:total_sequel type:int default:-- desc:期数
- * @return name:title type:string default:-- desc:标题
- * @return name:is_recently type:int default:-- desc:是否最近观看【0否1是】
- * @return name:recently_title type:string default:-- desc:上次观看标题
- * @return name:recently_id type:int default:-- desc:上次观看记录id
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getFollowUpList()
- {
- $sel_where = [];
- $sel_where[] = ['p.user_id','=',$this->user_id];
- $sel_where[] = ['p.type','=',3];
- $sel_where[] = ['p.switch_value','=',1];
- $title = input('title');
- if($title) $sel_where[] = ['a.title','like','%'.$title.'%'];
- $field = 'p.id,p.switch_id as article_id,p.create_at,a.title,a.total_sequel,a.cover,a.status ,a.is_deleted';
- $list = PlatformSwitch::field($field)
- ->alias('p')
- ->leftJoin('ArticleIntro a','p.switch_id = a.id')
- ->where($sel_where)
- ->limit($this->off_set,$this->page_num)
- ->order('p.id desc')
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['is_normal'] = $v['status'] == 1 && $v['is_deleted'] == 0 ? 1 : 0;
- $recently_id = UserTrack::getRecentlyTrack($this->user_id,3,$v['article_id']);
- $v['is_recently'] = $recently_id ? 1 : 0;
- $v['recently_id'] = $recently_id ? $recently_id : 0;
- $v['recently_title'] = ArticleItem::where('id',$recently_id)->value('title');
- });
- $total_num= PlatformSwitch::field($field)->alias('p') ->leftJoin('ArticleIntro a','p.switch_id = a.id')->where($sel_where)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的订阅---消息
- * @desc 订阅消息
- * @author qc
- * @method GET
- * @url /api/Article/getFollowUpMessage
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:int default:-- desc:搜索内容
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:内容
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_read type:int default:-- desc:是否已读【0否1是】
- * @return name:article_title type:string default:-- desc:系列标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:article_id type:int default:-- desc:系列id
- * @return name:children_id type:int default:-- desc:详情id
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getFollowUpMessage()
- {
- $title = input('title');
- $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'article','m.type_id'=>5])
- ->alias('m')
- ->when($title,function ($query)use ($title){
- if($title) $query->where('m.content','like','%'.$title.'%');})
- ->field('m.id,v.create_at,m.is_read,m.content,m.relation_id article_id,m.module,v.title article_title,m.children_id')
- ->leftJoin('ArticleIntro v','v.id= m.relation_id')
- ->limit($this->off_set,$this->page_num)
- ->order(['m.id'=>'desc'])
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['series_title'] =$v['article_title'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['children_id'],$this->request->controller());
- }
- $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'article','m.type_id'=>5])
- ->alias('m')->leftJoin('ArticleIntro v','v.id= m.relation_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 评论点赞列表--我的点赞
- * @desc 评论点赞列表
- * @author qc
- * @method GET
- * @url /api/Article/getTagsComment
- * @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:create_at type:string default:-- desc:时间
- * @return name:user_name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:content type:string default:-- desc:评论内容
- * @return name:cover type:string default:-- desc:封面
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- */
- public function getTagsComment()
- {
- $list = ArticleCommentLike::field('l.*,i.read_num,c.content,i.read_num,i.title,i.cover,u.name user_name,u.headimg,i.user_id buid,i.id item_id,i.article_id,x.title series_title')
- ->alias('l')
- ->where(['l.user_id'=>$this->user_id,'l.type'=>1])
- ->leftJoin('ArticleComment c','l.like_id = c.id')
- ->leftJoin('ArticleItem i','i.id = c.item_id')
- ->leftJoin('ArticleIntro x','x.id = i.article_id')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('l.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $article_auth = ArticleItem::getArticleAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- });
- $total_num =ArticleCommentLike::where(['l.user_id'=>$this->user_id,'l.type'=>1])
- ->alias('l')
- ->leftJoin('ArticleComment c','l.like_id = c.id')
- ->leftJoin('ArticleItem i','i.id = c.item_id')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取角标数量
- * @desc 获取角标数量
- * @author qc
- * @method GET
- * @url /api/Article/getMarkNum
- * @header name:Authorization require:1 desc:Token
- * @return name:reply_num type:int default:-- desc:未读量--回复我的
- * @return name:comment_num type:int default:-- desc:未读量--评论我的
- * @return name:praise_num type:int default:-- desc:点赞我的【包含视频点赞和评论点赞】
- * @return name:article_praise_num type:int default:-- desc:-图文点赞
- * @return name:comment_praise_num type:int default:-- desc:评论点赞
- * @return name:follow_num type:int default:-- desc:订阅
- */
- public function getMarkNum()
- {
- // 评论我的
- $comment_num = ArticleComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.user_id','<>',$this->user_id],['is_read','=',0],['t.pid','=',0]])
- ->leftJoin('ArticleItem i','t.item_id = i.id')
- ->alias('t')->count();
- // 回复我的
- $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- $reply_num = $all_comment ? ArticleComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.lev','>=',2],['is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count() : 0;
- // 点赞我的
- $all_article = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
- $article_praise_num = ArticleLike ::where([['is_read','=',0],['item_id','in',$all_article],['user_id','<>',$this->user_id]])->count();
- $comment_praise_num = ArticleCommentLike::where([['is_read','=',0],['like_id','in',$all_comment],['user_id','<>',$this->user_id]])->count();
- $praise_num = $article_praise_num + $comment_praise_num;
- $follow_num = UserMessage::getUnreadNum($this->user_id,'article',5);
- $this->success('ok',compact(['reply_num','comment_num','praise_num','article_praise_num','comment_praise_num','follow_num']));
- }
- /**
- * @title 消息已读&&未读变更
- * @desc 消息已读
- * @author qc
- * @method POST
- * @url /api/Article/unreadChange
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部)
- * @param name:type type:string default:1 desc:消息类型【1评论我的,2回复我的,3订阅消息,4点赞我的--图文,5点赞我的--评论】
- * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
- *
- */
- public function unreadChange()
- {
- $type = input('post.type',1);
- $id = input('post.id');
- $where = [];
- switch ($type) {
- case 1:
- ArticleComment::where([['i.user_id','=',$this->user_id],['t.pid','=',0]])
- ->when($id ,function ($query)use ($id){
- if($id) return $query->where('t.id','in',$id);
- })->leftJoin('ArticleItem i','t.item_id = i.id')
- ->alias('t')->update(['source_read'=>input('post.is_read'),'is_read'=>input('post.is_read')]);
- break;
- case 2:
- $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- ArticleComment::where([['t.pid','in',implode(',',$all_comment)]])
- ->when($id ,function ($query)use ($id){
- if($id) return $query->where('t.id','in',$id);
- })->alias('t')->update(['is_read'=>input('post.is_read')]);
- break;
- case 3:
- $where[] = ['user_id','=',$this->user_id];
- if($id) $where[] = ['id','in',$id];
- UserMessage::where($where)->update(['is_read'=>input('post.is_read')]);
- break;
- case 4:
- $all_article = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
- ArticleLike::where([['is_read','=',0],['item_id','in',$all_article]])->update(['is_read'=>1]);
- break;
- case 5:
- $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- ArticleCommentLike ::where([['is_read','=',0],['like_id','in',$all_comment]])->update(['is_read'=>1]);
- break;
- }
- $this->success('消息变更成功');
- }
- /**
- * @title 批量删除||批量取消
- * @desc 删除||取消
- * @author qc
- * @method POST
- * @url /api/Article/batchesDel
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
- * @param name:type type:string default:1 desc:消息类型【1我的评论,2评论我的,3我的回复,4我的已购,5用户图文删除,6订阅记录,7订阅消息,8我的点赞-图文,9我的点赞-评论,10回复我的,11点赞我的--图文,12点赞我的--评论,13我的收藏】
- */
- public function batchesDel(){
- $type = input('post.type',1);
- $del_where = [];
- $del_where[] = ['id','in',input('post.id')];
- if(in_array($type,[1,3,4,5,6,7,8,9])) $del_where[] = ['user_id','=',$this->user_id];
- if(in_array($type,[1,3])) ArticleComment::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[2])) ArticleComment::where($del_where)->update(['source_deleted'=>1,'source_read'=>1,'is_read'=>1]);
- if(in_array($type,[10])) ArticleComment::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[4])) UserLearn::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[5])) UserArticle::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[6])) PlatformSwitch::where($del_where)->delete();
- if(in_array($type,[7])) UserMessage::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[8])) ArticleLike::where($del_where)->delete();
- if(in_array($type,[11])) ArticleLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[9])) ArticleCommentLike::where($del_where)->delete();
- if(in_array($type,[12])) ArticleCommentLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[13])) UserCollect::where($del_where)->delete();
- $this->success('操作成功');
- }
- /**
- * @title 点赞我的--图文
- * @desc 点赞我的--图文
- * @author qc
- * @method GET
- * @url /api/Article/praiseMyArticleList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:create_at type:string default:-- desc:时间
- * @return name:read_num type:int default:-- desc:阅读量
- * @return name:user_name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:cover type:string default:-- desc:封面
- */
- public function praiseMyArticleList()
- {
- $all_list = ArticleItem::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
- $user_info = $this->userInfo('name,headimg');
- $list = ArticleLike::where([['l.item_id','in',$all_list],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')
- ->field('l.id,l.user_id,m.name user_name,m.headimg,l.create_at,v.cover,v.title,v.read_num,x.title series_title,v.article_id,l.item_id')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('ArticleItem v','v.id = l.item_id')
- ->leftJoin('ArticleIntro x','x.id = v.article_id')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v,$k)use ($user_info){
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- $v['app_name'] = $user_info['name'] ;
- $v['app_logo'] = $user_info['headimg'];
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total_num = ArticleLike::where([['item_id','in',$all_list],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('ArticleItem v','v.id = l.item_id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 点赞我的--评论
- * @desc 点赞我的--评论
- * @author qc
- * @method GET
- * @url /api/Article/praiseMyComment
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:create_at type:string default:-- desc:时间
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:self_name type:string default:-- desc:会员名称[自己的]
- * @return name:user_name type:string default:-- desc:会员名称【别人的】
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:cover type:string default:-- desc:封面
- * @return name:like_id type:int default:-- desc:评论id
- */
- public function praiseMyComment()
- {
- $user_info = $this->userInfo('name,headimg');
- $list = ArticleCommentLike::where([['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')
- ->field('l.id,l.user_id,l.like_id,m.name user_name,m.headimg,l.create_at,v.cover,c.content,v.title,v.read_num,x.title series_title,v.article_id,c.item_id,v.user_id buid')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('ArticleComment c','c.id = l.like_id')
- ->leftJoin('ArticleItem v','v.id = c.item_id')
- ->leftJoin('ArticleIntro x','x.id = v.article_id')
- ->order('l.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v,$k)use ($user_info){
- $v['self_name'] = $user_info['name'] ;
- $article_auth = ArticleItem::getArticleAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $article_auth['app_name'];
- $v['app_logo'] = $article_auth['app_logo'];
- $v['read_num'] = numTransform($v['read_num']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['article_id'],$v['item_id'],$this->request->controller());
- });
- $total_num = ArticleCommentLike::where([['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('ArticleComment c','c.id = l.like_id')
- ->leftJoin('ArticleItem v','v.id = c.item_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- }
|