Consult.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\api\controller;
  15. use app\api\controller\Base;
  16. use think\Db;
  17. use think\Model;
  18. /**
  19. * @title 咨询管理
  20. * @controller Consult
  21. * @group member
  22. */
  23. class Consult extends Base
  24. {
  25. function initialize(){
  26. $this->check_login();
  27. }
  28. /**
  29. * @title 发布咨询
  30. * @desc 发布咨询
  31. * @author QGF
  32. * @url /api/Consult/add_consult
  33. * @method GET
  34. * @tag 发布咨询
  35. * @header name:Authorization require:1 desc:Token
  36. * @param name:content type:string require:1 default:-- desc:要咨询的问题
  37. */
  38. public function add_consult(){
  39. $uid = $this->uid;
  40. $content = input('content');
  41. if(empty($content)){
  42. $this->error('参数错误');
  43. }
  44. $data = array(
  45. 'user_id' => $uid,
  46. 'type' => 1
  47. );
  48. Db::name('store_consult')->insert($data);
  49. $consult_id = Db::name('store_consult')->getLastInsID();
  50. Db::name('store_consult')->where('id',$consult_id)->update(array('root_comment_id'=>$consult_id));
  51. $this->success('发布成功');
  52. }
  53. /**
  54. * @title 论坛列表
  55. * @desc 论坛列表
  56. * @author QGF
  57. * @url /api/Forum/forum_list
  58. * @method GET
  59. * @tag 论坛列表
  60. * @header name:Authorization require:1 desc:Token
  61. * @param name:page type:int require:0 default:1 desc:页数(默认为1)
  62. * @param name:page_size type:int require:0 default:10 desc:每页数量(默认为10)
  63. * @param name:keyword type:string require:0 default:-- desc:搜索的关键词(PC端)
  64. * @return name:user_id type:int default:-- desc:内容提供者(发布者)ID
  65. * @return name:title type:string default:-- desc:论坛标题
  66. * @return name:images type:array default:-- desc:论坛图片(数组)
  67. * @return name:create_at type:string default:-- desc:发布时间
  68. * @return name:is_like type:int default:-- desc:是否点赞(0:未点赞,1:已点赞)
  69. * @return name:is_attention type:int default:-- desc:是否关注(0:未关注,1:已关注)
  70. * @return name:user_name type:string default:-- desc:内容提供者名称
  71. * @return name:user_headimg type:string default:-- desc:内容提供者头像
  72. * @return name:ID type:int default:-- desc:论坛ID
  73. */
  74. public function forum_list(){
  75. $uid = $this->uid;
  76. $page = input('page',1);
  77. $pageSize = input('page_size',10);
  78. $keyword = input('keyword');
  79. if($keyword){
  80. $where = "title like '%".$keyword."%'";
  81. }else{
  82. $where = "id > 0";
  83. }
  84. $list = Db::name('store_forum')->field('id,user_id,title,images,create_at')->where('is_deleted',0)->where('user_id','<>',$uid)->where($where)->group('user_id')->page($page,$pageSize)->order('id','desc')->select();
  85. if($list){
  86. foreach ($list as &$value){
  87. $like_id = Db::name('store_forum_like')->where('forum_id',$value['id'])->where('user_id',$uid)->where('status',1)->value('id');
  88. $value['is_like'] = $like_id?1:0;
  89. $attention_id = Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$value['user_id'])->where('status',1)->value('id');
  90. $value['is_attention'] = $attention_id?1:0;
  91. $forum_member_info = Db::name('store_member')->field('name,headimg')->where('id',$value['user_id'])->find();
  92. $value['images'] = image_path($value['images']);
  93. $value['user_name'] = $forum_member_info['name'];
  94. $value['user_headimg'] = $forum_member_info['headimg'];
  95. $value['ID'] = $value['id'];
  96. unset($value['id']);
  97. }
  98. }
  99. $this->success('获取成功',$list);
  100. }
  101. /**
  102. * @title 论坛管理(内容提供者)
  103. * @desc 论坛管理(内容提供者)
  104. * @author QGF
  105. * @url /api/Forum/forum_manage
  106. * @method GET
  107. * @tag 论坛管理(内容提供者)
  108. * @header name:Authorization require:1 desc:Token
  109. * @param name:page type:int require:0 default:1 desc:页数(默认为1)
  110. * @param name:page_size type:int require:0 default:10 desc:每页数量(默认为10)
  111. * @return name:title type:string default:-- desc:论坛标题
  112. * @return name:images type:array default:-- desc:论坛图片(数组)
  113. * @return name:create_at type:string default:-- desc:发布时间
  114. * @return name:user_name type:string default:-- desc:内容提供者名称
  115. * @return name:user_headimg type:string default:-- desc:内容提供者头像
  116. */
  117. public function forum_manage(){
  118. $uid = $this->uid;
  119. $member_info = Db::name('store_member')->field('current_type')->where('id',$uid)->find();
  120. if($member_info['current_type'] != 2){
  121. $this->error('请切换至内容提供者');
  122. }
  123. $page = input('page',1);
  124. $pageSize = input('page_size',10);
  125. $list = Db::name('store_forum')->field('id,user_id,title,images,create_at')->where('is_deleted',0)->where('user_id',$uid)->page($page,$pageSize)->order('id','desc')->select();
  126. if($list){
  127. foreach ($list as &$value){
  128. $value['ID'] = $value['id'];
  129. $forum_member_info = Db::name('store_member')->field('name,headimg')->where('id',$value['user_id'])->find();
  130. $value['images'] = image_path($value['images']);
  131. $value['user_name'] = $forum_member_info['name'];
  132. $value['user_headimg'] = $forum_member_info['headimg'];
  133. unset($value['user_id']);
  134. unset($value['id']);
  135. }
  136. }
  137. $this->success('获取成功',$list);
  138. }
  139. /**
  140. * @title 删除论坛(內容提供者)
  141. * @desc 删除论坛
  142. * @author QGF
  143. * @url /api/Forum/deleted_forum
  144. * @method GET
  145. * @tag 删除论坛
  146. * @header name:Authorization require:1 desc:Token
  147. * @param name:id type:int require:1 default:-- desc:论坛ID
  148. */
  149. public function deleted_forum(){
  150. $uid = $this->uid;
  151. $id = input('id');
  152. if(empty($id)){
  153. $this->error('参数错误');
  154. }
  155. $member_info = Db::name('store_member')->field('current_type')->where('id',$uid)->find();
  156. if($member_info['current_type'] != 2){
  157. $this->error('请切换至内容提供者');
  158. }
  159. $forum_info = Db::name('store_forum')->field('id')->where('id',$id)->where('user_id',$uid)->where('is_deleted',0)->find();
  160. if(empty($forum_info)){
  161. $this->error('论坛信息有误');
  162. }
  163. Db::name('store_forum')->where('id',$id)->update(array('is_deleted'=>1));
  164. $this->success('删除成功');
  165. }
  166. /**
  167. * @title 论坛详情
  168. * @desc 论坛详情
  169. * @author QGF
  170. * @url /api/Forum/forum_detail
  171. * @method GET
  172. * @tag 论坛详情
  173. * @header name:Authorization require:1 desc:Token
  174. * @param name:id type:int require:1 default:-- desc:论坛ID
  175. * @return name:user_id type:int default:-- desc:内容提供者(发布者)ID
  176. * @return name:title type:string default:-- desc:论坛标题
  177. * @return name:images type:array default:-- desc:论坛图片(数组)
  178. * @return name:video type:string default:-- desc:视频地址(没有返回null)
  179. * @return name:create_at type:string default:-- desc:发布时间
  180. * @return name:is_like type:int default:-- desc:是否点赞(0:未点赞,1:已点赞)
  181. * @return name:is_attention type:int default:-- desc:是否关注(0:未关注,1:已关注)
  182. * @return name:user_name type:string default:-- desc:内容提供者名称
  183. * @return name:user_headimg type:string default:-- desc:内容提供者头像
  184. * @return name:ID type:int default:-- desc:论坛ID
  185. */
  186. public function forum_detail(){
  187. $uid = $this->uid;
  188. $id = input('id');
  189. if(empty($id)){
  190. $this->error('参数错误');
  191. }
  192. $forum_info = Db::name('store_forum')->field('id,user_id,title,images,video,create_at')->where('id',$id)->where('is_deleted',0)->find();
  193. if(empty($forum_info)){
  194. $this->error('论坛信息有误');
  195. }
  196. $like_id = Db::name('store_forum_like')->where('forum_id',$id)->where('user_id',$uid)->where('status',1)->value('id');
  197. $forum_info['is_like'] = $like_id?1:0;
  198. $attention_id = Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$forum_info['user_id'])->where('status',1)->value('id');
  199. $forum_info['is_attention'] = $attention_id?1:0;
  200. $forum_member_info = Db::name('store_member')->field('name,headimg')->where('id',$forum_info['user_id'])->find();
  201. $forum_info['images'] = image_path($forum_info['images']);
  202. $forum_info['user_name'] = $forum_member_info['name'];
  203. $forum_info['user_headimg'] = $forum_member_info['headimg'];
  204. $forum_info['ID'] = $forum_info['id'];
  205. unset($forum_info['id']);
  206. $this->success('获取成功',$forum_info);
  207. }
  208. /**
  209. * @title 点赞/取消点赞
  210. * @desc 点赞/取消点赞
  211. * @author QGF
  212. * @url /api/Forum/forum_like
  213. * @method GET
  214. * @tag 点赞/取消点赞
  215. * @header name:Authorization require:1 desc:Token
  216. * @param name:id type:int require:1 default:-- desc:论坛ID
  217. * @param name:type type:int require:1 default:-- desc:类型(0:取消点赞,1:点赞)
  218. */
  219. public function forum_like(){
  220. $uid = $this->uid;
  221. $id = input('id');
  222. $type = input('type');
  223. if(empty($id) || !isset($type)){
  224. $this->error('参数错误');
  225. }
  226. $store_forum = Db::name('store_forum')->field('user_id')->where('id',$id)->where('status',1)->where('is_deleted',0)->find();
  227. if(empty($store_forum)){
  228. $this->error('动态信息有误');
  229. }
  230. $user_id = $store_forum['user_id'];
  231. if($uid == $user_id){
  232. $this->error('不能操作自己');
  233. }
  234. $like = Db::name('store_forum_like')->where('user_id',$uid)->where('forum_id',$id)->where('user_id',$uid)->find();
  235. if($type == 0){ //取消关注
  236. if(empty($like['status'])){
  237. $this->error('没点赞无需取消');
  238. }
  239. Db::name('store_forum_like')->where('user_id',$uid)->where('forum_id',$id)->update(array('status'=>0));
  240. }else{
  241. if(!empty($like['status'])){
  242. $this->error('已点赞无需继续点赞');
  243. }
  244. if($like['id']){
  245. Db::name('store_forum_like')->where('user_id',$uid)->where('forum_id',$id)->update(array('status'=>1));
  246. }else{
  247. $data = array(
  248. 'user_id' => $uid,
  249. 'from_user_id' => $user_id,
  250. 'forum_id' => $id,
  251. 'status' => 1
  252. );
  253. Db::name('store_forum_like')->insert($data);
  254. }
  255. }
  256. $this->success('操作成功');
  257. }
  258. /**
  259. * @title 关注/取消关注
  260. * @desc 关注/取消关注
  261. * @author QGF
  262. * @url /api/Forum/forum_attention
  263. * @method GET
  264. * @tag 关注/取消关注
  265. * @header name:Authorization require:1 desc:Token
  266. * @param name:user_id type:int require:1 default:-- desc:被关注/取消关注的用户ID
  267. * @param name:type type:int require:1 default:-- desc:类型(0:取消关注,1:关注)
  268. */
  269. public function forum_attention(){
  270. $uid = $this->uid;
  271. $user_id = input('user_id');
  272. $type = input('type');
  273. if(empty($user_id) || !isset($type)){
  274. $this->error('参数错误');
  275. }
  276. if($uid == $user_id){
  277. $this->error('不能操作自己');
  278. }
  279. $attention = Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$user_id)->find();
  280. if($type == 0){ //取消关注
  281. if(empty($attention['status'])){
  282. $this->error('没关注无需取消');
  283. }
  284. Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$user_id)->update(array('status'=>0));
  285. }else{
  286. if(!empty($attention['status'])){
  287. $this->error('已关注无需继续关注');
  288. }
  289. if($attention['id']){
  290. Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$user_id)->update(array('status'=>1));
  291. }else{
  292. $data = array(
  293. 'user_id' => $uid,
  294. 'from_user_id' => $user_id,
  295. 'status' => 1
  296. );
  297. Db::name('store_forum_attention')->insert($data);
  298. }
  299. }
  300. $this->success('操作成功');
  301. }
  302. /**
  303. * @title 发表评论
  304. * @desc 发表评论
  305. * @author QGF
  306. * @url /api/Forum/forum_comment
  307. * @method GET
  308. * @tag 发表评论
  309. * @header name:Authorization require:1 desc:Token
  310. * @param name:forum_id type:int require:1 default:-- desc:论坛ID
  311. * @param name:content type:string require:1 default:-- desc:评论内容
  312. */
  313. public function forum_comment(){
  314. $uid = $this->uid;
  315. $forum_id = input('forum_id');
  316. $content = input('content');
  317. if(empty($forum_id) || empty($content)){
  318. $this->error('参数错误');
  319. }
  320. $store_forum = Db::name('store_forum')->field('user_id')->where('id',$forum_id)->where('status',1)->where('is_deleted',0)->find();
  321. if(empty($store_forum)){
  322. $this->error('动态信息有误');
  323. }
  324. $user_id = $store_forum['user_id']; //论坛作者的会员ID
  325. if($uid == $user_id){
  326. $this->error('不能操作自己');
  327. }
  328. $comment_info = Db::name('store_forum_comment')->field('id')->where('user_id',$uid)->where('forum_id',$forum_id)->where('type',1)->find();
  329. if(!empty($comment_info)){
  330. $this->error('已评论过该动态');
  331. }
  332. $comment_data = array(
  333. 'user_id' => $uid,
  334. 'from_user_id' => $user_id,
  335. 'forum_id' => $forum_id,
  336. 'content' => $content,
  337. 'type' => 1
  338. );
  339. Db::name('store_forum_comment')->insert($comment_data);
  340. $comment_id = Db::name('store_forum_comment')->getLastInsID();
  341. Db::name('store_forum_comment')->where('id',$comment_id)->update(array('root_comment_id'=>$comment_id));
  342. $this->success('评论成功');
  343. }
  344. /**
  345. * @title 回复评论(留言)
  346. * @desc 回复评论(留言)
  347. * @author QGF
  348. * @url /api/Forum/reply_comment
  349. * @method GET
  350. * @tag 回复评论(留言)
  351. * @header name:Authorization require:1 desc:Token
  352. * @param name:comment_id type:int require:1 default:-- desc:要留言的评论ID
  353. * @param name:content type:string require:1 default:-- desc:留言内容
  354. */
  355. public function reply_comment(){
  356. $uid = $this->uid;
  357. $comment_id = input('comment_id');//要回复的评论ID
  358. $content = input('content');//回复评论的内容
  359. if(empty($content) || empty($comment_id)){
  360. $this->error('参数错误');
  361. }
  362. $comment = Db::name('store_forum_comment')->field('forum_id,user_id,root_comment_id')->where('id',$comment_id)->find();
  363. if(empty($comment)){
  364. $this->error('要回复的评论不存在');
  365. }
  366. if($comment['user_id'] == $uid){
  367. $this->error('不能回复自己的评论');
  368. }
  369. //判断要是否回复过次评论了
  370. $reply_comment = Db::name('store_forum_comment')->field('id')->where('user_id',$uid)->where('type',2)->where('comment_id',$comment_id)->find();
  371. if(!empty($reply_comment)){
  372. $this->error('已回复过此评论');
  373. }
  374. $root_comment_id = $comment['root_comment_id']?$comment['root_comment_id']:$comment_id;
  375. $comment_data = array(
  376. 'forum_id' => $comment['forum_id'],
  377. 'user_id' => $uid,
  378. 'from_user_id' => $comment['user_id'],
  379. 'content' => $content,
  380. 'comment_id' => $comment_id,
  381. 'root_comment_id' => $root_comment_id,
  382. 'type' => 2
  383. );
  384. Db::name('store_forum_comment')->insert($comment_data);
  385. $this->success('留言成功');
  386. }
  387. /**
  388. * @title 评论列表
  389. * @desc 评论列表
  390. * @author QGF
  391. * @url /api/Forum/comment_list
  392. * @method GET
  393. * @tag 评论列表
  394. * @header name:Authorization require:1 desc:Token
  395. * @param name:page type:int require:0 default:1 desc:页数(默认为1)
  396. * @param name:page_size type:int require:0 default:10 desc:每页数量(默认为10)
  397. * @param name:forum_id type:int require:1 default:-- desc:论坛ID
  398. * @return name:comment_num type:int default:-- desc:评论数量
  399. * @return name:comment_list type:array default:-- desc:content:评论内容,create_time:评论时间,headimg:评论者头像,name:评论者名称,reply_comment:留言的内容列表(content:留言内容,create_time:留言时间,to_user_name:回复的人员名称,user_name:留言者名称,user_headimg:留言者头像),ID:评论ID
  400. */
  401. public function comment_list(){
  402. $forum_id = input('forum_id');
  403. $page = input('page',1);
  404. $pageSize = input('page_size',10);
  405. if(empty($forum_id)){
  406. $this->error('参数错误');
  407. }
  408. //评论列表
  409. $comment_list = Db::name('store_forum_comment')->alias("c")
  410. ->join('store_member m', 'c.user_id = m.id')
  411. ->field('c.id,c.content,c.create_time,c.root_comment_id,m.headimg,m.name')
  412. ->where('forum_id',$forum_id)->where('c.type',1)
  413. ->page($page,$pageSize)
  414. ->order('c.id desc')
  415. ->select();
  416. if(empty($comment_list)){
  417. $this->success('暂无评论',array());
  418. }
  419. foreach ($comment_list as &$value){
  420. //查看回复评论
  421. $value['reply_comment'] = Db::name('store_forum_comment')->field('user_id,content,comment_id,create_time')->where('root_comment_id',$value['root_comment_id'])->where('type',2)->select();
  422. if($value['reply_comment']){
  423. foreach ($value['reply_comment'] as &$v){
  424. $to_user_id = Db::name('store_forum_comment')->where('id',$v['comment_id'])->value('user_id');
  425. $v['to_user_name'] = Db::name('store_member')->where('id',$to_user_id)->value('name');
  426. $user_info = Db::name('store_member')->field('name,headimg')->where('id',$v['user_id'])->find();
  427. $v['user_name'] = $user_info['name'];
  428. $v['user_headimg'] = $user_info['headimg'];
  429. unset($v['comment_id']);
  430. unset($v['user_id']);
  431. }
  432. }
  433. $value['ID'] = $value['id'];
  434. unset($value['id']);
  435. unset($value['root_comment_id']);
  436. }
  437. $data = array(
  438. 'comment_num' => Db::name('store_forum_comment')->where('forum_id',$forum_id)->where('type',1)->count('id'),
  439. 'comment_list' => $comment_list
  440. );
  441. $this->success('获取成功',$data);
  442. }
  443. /**
  444. * @title 论坛发布者详情(用户端)
  445. * @desc 论坛发布者详情(用户端)
  446. * @author QGF
  447. * @url /api/Forum/forum_master
  448. * @method GET
  449. * @tag 论坛发布者详情(用户端)
  450. * @header name:Authorization require:1 desc:Token
  451. * @param name:user_id type:int require:1 default:-- desc:论坛发布者ID
  452. * @return name:headimg type:string default:-- desc:发布者头像
  453. * @return name:name type:string default:-- desc:发布者名称
  454. * @return name:is_like type:int default:-- desc:是否点赞(0:未点赞,1:已点赞)
  455. * @return name:is_attention type:int default:-- desc:是否关注(0:未关注,1:已关注)
  456. * @return name:forum_list type:array default:-- desc:user_id:发布者ID,title:论坛标题,images:评论图片(数组),create_at:发布时间,is_like:是否点赞(0:未点赞,1:已点赞),user_name:发布者名称,user_headimg:发布者头像,ID:论坛ID
  457. */
  458. public function forum_master(){
  459. $uid = $this->uid;
  460. $user_id = input('user_id');
  461. if(empty($user_id)){
  462. $this->error('参数错误');
  463. }
  464. if($uid == $user_id){
  465. $this->error('不能操作自己');
  466. }
  467. //查看是否已关注
  468. $is_attention = Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$user_id)->where('status',1)->count();
  469. //关注数量
  470. $attention_num = Db::name('store_forum_attention')->where('from_user_id',$user_id)->where('status',1)->count();
  471. //点赞数量
  472. $like_num = Db::name('store_forum_like')->where('from_user_id',$user_id)->where('status',1)->count();
  473. //动态列表
  474. $field = 'id,user_id,title,images,create_at';
  475. $forum_list = Db::name('store_forum')->field($field)->where('user_id',$user_id)->where('status',1)->where('is_deleted',0)->order('id desc')->select();
  476. $member = Db::name('store_member')->field('headimg,name')->where('id',$user_id)->find();
  477. $name = $member['name'];
  478. $headimg = $member['headimg'];
  479. foreach ($forum_list as &$value){
  480. $like_id = Db::name('store_forum_like')->where('forum_id',$value['id'])->where('user_id',$uid)->where('status',1)->value('id');
  481. $value['is_like'] = $like_id?1:0;
  482. $value['images'] = image_path($value['images']);
  483. $value['user_name'] = $name;
  484. $value['user_headimg'] = $headimg;
  485. $value['ID'] = $value['id'];
  486. unset($value['id']);
  487. }
  488. $data = array(
  489. 'headimg' => $headimg,
  490. 'name' => $name,
  491. 'is_attention' => $is_attention,
  492. 'attention_num' => $attention_num,
  493. 'like_num' => $like_num,
  494. 'forum_list' => $forum_list
  495. );
  496. $this->success('获取成功',$data);
  497. }
  498. /**
  499. * @title 我的关注
  500. * @desc 我的关注
  501. * @author QGF
  502. * @url /api/Forum/my_attention
  503. * @method GET
  504. * @tag 我的关注
  505. * @header name:Authorization require:1 desc:Token
  506. * @param name:page type:int require:0 default:1 desc:页数(默认为1)
  507. * @param name:page_size type:int require:0 default:10 desc:每页数量(默认为10)
  508. * @param name:keyword type:string require:0 default:-- desc:搜索的关键词(PC端)
  509. * @return name:user_id type:int default:-- desc:内容提供者(发布者)ID
  510. * @return name:title type:string default:-- desc:论坛标题
  511. * @return name:images type:array default:-- desc:论坛图片(数组)
  512. * @return name:create_at type:string default:-- desc:发布时间
  513. * @return name:is_like type:int default:-- desc:是否点赞(0:未点赞,1:已点赞)
  514. * @return name:is_attention type:int default:-- desc:是否关注(0:未关注,1:已关注)
  515. * @return name:user_name type:string default:-- desc:内容提供者名称
  516. * @return name:user_headimg type:string default:-- desc:内容提供者头像
  517. * @return name:ID type:int default:-- desc:论坛ID
  518. */
  519. public function my_attention(){
  520. $uid = $this->uid;
  521. $page = input('page',1);
  522. $pageSize = input('page_size',10);
  523. $user_id_arr = Db::name('store_forum_attention')->where('user_id',$uid)->where('status',1)->column('from_user_id');
  524. $list = Db::name('store_forum')->field('id,user_id,title,images,create_at')->where('is_deleted',0)->where('user_id','in',$user_id_arr)->group('user_id')->page($page,$pageSize)->order('id','desc')->select();
  525. if($list){
  526. foreach ($list as &$value){
  527. $like_id = Db::name('store_forum_like')->where('forum_id',$value['id'])->where('user_id',$uid)->where('status',1)->value('id');
  528. $value['is_like'] = $like_id?1:0;
  529. $attention_id = Db::name('store_forum_attention')->where('user_id',$uid)->where('from_user_id',$value['user_id'])->where('status',1)->value('id');
  530. $value['is_attention'] = $attention_id?1:0;
  531. $forum_member_info = Db::name('store_member')->field('name,headimg')->where('id',$value['user_id'])->find();
  532. $value['images'] = image_path($value['images']);
  533. $value['user_name'] = $forum_member_info['name'];
  534. $value['user_headimg'] = $forum_member_info['headimg'];
  535. $value['ID'] = $value['id'];
  536. unset($value['id']);
  537. }
  538. }
  539. $this->success('获取成功',$list);
  540. }
  541. }