123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\api\controller\zzz;
- use app\common\controller\Api;
- use think\Db;
- /**
- *
- */
- class News extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- //分类
- public function typelist()
- {
- $list = Db::name('zzz_newstype')->field('id, name')->select();
- $this->success(1, $list);
- }
- public function newslist(){
- $type_id = input('type_id',0);
- //是否屏蔽
- $map = [];
- if($this->auth->isLogin()){
- $screen_ids = Db::name('zzz_news_screen')->where('user_id',$this->auth->id)->column('news_id');
- if(!empty($screen_ids)){
- $map['id'] = ['NOTIN',$screen_ids];
- }
- }
- $list = Db::name('zzz_news')->field('content',true)->where('type_id',$type_id)->where($map)->autopage()->select();
- $list = list_domain_image($list,['image']);
- $this->success(1, $list);
- }
- public function newsinfo(){
- $id = input('id',0);
- $info = Db::name('zzz_news')->where('id',$id)->find();
- $info = info_domain_image($info,['image']);
- $this->success(1, $info);
- }
- //举报
- public function report(){
- $this->success('举报成功,客服人员即将处理');
- }
- //不感兴趣
- public function screen(){
- $id = input('id',0);
- $data = [
- 'news_id' => $id,
- 'user_id' => $this->auth->id,
- ];
- Db::name('zzz_news_screen')->insertGetId($data);
- $this->success();
- }
- }
|