News.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\api\controller\zzz;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. *
  7. */
  8. class News extends Api
  9. {
  10. protected $noNeedLogin = ['*'];
  11. protected $noNeedRight = ['*'];
  12. //分类
  13. public function typelist()
  14. {
  15. $list = Db::name('zzz_newstype')->field('id, name')->select();
  16. $this->success(1, $list);
  17. }
  18. public function newslist(){
  19. $type_id = input('type_id',0);
  20. //是否屏蔽
  21. $map = [];
  22. if($this->auth->isLogin()){
  23. $screen_ids = Db::name('zzz_news_screen')->where('user_id',$this->auth->id)->column('news_id');
  24. if(!empty($screen_ids)){
  25. $map['id'] = ['NOTIN',$screen_ids];
  26. }
  27. }
  28. $list = Db::name('zzz_news')->field('content',true)->where('type_id',$type_id)->where($map)->autopage()->select();
  29. $list = list_domain_image($list,['image']);
  30. $this->success(1, $list);
  31. }
  32. public function newsinfo(){
  33. $id = input('id',0);
  34. $info = Db::name('zzz_news')->where('id',$id)->find();
  35. $info = info_domain_image($info,['image']);
  36. $this->success(1, $info);
  37. }
  38. //举报
  39. public function report(){
  40. $this->success('举报成功,客服人员即将处理');
  41. }
  42. //不感兴趣
  43. public function screen(){
  44. $id = input('id',0);
  45. $data = [
  46. 'news_id' => $id,
  47. 'user_id' => $this->auth->id,
  48. ];
  49. Db::name('zzz_news_screen')->insertGetId($data);
  50. $this->success();
  51. }
  52. }