1 个管道
的构建
通过
耗费
0 秒
更新 CardController.php
正在显示
1 个修改的文件
包含
18 行增加
和
3 行删除
@@ -66,7 +66,7 @@ class CardController extends RestBaseController | @@ -66,7 +66,7 @@ class CardController extends RestBaseController | ||
66 | if($data['keyword']) { | 66 | if($data['keyword']) { |
67 | $condition['c.is_recommend'] = 1;//后台推荐 | 67 | $condition['c.is_recommend'] = 1;//后台推荐 |
68 | $condition['c.name|company|tel'] = ['like','%'.$data['keyword'].'%']; | 68 | $condition['c.name|company|tel'] = ['like','%'.$data['keyword'].'%']; |
69 | - $condition2['c.name|company|tel'] = ['like','%'.$data['keyword'].'%','and']; | 69 | + $condition2['c.name|company|tel'] = ['like','%'.$data['keyword'].'%']; |
70 | //搜索日志 | 70 | //搜索日志 |
71 | $info = Db::name('search')->where(['keyword' => $data['keyword']])->find(); | 71 | $info = Db::name('search')->where(['keyword' => $data['keyword']])->find(); |
72 | if ($info) { | 72 | if ($info) { |
@@ -85,14 +85,29 @@ class CardController extends RestBaseController | @@ -85,14 +85,29 @@ class CardController extends RestBaseController | ||
85 | } | 85 | } |
86 | $condition = $condition == '' ? '' : $condition; | 86 | $condition = $condition == '' ? '' : $condition; |
87 | $condition2['c.id'] = ['in',$ids]; | 87 | $condition2['c.id'] = ['in',$ids]; |
88 | - $result = Db::name('card') | 88 | + if($data['keyword']) { |
89 | + $where = "SELECT `c`.`id`,`c`.`name`,`c`.`position`,`c`.`tel`,`c`.`home_tel`,`c`.`email`,`c`.`company`,`u`.`avatar`,IF(c.user_id='.$this->userId.',`c`.`user_id`,0) top FROM `bro_card` `c` LEFT JOIN `bro_user` `u` ON `c`.`user_id`=`u`.`id` | ||
90 | +WHERE `c`.`is_recommend` = 1 AND ( `c`.`name` LIKE '%".$data['keyword']."%' OR `company` LIKE '%".$data['keyword']."%' OR `tel` LIKE '%".$data['keyword']."%' ) | ||
91 | + OR ( (`c`.`name` LIKE '%".$data['keyword']."%' OR `company` LIKE '%".$data['keyword']."%' OR `tel` LIKE '%".$data['keyword']."%') and `c`.`id` IN $ids) | ||
92 | +ORDER BY top desc,c.create_time desc"; | ||
93 | + $result = Db::name('card') | ||
94 | + ->alias('c') | ||
95 | + ->join('user u','c.user_id=u.id','left') | ||
96 | + ->where() | ||
97 | + ->field('c.id,c.name,c.position,c.tel,c.home_tel,c.email,c.company,u.avatar,IF(c.user_id='.$this->userId.',c.user_id,0) top') | ||
98 | + ->order('top desc,c.create_time desc') | ||
99 | + ->paginate($per_page); | ||
100 | + } else { | ||
101 | + $result = Db::name('card') | ||
89 | ->alias('c') | 102 | ->alias('c') |
90 | ->join('user u','c.user_id=u.id','left') | 103 | ->join('user u','c.user_id=u.id','left') |
91 | ->where($condition) | 104 | ->where($condition) |
92 | ->whereOr($condition2) | 105 | ->whereOr($condition2) |
93 | ->field('c.id,c.name,c.position,c.tel,c.home_tel,c.email,c.company,u.avatar,IF(c.user_id='.$this->userId.',c.user_id,0) top') | 106 | ->field('c.id,c.name,c.position,c.tel,c.home_tel,c.email,c.company,u.avatar,IF(c.user_id='.$this->userId.',c.user_id,0) top') |
94 | ->order('top desc,c.create_time desc') | 107 | ->order('top desc,c.create_time desc') |
95 | - ->select(false); | 108 | + ->paginate($per_page); |
109 | + } | ||
110 | + | ||
96 | $this->success('获取成功',$result); | 111 | $this->success('获取成功',$result); |
97 | if ($result === false) { | 112 | if ($result === false) { |
98 | $this->error(['code'=>'40000','msg'=>'获取失败']); | 113 | $this->error(['code'=>'40000','msg'=>'获取失败']); |
-
请 注册 或 登录 后发表评论