Article.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\ArticleCate;
  4. use app\common\model\ArticleComment;
  5. use app\common\model\ArticleCommentLike;
  6. use app\common\model\ArticleIntro;
  7. use app\common\model\ArticleItem;
  8. use app\common\model\ArticleLike;
  9. use app\common\model\SeriesArticleCate;
  10. use app\common\model\User;
  11. use app\common\model\UserCollect;
  12. use app\common\model\UserArticle;
  13. use app\common\model\UserLearn;
  14. use app\common\model\UserMessage;
  15. use app\common\model\UserSearch;
  16. use app\common\model\UserTag;
  17. use app\common\model\UserTrack;
  18. use library\tools\Data;
  19. use think\Db;
  20. /**
  21. * @title 图文
  22. * @controller Article
  23. * @group base
  24. */
  25. class Article extends Base
  26. {
  27. // 需要登录的
  28. protected $need_login = [
  29. 'articleTransmit',
  30. 'articleRead',
  31. 'articleTags',
  32. 'articleComment',
  33. 'articleCollect',
  34. 'userReferArticle',
  35. 'getMyArticleList',
  36. 'getUserArticleDetail',
  37. 'delUserArticle',
  38. 'delComment',
  39. 'getLearnHistory',
  40. 'getArticleCollect',
  41. 'getCommentArticle',
  42. 'getPurchaseArticle',
  43. 'getPurchaseArticle',
  44. 'getReplyArticle',
  45. 'getReplyComment',
  46. 'getTagsArticle',
  47. ];
  48. public function initialize()
  49. {
  50. parent::initialize();
  51. parent::setUid();
  52. }
  53. /**
  54. * @title 图文接口说明
  55. * @desc 图文接口说明
  56. * @author qc
  57. * @url /api/Article/classIntro
  58. * @method GET
  59. * @return name:1 type:string default:-- desc:图片(images字段)多图片都用竖线(|)隔开,会员上传多张也用(|)隔开
  60. * @return name:2 type:string default:-- desc:cover字段值是images的第一个路径【非多张】
  61. * @return name:3 type:string default:-- desc:单一图文与系列图文区别,type值(1是单一,2是系列),数据:item_list二维数组数据数量不一样(单一的只有一个,系列的可以是多个)【可以将单一图文看做只有一条记录的系列图文!!!!】
  62. * @return name:4 type:string default:-- desc:单一图文详情的字段(cover,images,is_vip,title)与item_list数组的第一个同字段名的值相同
  63. * @return name:5 type:string default:-- desc:系列图文详情的字段(cover,images)与item_list的其中一个相同
  64. * @return name:6 type:string default:-- desc:关于是否的字段(0否,1是)
  65. * @return name:7 type:string default:-- desc:item_id是数组item_list下的id
  66. */
  67. public function classIntro(){}
  68. /**
  69. * @title 获取图文分类
  70. * @desc 获取图文分类
  71. * @author qc
  72. * @url /api/Article/getArticleCate
  73. * @method GET
  74. * @header name:Authorization require:1 desc:Token
  75. * @param name:type type:int default:1 desc:类型1单个2系列
  76. * @return name:id type:int default:-- desc:分类id
  77. * @return name:logo type:string default:-- desc:图标
  78. * @return name:title type:string default:0 desc:分类名称
  79. * @return name:children type:array default:0 desc:下级分类
  80. */
  81. public function getArticleCate()
  82. {
  83. $type = input('type',1);
  84. if($type == 1) {
  85. $list = ArticleCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray();
  86. }else{
  87. $list = SeriesArticleCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray();
  88. }
  89. $list = make_tree($list);
  90. $this->success('ok',['list'=>$list]);
  91. }
  92. /**
  93. * @title 图文推荐
  94. * @desc 图文推荐
  95. * @author qc
  96. * @method GET
  97. * @url /api/Article/getRecommendList
  98. * @header name:Authorization require:1 desc:Token
  99. * @param name:page type:int default:0 desc:页数
  100. * @param name:page_num type:int default:20 desc:每页数
  101. * @return name:id type:string default:-- desc:图文item_id
  102. * @return name:title type:string default:-- desc:标题
  103. * @return name:article_id type:string default:-- desc:系列id
  104. * @return name:cover type:string default:-- desc:封面
  105. * @return name:images_arr type:string default:-- desc:图片
  106. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  107. * @return name:read_num type:int default:-- desc:阅读量
  108. * @return name:app_name type:string default:-- desc:平台名称
  109. * @return name:app_logo type:string default:-- desc:平台头像
  110. */
  111. public function getRecommendList()
  112. {
  113. $app_name = sysconf('app_name');
  114. $app_logo = sysconf('app_logo');
  115. $search_log = UserSearch::getSearchTitle($this->user_id,2);
  116. $search_arr = [];
  117. $where_str = 'b.id > 0';
  118. foreach ($search_log as $t){
  119. $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
  120. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  121. }
  122. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  123. $field = ' a.id,a.title,a.cover,a.images,a.user_id,a.is_vip,a.read_num,a.article_id ,IFNULL(is_recommend,0) is_recommend ';
  124. $table = 'dd_article_item';
  125. $order_by_two = 'a.read_num';
  126. $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id LEFT JOIN dd_article_intro as k ON k.id = a.article_id WHERE a.is_deleted = 0 AND a.status =1 AND k.status = 1 AND k.is_deleted = 0 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}";
  127. $list = Db::query($sql);
  128. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  129. if(!$v['user_id']){
  130. $v['app_name'] = $app_name;
  131. $v['app_logo'] = $app_logo;
  132. }else{
  133. $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
  134. $v['app_name'] = $user_info ? $user_info->name : '';
  135. $v['app_logo'] = $user_info ? $user_info->headimg : '';
  136. }
  137. $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
  138. });
  139. $this->success('ok',['list'=>$list]);
  140. }
  141. /**
  142. * @title 获取图文列表(平台发布)
  143. * @desc 获取图文列表
  144. * @author qc
  145. * @method GET
  146. * @url /api/Article/getArticleList
  147. * @header name:Authorization require:1 desc:Token
  148. * @param name:type type:int default:0 desc:类型1单个2系列
  149. * @param name:is_tj type:int default:0 desc:是否推荐0否1是
  150. * @param name:title type:string default:-- desc:标题
  151. * @param name:page type:int default:0 desc:页数
  152. * @param name:page_num type:int default:20 desc:每页数
  153. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  154. * @param name:first_classify type:int default:0 desc:一级分类
  155. * @param name:second_classify type:int default:0 desc:二级分类
  156. * @return name:id type:string default:-- desc:ID[请求/api/Article/getArticleDetail用]
  157. * @return name:title type:string default:-- desc:标题
  158. * @return name:type type:int default:0 desc:类型1单个2系列
  159. * @return name:cover type:string default:-- desc:封面()
  160. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  161. * @return name:is_over type:int default:-- desc:是否完结(0否,1是)
  162. * @return name:read_num type:int default:-- desc:阅读量
  163. * @return name:label type:string default:-- desc:标签
  164. * @return name:item_list type:array default:-- desc:图文
  165. * @return name:item_list.title type:string default:-- desc:图文标题
  166. * @return name:item_list.is_vip type:int default:-- desc:是否是vip
  167. * @return name:item_list.cover type:string default:-- desc:图文封面
  168. * @return name:item_list.images type:string default:-- desc:图片(多张用|隔开)
  169. * @return name:item_list.content type:string default:-- desc:内容
  170. */
  171. public function getArticleList()
  172. {
  173. $sel_where = [];
  174. $title = input('get.title');
  175. $type = input('get.type',0);
  176. $is_tj = input('get.is_tj',0);
  177. $sort_type = input('get.sort_type',1);
  178. $first_classify = input('get.first_classify');
  179. $second_classify = input('get.second_classify');
  180. $sel_where[] = ['is_deleted','=',0];
  181. $sel_where[] = ['status','=',1];
  182. $sel_where[] = ['item_num','>',0];
  183. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  184. if($type) $sel_where[] = ['type','=',$type];
  185. if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
  186. if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
  187. switch ($sort_type) {
  188. case 1:
  189. $order = ['sort'=>'desc','id'=>'desc'];
  190. break;
  191. case 2:
  192. $order = ['id'=>'asc','sort'=>'desc'];
  193. break;
  194. case 3:
  195. $order = ['id'=>'desc','sort'=>'desc'];
  196. break;
  197. }
  198. if($title && $this->user_id)UserSearch::saveSearchTitle($this->user_id,$title,2);
  199. $where_str = 'id > 0';
  200. if($is_tj) {
  201. $search_log = UserSearch::getSearchTitle($this->user_id,2);
  202. $search_arr = [];
  203. foreach ($search_log as $t){
  204. $search_arr[] = " title like '".'%'.$t."%'" .' ';
  205. }
  206. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  207. }
  208. $list = ArticleIntro::where($sel_where)->with('itemList')
  209. ->limit($this->off_set,$this->page_num)
  210. ->where($where_str)
  211. ->order($order)
  212. ->select()->toArray();
  213. array_walk($list,function (&$v,$k){
  214. });
  215. $this->success('ok',['list'=>$list]);
  216. }
  217. /**
  218. * @title 获取图文详情(平台)
  219. * @desc 获取图文详情
  220. * @author qc
  221. * @method GET
  222. * @url /api/Article/getArticleDetail
  223. * @header name:Authorization require:1 desc:Token
  224. * @param name:id type:int default:0 desc:图文id
  225. * @return name:title type:string default:-- desc:标题
  226. * @return name:cover type:string default:-- desc:封面
  227. * @return name:images type:string default:-- desc:图片
  228. * @return name:is_vip type:string default:-- desc:是否VIP
  229. * @return name:item_list type:array default:-- desc:图文
  230. * @return name:item_list.id type:string default:-- desc:[请求/api/Article/getArticleItemInfo用,请求图文模块其他接口参数:item_id]
  231. * @return name:item_list.title type:string default:-- desc:图文标题
  232. * @return name:item_list.is_vip type:int default:-- desc:是否是vip
  233. * @return name:item_list.cover type:string default:-- desc:封面
  234. * @return name:item_list.images type:int default:-- desc:图片
  235. * @return name:item_list.content type:int default:-- desc:内容
  236. * @return name:item_list.transmit_num type:int default:-- desc:转发量
  237. * @return name:item_list.read_num type:int default:-- desc:阅读量
  238. * @return name:item_list.comment_num type:int default:-- desc:评论量
  239. * @return name:item_list.collect_num type:int default:-- desc:收藏量
  240. * @return name:item_list.is_collect type:int default:-- desc:是否收藏
  241. * @return name:item_list.video_id type:int default:-- desc:关联视频id【单个id||系列id】
  242. * @return name:item_list.video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  243. * @return name:item_list.datum_id type:int default:-- desc:资料id【单个id||系列id】
  244. * @return name:item_list.datum_item type:int default:-- desc:资料详情id【url_arr.id】
  245. */
  246. public function getArticleDetail()
  247. {
  248. $sel_where = [];
  249. $sel_where[] = ['id','=',input('get.id')];
  250. $detail = ArticleIntro::where($sel_where)->with('itemList')->find()->toArray();
  251. if($detail['is_deleted'] == 1 || $detail['status'] == 0)$this->error('该图文已下线');
  252. foreach ($detail['item_list'] as &$dv) {
  253. $dv['comment_num'] = ArticleComment::where(['article_id'=>$detail['id'],'item_id'=>$dv['id']])->count();
  254. $dv['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
  255. $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['id'],$dv['id']);
  256. }
  257. $detail['read_num'] = array_sum(array_column($detail['item_list'],'read_num'));
  258. $this->success('ok',['detail'=>$detail]);
  259. }
  260. /**
  261. * @title 获取图文ITEM详情(平台)
  262. * @desc 获取图文ITEM详情
  263. * @author qc
  264. * @method GET
  265. * @url /api/Article/getArticleItemInfo
  266. * @header name:Authorization require:1 desc:Token
  267. * @param name:item_id type:int default:0 desc:item_list
  268. * @return name:title type:string default:-- desc:图文标题
  269. * @return name:is_vip type:int default:-- desc:是否是vip
  270. * @return name:cover type:string default:-- desc:封面
  271. * @return name:images type:int default:-- desc:图片
  272. * @return name:content type:int default:-- desc:内容
  273. * @return name:transmit_num type:int default:-- desc:转发量
  274. * @return name:read_num type:int default:-- desc:阅读量
  275. * @return name:comment_num type:int default:-- desc:评论量
  276. * @return name:collect_num type:int default:-- desc:收藏量
  277. * @return name:is_collect type:int default:-- desc:是否收藏
  278. * @return name:like_num type:int default:-- desc:点赞量
  279. * @return name:is_like type:int default:-- desc:是否点赞
  280. * @return name:video_id type:int default:-- desc:关联视频id【单个id||系列id】
  281. * @return name:video_item type:int default:-- desc:关联视频详情id【video_arr.id】
  282. * @return name:datum_id type:int default:-- desc:资料id【单个id||系列id】
  283. * @return name:datum_item type:int default:-- desc:资料详情id【url_arr.id】
  284. */
  285. public function getArticleItemInfo()
  286. {
  287. $item_id = input('get.item_id');
  288. $detail = ArticleItem::where('id',$item_id)->find()->toArray();
  289. $detail['comment_num'] = ArticleComment::where(['article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count();
  290. $detail['collect_num'] = UserCollect::where(['coll_type'=>3,'coll_id'=>$detail['article_id'],'children_id'=>$detail['id']])->count();
  291. $detail['is_collect'] = UserCollect::checkCollectByType($this->user_id,3,$detail['article_id'],$detail['id']);
  292. $detail['is_like'] = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count();
  293. $detail['like_num'] = ArticleLike::where(['article_id'=>$detail['article_id'],'item_id'=>$detail['id']])->count();
  294. UserTrack::crateTrack($this->user_id,3,$detail['article_id'],$item_id);
  295. //var_dump($this->user_id,3,$detail['article_id'],$item_id);
  296. $this->success('ok',['detail'=>$detail]);
  297. }
  298. /**
  299. * @title 获取图文评论列表
  300. * @desc 获取图文评论列表
  301. * @author qc
  302. * @method GET
  303. * @url /api/Article/getArticleCommentList
  304. * @header name:Authorization require:1 desc:Token
  305. * @param name:article_id type:int default:-- desc:图文id
  306. * @param name:item_id type:int default:-- desc:item_id
  307. * @param name:sort_type type:int default:1 desc:排序1默认2时间升序3时间降序
  308. * @param name:page type:int default:-- desc:页数
  309. * @return name:name type:string default:-- desc:会员名称
  310. * @return name:headimg type:string default:-- desc:会员头像
  311. * @return name:content type:string default:-- desc:内容
  312. * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
  313. * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
  314. * @return name:like_num type:int default:-- desc:点赞数量
  315. * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
  316. * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是)
  317. * @return name:total_num type:int default:-- desc:总评论数(仅一级)
  318. */
  319. public function getArticleCommentList()
  320. {
  321. $where = [];
  322. $where[] = ['c.article_id','=',input('get.article_id')];
  323. $where[] = ['c.is_deleted','=',0];
  324. $user_id = $this->user_id;
  325. $sort_type= input('sort_type',1);
  326. if(input('get.item_id')) $where[] = ['c.item_id','=',input('get.item_id')];
  327. switch ($sort_type) {
  328. case 1:
  329. $order = ['sort'=>'desc','id'=>'desc'];
  330. break;
  331. case 2:
  332. $order = ['id'=>'asc','sort'=>'desc'];
  333. break;
  334. case 3:
  335. $order = ['id'=>'desc','sort'=>'desc'];
  336. break;
  337. }
  338. $list =ArticleComment::where($where)
  339. ->alias('c')
  340. ->field('c.*,u.name,u.headimg')
  341. ->leftJoin('store_member u','u.id = c.user_id')
  342. ->order($order)
  343. ->limit($this->off_set,$this->page_num)
  344. ->select()->toArray();
  345. array_walk($list,function (&$val,$k)use($user_id){
  346. $children = ArticleComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0])
  347. ->alias('c')->field('c.*,u.name,u.headimg')
  348. ->leftJoin('store_member u','u.id = c.user_id')
  349. ->order('c.id asc')
  350. ->select()->toArray();
  351. $val['children'] = $children;
  352. $val['like_num'] = ArticleCommentLike::where('like_id',$val['id'])->count();
  353. $val['is_like'] = ArticleCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id])->count();
  354. $parent = ArticleComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0])
  355. ->alias('c')->field('c.*,u.name,u.headimg')
  356. ->leftJoin('store_member u','u.id = c.user_id')
  357. ->find();
  358. $val['parent'] = $parent ? $parent->toArray() : null;
  359. $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0;
  360. });
  361. $total_num = ArticleComment::where($where)->alias('c')->count();
  362. $this->success('ok',['list'=>$list,'total_num'=>$total_num]);
  363. }
  364. /**
  365. * @title 以下接口调用验证登录【需要header传Authorization】
  366. * @desc 转发成功后调用
  367. * @author qc
  368. * @method
  369. * @url /api/Article/needLogin()
  370. */
  371. public function needLogin(){}
  372. /**
  373. * @title 图文转发(转发数量统计)
  374. * @desc 转发成功后调用
  375. * @author qc
  376. * @method POST
  377. * @url /api/Article/articleTransmit
  378. * @header name:Authorization require:1 desc:Token
  379. * @param name:item_id type:int default:-- desc:item_list的id
  380. */
  381. public function articleTransmit()
  382. {
  383. $item_id = input('post.item_id',0);
  384. ArticleItem::where('id',$item_id)->setInc('transmit_num');
  385. $this->success('ok');
  386. }
  387. /**
  388. * @title 图文阅读(阅读数量统计)
  389. * @desc 图文阅读
  390. * @author qc
  391. * @method POST
  392. * @url /api/Article/articleRead
  393. * @header name:Authorization require:1 desc:Token
  394. * @param name:item_id type:int default:-- desc:item_list的id
  395. */
  396. public function articleRead()
  397. {
  398. $item_id = input('post.item_id',0);
  399. ArticleItem::where('id',$item_id)->setInc('read_num');
  400. $this->success('ok');
  401. }
  402. /**
  403. * @title 图文点赞||取消点赞
  404. * @desc 点赞||取消点赞
  405. * @author qc
  406. * @method POST
  407. * @url /api/Article/articleTags
  408. * @header name:Authorization require:1 desc:Token
  409. * @param name:article_id type:int default:1 desc:图文id
  410. * @param name:item_id type:int default:1 desc:item_id
  411. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  412. */
  413. public function articleTags()
  414. {
  415. $article_id = input('post.article_id');
  416. $item_id = input('post.item_id');
  417. $ret_val = 0;
  418. $check_tags = ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id])->value('id');
  419. if($check_tags) {
  420. ArticleLike::where(['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id])->delete();
  421. }else{
  422. Data::save('ArticleLike',
  423. ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id],'user_id',
  424. ['user_id'=>$this->user_id,'article_id'=>$article_id,'item_id'=>$item_id]);
  425. $ret_val = 1;
  426. }
  427. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  428. }
  429. /**
  430. * @title 图文评论
  431. * @desc 图文评论
  432. * @author qc
  433. * @method POST
  434. * @url /api/Article/articleComment
  435. * @header name:Authorization require:1 desc:Token
  436. * @param name:article_id type:int default:1 desc:图文id
  437. * @param name:item_id type:int default:1 desc:item_id
  438. * @param name:content type:string default:-- desc:内容
  439. * @return name:name type:string default:-- desc:会员名称
  440. * @return name:headimg type:string default:-- desc:会员头像
  441. * @return name:content type:string default:-- desc:内容
  442. */
  443. public function articleComment()
  444. {
  445. $article_id = input('post.article_id');
  446. $item_id = input('post.item_id');
  447. $content = input('post.content',0);
  448. if(!$content) $this->error('请输入评论内容');
  449. $res = ArticleComment::create(['user_id'=>$this->user_id,'content'=>$content,'article_id'=>$article_id,'item_id'=>$item_id]);
  450. $detail =ArticleComment::where('c.id',$res->id)
  451. ->alias('c')
  452. ->field('c.id,c.content,c.create_at,u.name,u.headimg')
  453. ->leftJoin('store_member u','u.id = c.user_id')
  454. ->find()->toArray();
  455. $send_user = ArticleItem::where('id',$item_id)->value('user_id');
  456. $user_info = $this->userInfo('name');
  457. if($send_user) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$item_id,$user_info['name'].'评论了您的图文');
  458. $this->success('评论成功',['detail'=>$detail]);
  459. }
  460. /**
  461. * @title 删除评论
  462. * @desc 删除评论
  463. * @author qc
  464. * @method POST
  465. * @url /api/Article/delComment
  466. * @header name:Authorization require:1 desc:Token
  467. * @param name:id type:int default:1 desc:评论id
  468. */
  469. public function delComment(){
  470. ArticleComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
  471. $this->success('删除成功');
  472. }
  473. /**
  474. * @title 图文二级评论
  475. * @desc 图文二级评论
  476. * @author qc
  477. * @method POST
  478. * @url /api/Article/secondCommend
  479. * @header name:Authorization require:1 desc:Token
  480. * @param name:id type:int default:1 desc:评论id
  481. * @param name:content type:string default:-- desc:内容
  482. * @return name:name type:string default:-- desc:会员名称
  483. * @return name:headimg type:string default:-- desc:会员头像
  484. * @return name:content type:string default:-- desc:内容
  485. */
  486. public function secondCommend()
  487. {
  488. $comment = ArticleComment::where('id',input('post.id'))->find()->toArray();
  489. $user_info = $this->userInfo('name');
  490. UserMessage:: sendUserMessage($comment['user_id'],'article',3,0,$this->user_id,$comment['id'],$user_info['name'].'回复了您的评论');
  491. $send_user = ArticleItem::where('id',$comment['item_id'])->value('user_id');
  492. if($send_user) UserMessage:: sendUserMessage($send_user,'article',4,0,$this->user_id,$comment['item_id'],$user_info['name'].'评论了您的图文');
  493. unset($comment['id']);
  494. unset($comment['create_at']);
  495. $comment['pid'] = input('post.id');
  496. $comment['user_id'] = $this->user_id;
  497. $comment['content'] = input('post.content');
  498. $comment['lev']++;
  499. if(!$comment['source_id']) $comment['source_id'] = input('post.id');
  500. $res = ArticleComment::create($comment);
  501. $detail = ArticleComment::where('c.id',$res->id)
  502. ->alias('c')
  503. ->field('c.id,c.content,c.create_at,u.name,u.headimg')
  504. ->leftJoin('store_member u','u.id = c.user_id')
  505. ->find()->toArray();
  506. $this->success('评论成功',['detail'=>$detail]);
  507. }
  508. /**
  509. * @title 评论点赞||取消点赞
  510. * @desc 评论
  511. * @author qc
  512. * @method POST
  513. * @url /api/Article/commentTags
  514. * @header name:Authorization require:1 desc:Token
  515. * @param name:comment_id type:int default:1 desc:评论记录id
  516. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  517. */
  518. public function commentTags()
  519. {
  520. $comment_id = input('post.comment_id');
  521. $ret_val = 0;
  522. $check_tags = ArticleCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$comment_id])->value('id');
  523. if($check_tags) {
  524. ArticleCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$comment_id])->delete();
  525. }else{
  526. Data::save('ArticleCommentLike',
  527. ['user_id'=>$this->user_id,'like_id'=>$comment_id,],'user_id',
  528. ['user_id'=>$this->user_id,'like_id'=>$comment_id]);
  529. $ret_val = 1;
  530. }
  531. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  532. }
  533. /**
  534. * @title 图文收藏||取消收藏
  535. * @desc 用户收藏
  536. * @author qc
  537. * @method POST
  538. * @url /api/Article/articleCollect
  539. * @header name:Authorization require:1 desc:Token
  540. * @param name:article_id type:int require:1 default:-- desc:记录id[图文id]
  541. * @param name:item_id type:int default:1 desc:item_id
  542. * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
  543. */
  544. public function articleCollect()
  545. {
  546. $coll_type = input('post.coll_type',3);
  547. $coll_id = input('post.article_id',0);
  548. $item_id = input('post.item_id',0);
  549. $collect_check = UserCollect::checkCollectByType($this->user_id,$coll_type,$coll_id,$item_id);
  550. if($collect_check) {
  551. UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$coll_id,'children_id'=>$item_id])->delete();
  552. $this->success('取消收藏成功',['status'=>0]);
  553. }else{
  554. Data::save('UserCollect', [
  555. 'user_id'=>$this->user_id,
  556. 'coll_type'=>$coll_type,
  557. 'coll_id'=>$coll_id,
  558. 'children_id'=>$item_id,
  559. 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$coll_id,'children_id'=>$item_id]);
  560. $this->success('收藏成功',['status'=>1]);
  561. }
  562. }
  563. /**
  564. * @title 用户提交或修改图文【个人】
  565. * @desc 用户提交或修改图文【个人】
  566. * @author qc
  567. * @method POST
  568. * @url /api/Article/userReferArticle
  569. * @header name:Authorization require:1 desc:Token
  570. * @param name:id type:int default:-- desc:id(修改时必传)
  571. * @param name:title type:string default:-- desc:标题
  572. * @param name:images type:string default:-- desc:图片(多张用|隔开)
  573. * @param name:desc type:string default:-- desc:简介
  574. * @param name:label type:string default:-- desc:图文标签
  575. * @param name:document type:string default:-- desc:文件路径【单文件】
  576. */
  577. public function userReferArticle()
  578. {
  579. $id = input('post.id',0);
  580. $title = input('post.title');
  581. $desc = input('post.desc');
  582. $images = input('post.images');
  583. $label = input('post.label');
  584. $document = input('post.document');
  585. //if(!$images) $this->error('请上传图文');
  586. if($id){
  587. $check_status = UserArticle::where('id',$id)->value('status');
  588. if($check_status == 1) $this->error('已审核通过,不允许修改');
  589. }
  590. $data = [
  591. 'title' => $title,
  592. 'user_id' => $this->user_id,
  593. 'desc' => $desc,
  594. 'images' => $images,
  595. 'label' => $label,
  596. 'document' => $document,
  597. 'cover' => $images ? explode('|',$images)[0] : '',
  598. 'status' => 0,
  599. 'remark' => '',
  600. ];
  601. if($id) $data['id'] = $id;
  602. if($id){
  603. UserArticle::where('id',$id)->update($data);
  604. }else{
  605. $res= UserArticle::create($data) ;
  606. }
  607. UserMessage::sendUserMessage($this->user_id,'article',1,0,0,$id ? $id:$res->id);
  608. $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]);
  609. }
  610. /**
  611. * @title 获取我的图文列表【个人--我的发布列表】
  612. * @desc 获取我的图文列表【个人】
  613. * @author qc
  614. * @method GET
  615. * @url /api/Article/getMyArticleList
  616. * @header name:Authorization require:1 desc:Token
  617. * @param name:title type:string default:-- desc:标题
  618. * @param name:page type:int default:0 desc:页数
  619. * @param name:page_num type:int default:20 desc:每页数
  620. * @return name:title type:string default:-- desc:标题
  621. * @return name:desc type:string default:-- desc:简介
  622. * @return name:images type:string default:-- desc:图文【多张|隔开】
  623. * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
  624. * @return name:remark type:string default:-- desc:审核备注
  625. */
  626. public function getMyArticleList()
  627. {
  628. $sel_where = [];
  629. $sel_where[] = ['is_deleted','=',0];
  630. $sel_where[] = ['user_id','=',$this->user_id];
  631. $title = input('get.title');
  632. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  633. $list = UserArticle::where($sel_where)
  634. ->field('id,title,desc,images,status,remark')
  635. ->order('id desc')
  636. ->limit($this->off_set,$this->page_num)
  637. ->select()->toArray();
  638. $this->success('ok',['list'=>$list]);
  639. }
  640. /**
  641. * @title 获取我的图文详情【个人】
  642. * @desc 获取我的图文列表【个人】
  643. * @author qc
  644. * @method GET
  645. * @url /api/Article/getUserArticleDetail
  646. * @header name:Authorization require:1 desc:Token
  647. * @param name:id type:string default:-- desc:记录id
  648. * @return name:title type:string default:-- desc:标题
  649. * @return name:desc type:string default:-- desc:简介
  650. * @return name:images type:string default:-- desc:图文[多张|隔开]
  651. * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
  652. * @return name:remark type:string default:-- desc:审核备注
  653. * @return name:label type:string default:-- desc:标签
  654. * @return name:document type:string default:-- desc:文件路径
  655. */
  656. public function getUserArticleDetail()
  657. {
  658. $detail =UserArticle::where('id',input('get.id'))->field('id,title,desc,images,status,remark,label,document')->find();
  659. if(!$detail) $this->error('图文有误');
  660. $this->success('ok',['detail'=>$detail->toArray()]);
  661. }
  662. /**
  663. * @title 用户删除图文记录【个人】
  664. * @desc 用户删除图文记录【个人】
  665. * @author qc
  666. * @method POST
  667. * @url /api/Article/delUserArticle
  668. * @header name:Authorization require:1 desc:Token
  669. * @param name:id type:int default:-- desc:id
  670. */
  671. public function delUserArticle()
  672. {
  673. UserArticle::where(['user_id'=>$this->user_id,'id'=>input('post.id')])->delete();
  674. $this->success('删除成功');
  675. }
  676. /**
  677. * @title 以下接口学习服务模块的
  678. * @desc
  679. * @author qc
  680. * @method
  681. * @url /api/Article/learn()
  682. */
  683. public function learn(){}
  684. /**
  685. * @title 图文学习历史
  686. * @desc 图文学习历史
  687. * @author qc
  688. * @method GET
  689. * @url /api/Article/getLearnHistory
  690. * @header name:Authorization require:1 desc:Token
  691. * @param name:title type:string default:-- desc:标题
  692. * @param name:page type:int default:0 desc:页数
  693. * @param name:page_num type:int default:20 desc:每页数
  694. * @return name:title type:string default:-- desc:标题
  695. * @return name:article_id type:string default:-- desc:文章id
  696. * @return name:item_id type:string default:-- desc:item_id
  697. * @return name:cover type:string default:-- desc:封面
  698. * @return name:time type:string default:-- desc:时间
  699. */
  700. public function getLearnHistory()
  701. {
  702. $sel_where = [];
  703. $sel_where[] = ['t.user_id','=',$this->user_id];
  704. $sel_where[] = ['t.type','=',3];
  705. $title = input('get.title');
  706. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  707. $list = UserTrack::where($sel_where)
  708. ->alias('t')
  709. ->field('t.id,t.update_int,t.first_id article_id,t.second_id item_id,i.title,i.cover')
  710. ->leftJoin('ArticleItem i','t.second_id = i.id')
  711. ->order('update_int desc')
  712. ->limit($this->off_set,$this->page_num)
  713. ->select()->toArray();
  714. foreach ($list as &$v) {
  715. $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
  716. }
  717. $this->success('ok',['list'=>$list]);
  718. }
  719. /**
  720. * @title 图文收藏记录
  721. * @desc 图文收藏记录
  722. * @author qc
  723. * @method GET
  724. * @url /api/Article/getArticleCollect
  725. * @header name:Authorization require:1 desc:Token
  726. * @param name:title type:string default:-- desc:标题
  727. * @param name:page type:int default:0 desc:页数
  728. * @param name:page_num type:int default:20 desc:每页数
  729. * @return name:title type:string default:-- desc:标题
  730. * @return name:article_id type:string default:-- desc:文章id
  731. * @return name:item_id type:string default:-- desc:item_id
  732. * @return name:cover type:string default:-- desc:封面
  733. * @return name:create_at type:string default:-- desc:时间
  734. */
  735. public function getArticleCollect()
  736. {
  737. $sel_where = [];
  738. $title = input('get.title');
  739. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  740. $sel_where[] = ['t.user_id','=',$this->user_id];
  741. $sel_where[] = ['t.coll_type','=',3];
  742. $list = UserCollect::where($sel_where)
  743. ->alias('t')
  744. ->field('t.id,t.create_at,t.coll_id article_id,t.children_id item_id,i.title,i.cover')
  745. ->leftJoin('ArticleItem i','t.children_id = i.id')
  746. ->order('id desc')
  747. ->limit($this->off_set,$this->page_num)
  748. ->select()->toArray();
  749. $this->success('ok',['list'=>$list]);
  750. }
  751. /**
  752. * @title 我的评论【学习服务--我评论过的图文】
  753. * @desc 我的评论
  754. * @author qc
  755. * @method GET
  756. * @url /api/Article/getCommentArticle
  757. * @header name:Authorization require:1 desc:Token
  758. * @param name:title type:string default:-- desc:标题
  759. * @param name:page type:int default:0 desc:页数
  760. * @param name:page_num type:int default:20 desc:每页数
  761. * @return name:title type:string default:-- desc:标题
  762. * @return name:article_id type:string default:-- desc:文章id
  763. * @return name:item_id type:string default:-- desc:item_id
  764. * @return name:cover type:string default:-- desc:封面
  765. * @return name:create_at type:string default:-- desc:时间
  766. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  767. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  768. */
  769. public function getCommentArticle()
  770. {
  771. $user_info = $this->userInfo();
  772. $sel_where = [];
  773. $title = input('get.title');
  774. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  775. $sel_where[] = ['t.user_id','=',$this->user_id];
  776. $sel_where[] = ['t.is_deleted','=',0];
  777. $sel_where[] = ['t.lev','=',1];
  778. $list = ArticleComment::where($sel_where)
  779. ->alias('t')
  780. ->field('t.id,t.create_at,t.article_id,t.item_id,t.lev,t.content,i.title,i.cover')
  781. ->leftJoin('ArticleItem i','t.item_id = i.id')
  782. ->order('id desc')
  783. ->limit($this->off_set,$this->page_num)
  784. ->select()->toArray();
  785. foreach ($list as &$v)
  786. {
  787. $v['user_name'] = $user_info['name'];
  788. $v['headimg'] = $user_info['headimg'];
  789. }
  790. $this->success('ok',['list'=>$list]);
  791. }
  792. /**
  793. * @title 评论我的【学习服务--评论我的】
  794. * @desc 评论我的
  795. * @author qc
  796. * @method GET
  797. * @url /api/Article/commentMyArticle
  798. * @header name:Authorization require:1 desc:Token
  799. * @param name:title type:string default:-- desc:标题
  800. * @param name:page type:int default:0 desc:页数
  801. * @param name:page_num type:int default:20 desc:每页数
  802. * @return name:title type:string default:-- desc:标题
  803. * @return name:article_id type:string default:-- desc:文章id
  804. * @return name:item_id type:string default:-- desc:item_id
  805. * @return name:cover type:string default:-- desc:封面
  806. * @return name:create_at type:string default:-- desc:时间
  807. * @return name:user_name type:string default:-- desc:用户名
  808. * @return name:headimg type:string default:-- desc:用户头像
  809. */
  810. public function commentMyArticle()
  811. {
  812. $sel_where = [];
  813. $title = input('get.title');
  814. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  815. $sel_where[] = ['t.is_deleted','=',0];
  816. $sel_where[] = ['i.user_id','=',$this->user_id];
  817. $list = ArticleComment::where($sel_where)
  818. ->alias('t')
  819. ->field('t.id,t.create_at,t.article_id,t.item_id,t.lev,t.content,i.title,i.cover,u.name user_name,u.headimg')
  820. ->leftJoin('ArticleItem i','t.item_id = i.id')
  821. ->leftJoin('store_member u','t.user_id = u.id')
  822. ->order('t.id desc')
  823. ->limit($this->off_set,$this->page_num)
  824. ->select()->toArray();
  825. $this->success('ok',['list'=>$list]);
  826. }
  827. /**
  828. * @title 已购图文列表
  829. * @desc 已购图文列表
  830. * @author qc
  831. * @method GET
  832. * @url /api/Article/getPurchaseArticle
  833. * @header name:Authorization require:1 desc:Token
  834. * @param name:title type:string default:-- desc:标题
  835. * @param name:page type:int default:0 desc:页数
  836. * @param name:page_num type:int default:20 desc:每页数
  837. * @return name:title type:string default:-- desc:标题
  838. * @return name:article_id type:string default:-- desc:文章id
  839. * @return name:item_id type:string default:-- desc:item_id
  840. * @return name:cover type:string default:-- desc:封面
  841. * @return name:create_at type:string default:-- desc:时间
  842. */
  843. public function getPurchaseArticle()
  844. {
  845. $sel_where = [];
  846. $title = input('get.title');
  847. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  848. $sel_where[] = ['t.user_id','=',$this->user_id];
  849. $sel_where[] = ['t.type','=',3];
  850. $sel_where[] = ['t.end_int','>',time()];
  851. $list = UserLearn::where($sel_where)
  852. ->alias('t')
  853. ->field('t.id,t.create_at,t.first_id article_id,t.second_id item_id,i.title,i.cover')
  854. ->leftJoin('ArticleItem i','t.second_id = i.id')
  855. ->order('id desc')
  856. ->limit($this->off_set,$this->page_num)
  857. ->select()->toArray();
  858. $this->success('ok',['list'=>$list]);
  859. }
  860. /**
  861. * @title 我的回复【我的回复--我回复过的评论】
  862. * @desc 我的评论
  863. * @author qc
  864. * @method GET
  865. * @url /api/Article/getReplyArticle
  866. * @header name:Authorization require:1 desc:Token
  867. * @param name:title type:string default:-- desc:标题
  868. * @param name:page type:int default:0 desc:页数
  869. * @param name:page_num type:int default:20 desc:每页数
  870. * @return name:title type:string default:-- desc:标题
  871. * @return name:article_id type:string default:-- desc:文章id
  872. * @return name:item_id type:string default:-- desc:item_id
  873. * @return name:cover type:string default:-- desc:封面
  874. * @return name:create_at type:string default:-- desc:时间
  875. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  876. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  877. * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】
  878. * @return name:parent_comment.content type:string default:-- desc:内容
  879. * @return name:parent_comment.name type:string default:-- desc:会员名称
  880. * @return name:parent_comment.title type:string default:-- desc:图文标题
  881. * @return name:parent_comment.article_id type:string default:-- desc:文章id
  882. * @return name:parent_comment.item_id type:string default:-- desc:item_id
  883. */
  884. public function getReplyArticle()
  885. {
  886. $user_info = $this->userInfo();
  887. $sel_where = [];
  888. $title = input('get.title');
  889. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  890. $sel_where[] = ['t.user_id','=',$this->user_id];
  891. $sel_where[] = ['t.is_deleted','=',0];
  892. $sel_where[] = ['t.lev','=',2];
  893. $list = ArticleComment::where($sel_where)
  894. ->alias('t')
  895. ->field('t.id,t.create_at,t.lev,t.content,i.title,t.pid')
  896. ->leftJoin('ArticleItem i','t.item_id = i.id')
  897. ->order('t.id desc')
  898. ->limit($this->off_set,$this->page_num)
  899. ->select()->toArray();
  900. foreach ($list as &$v) {
  901. $v['user_name'] = $user_info['name'];
  902. $v['headimg'] = $user_info['headimg'];
  903. $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]])
  904. ->field('t.id,t.article_id,t.item_id,t.content,i.title,i.cover,t.pid,u.name')
  905. ->alias('t')
  906. ->leftJoin('ArticleItem i','t.item_id = i.id')
  907. ->leftJoin('store_member u','t.user_id = u.id')
  908. ->find()->toArray();
  909. $v['parent_comment'] = $parent_comment;
  910. }
  911. $this->success('ok',['list'=>$list]);
  912. }
  913. /**
  914. * @title 回复我的【回复我的--回复过我的评论】
  915. * @desc 回复我的
  916. * @author qc
  917. * @method GET
  918. * @url /api/Article/getReplyComment
  919. * @header name:Authorization require:1 desc:Token
  920. * @param name:title type:string default:-- desc:标题
  921. * @param name:page type:int default:0 desc:页数
  922. * @param name:page_num type:int default:20 desc:每页数
  923. * @return name:title type:string default:-- desc:标题
  924. * @return name:article_id type:string default:-- desc:文章id
  925. * @return name:item_id type:string default:-- desc:item_id
  926. * @return name:cover type:string default:-- desc:封面
  927. * @return name:create_at type:string default:-- desc:时间
  928. * @return name:user_name type:string default:-- desc:用户名【其他会员】
  929. * @return name:headimg type:string default:-- desc:用户头【其他会员】
  930. * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】
  931. * @return name:parent_comment.content type:string default:-- desc:内容
  932. * @return name:parent_comment.name type:string default:-- desc:会员名称
  933. * @return name:parent_comment.title type:string default:-- desc:图文标题
  934. * @return name:parent_comment.article_id type:string default:-- desc:文章id
  935. * @return name:parent_comment.item_id type:string default:-- desc:item_id
  936. */
  937. public function getReplyComment()
  938. {
  939. $all_comment = ArticleComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  940. if(empty($all_comment)) $this->success('ok',['list'=>null]);
  941. $sel_where = [];
  942. $title = input('get.title');
  943. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  944. $sel_where[] = ['t.is_deleted','=',0];
  945. $sel_where[] = ['t.lev','=',2];
  946. $sel_where[] = ['t.user_id','<>',$this->user_id];
  947. $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
  948. $list = ArticleComment::where($sel_where)
  949. ->alias('t')
  950. ->field('t.id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg')
  951. ->leftJoin('store_member u','t.user_id = u.id')
  952. ->leftJoin('ArticleItem i','t.item_id = i.id')
  953. ->order('t.id desc')
  954. ->limit($this->off_set,$this->page_num)
  955. ->select()->toArray();
  956. foreach ($list as &$v) {
  957. $parent_comment = ArticleComment::where([['t.id','=',$v['pid']]])
  958. ->field('t.id,t.article_id,t.item_id,t.content,i.title,i.cover,t.pid,u.name')
  959. ->alias('t')
  960. ->leftJoin('ArticleItem i','t.item_id = i.id')
  961. ->leftJoin('store_member u','t.user_id = u.id')
  962. ->find()->toArray();
  963. $v['parent_comment'] = $parent_comment;
  964. }
  965. $this->success('ok',['list'=>$list]);
  966. }
  967. /**
  968. * @title 图文点赞列表【我的点赞】
  969. * @desc 图文点赞列表
  970. * @author qc
  971. * @method GET
  972. * @url /api/Article/getTagsArticle
  973. * @header name:Authorization require:1 desc:Token
  974. * @param name:title type:string default:-- desc:标题
  975. * @param name:page type:int default:0 desc:页数
  976. * @param name:page_num type:int default:20 desc:每页数
  977. * @return name:title type:string default:-- desc:标题
  978. * @return name:article_id type:string default:-- desc:文章id
  979. * @return name:item_id type:string default:-- desc:item_id
  980. * @return name:cover type:string default:-- desc:封面
  981. * @return name:is_vip type:int default:-- desc:是否vip[0否1是]
  982. * @return name:create_at type:string default:-- desc:时间
  983. * @return name:read_num type:int default:-- desc:阅读量
  984. * @return name:images_arr type:array default:-- desc:图片
  985. */
  986. public function getTagsArticle()
  987. {
  988. $sel_where = [];
  989. $title = input('get.title');
  990. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  991. $sel_where[] = ['t.user_id','=',$this->user_id];
  992. $list = ArticleLike::where($sel_where)
  993. ->alias('t')
  994. ->field('t.id,t.create_at,t.article_id,t.item_id,i.title,i.cover,i.is_vip,images,i.read_num')
  995. ->leftJoin('ArticleItem i','t.item_id = i.id')
  996. ->order('id desc')
  997. ->limit($this->off_set,$this->page_num)
  998. ->select()->toArray();
  999. foreach ($list as &$v) {
  1000. $v['images_arr'] = $v['images'] ? explode('|',$v['images']):null;
  1001. }
  1002. $this->success('ok',['list'=>$list]);
  1003. }
  1004. }