123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 圈子中心
- */
- class Topichub extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = ['*'];
- //全部话题,和下面hottopic重复了,就t_number是全部的,不分性别
- 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);
- }
- //没用到,和下面的hottopicinfo重复了
- /*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 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; //是否已删除:0=否,1=是
- $where['a.auit_status'] = 1; //审核状态:0=待审核,1=通过,2=拒绝
- $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'); //热门话题id
- $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; //是否已删除:0=否,1=是
- $where['a.auit_status'] = 1; //审核状态:0=待审核,1=通过,2=拒绝
- $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);
- }
- }
|