123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- class Topichub extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
-
- public function lists(){
- $list = Db::name('topic_hub')->where('status',1)->order('weight desc,id desc')->autopage()->select();
- $list = list_domain_image($list,['image']);
- $this->success('success',$list);
- }
-
-
- public function info(){
- $id = input('id',0);
- $info = Db::name('topic_hub')->where(['status'=>1,'id'=>$id])->find();
- $info = info_domain_image($info,['image']);
- $this->success('success',$info);
- }
-
-
-
-
-
-
-
- public function top_list(){
- $list = Db::name('topic_hub')->field('id,name')->where(['status'=>1])->order('weight desc,p_number desc,t_number desc')->autopage()->select();
- if(empty($list)){
- $this->success('success',$list);
- }
- foreach($list as $key => $val){
- $child = Db::name('topic_dongtai')->alias('dt')
- ->field('dt.id,dt.content,dt.images,user.nickname')
- ->join('user','dt.user_id = user.id','LEFT')
- ->where('dt.topic_id',$val['id'])
- ->order('goodnum desc')->find();
- $child = info_domain_image($child,['images']);
- if(!empty($child)){
- $child['images'] = explode(',',$child['images'])[0];
- }
- $list[$key]['child'] = $child;
- }
- $this->success('success',$list);
- }
-
-
-
-
-
- public function hottopic() {
- $list = Db::name('topic_hub')->field('id, name, image, t_number, icon_type')->where('status',1)->order('weight desc,id desc')->autopage()->select();
- $list = list_domain_image($list,['image']);
- if ($list) {
- $where['a.status'] = 0;
- $where['a.auit_status'] = 1;
- $where['user.is_kefu'] = 0;
- if ($this->auth->gender == 1) {
- $where['user.gender'] = 0;
- } elseif ($this->auth->gender == 0) {
- $where['user.gender'] = 1;
- } else {
- $this->success('success', []);
- }
- $mt_topic_dongtai = Db::name('topic_dongtai a');
- foreach ($list as &$v) {
- $where['a.topic_id'] = $v['id'];
- $v['t_number'] = $mt_topic_dongtai
- ->join('mt_user user', 'a.user_id = user.id', 'left')
- ->where($where)->count('a.id');
- }
- }
- $this->success('success',$list);
- }
-
- public function hottopicinfo() {
- $id = input('id', 0, 'intval');
- $info = Db::name('topic_hub')->field('id, name, info, image, t_number, icon_type')->where(['status'=>1,'id'=>$id])->find();
- if (!$info) {
- $this->error('您的网络开小差了~');
- }
- $info = info_domain_image($info,['image']);
- if ($info) {
- $where['a.status'] = 0;
- $where['a.auit_status'] = 1;
- $where['user.is_kefu'] = 0;
- if ($this->auth->gender == 1) {
- $where['user.gender'] = 0;
- } elseif ($this->auth->gender == 0) {
- $where['user.gender'] = 1;
- } else {
- $this->success('success', []);
- }
- $mt_topic_dongtai = Db::name('topic_dongtai a');
- $where['a.topic_id'] = $info['id'];
- $info['t_number'] = $mt_topic_dongtai
- ->join('mt_user user', 'a.user_id = user.id', 'left')
- ->where($where)->count('a.id');
- }
- $this->success('success',$info);
- }
- }
|