...
|
...
|
@@ -207,6 +207,104 @@ class Farm extends Api |
|
|
*/
|
|
|
public function sou()
|
|
|
{
|
|
|
$token = $this->request->header('token');
|
|
|
if(empty($token)){
|
|
|
$page = $this->request->param('page',1,'intval');
|
|
|
$pageNum = $this->request->param('pageNum',10,'intval');
|
|
|
$param = $this->request->param();
|
|
|
if(empty($param['keyword']) && empty($param['area'])){
|
|
|
$this->error('请输入搜索关键字');
|
|
|
}
|
|
|
if(empty($param['keyword'])){
|
|
|
$data = Db::name('farm')
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->field('a.id,a.user_id,a.name,a.content,a.province,a.fun_num,b.avatar,b.score')
|
|
|
->whereLike('a.province',"%$param[area]%")
|
|
|
->order('a.createtime desc')
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
foreach ($data as &$v){
|
|
|
$is_ren = Db::name('attestation')
|
|
|
->where('farm_id',$v['id'])
|
|
|
->field('user_id,status')
|
|
|
->find();
|
|
|
if($is_ren){
|
|
|
if($is_ren['status'] == 1){
|
|
|
$v['is_ren'] = 1;
|
|
|
}else{
|
|
|
$v['is_ren'] = 2;
|
|
|
}
|
|
|
}else{
|
|
|
$v['is_ren'] = 0;
|
|
|
}
|
|
|
|
|
|
$v['status'] = 1;
|
|
|
$v['is_guan'] = 2;
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}elseif (empty($param['area'])){
|
|
|
$data = Db::name('farm')
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->field('a.id,a.user_id,a.name,a.content,a.province,a.fun_num,b.avatar,b.score')
|
|
|
->whereLike('a.name',"%$param[keyword]%")
|
|
|
->order('a.createtime desc')
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
foreach ($data as &$v){
|
|
|
$is_ren = Db::name('attestation')
|
|
|
->where('farm_id',$v['id'])
|
|
|
->field('user_id,status')
|
|
|
->find();
|
|
|
if($is_ren){
|
|
|
if($is_ren['status'] == 1){
|
|
|
$v['is_ren'] = 1;
|
|
|
}else{
|
|
|
$v['is_ren'] = 2;
|
|
|
}
|
|
|
}else{
|
|
|
$v['is_ren'] = 0;
|
|
|
}
|
|
|
|
|
|
$v['status'] = 1;
|
|
|
$v['is_guan'] = 2;
|
|
|
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}else{
|
|
|
$data = Db::name('farm')
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->field('a.id,a.user_id,a.name,a.content,a.province,a.fun_num,b.avatar,b.score')
|
|
|
->whereLike('a.name',"%$param[keyword]%")
|
|
|
->whereLike('a.province',"%$param[area]%")
|
|
|
->order('a.createtime desc')
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
foreach ($data as &$v){
|
|
|
$is_ren = Db::name('attestation')
|
|
|
->where('farm_id',$v['id'])
|
|
|
->field('user_id,status')
|
|
|
->find();
|
|
|
if($is_ren){
|
|
|
if($is_ren['status'] == 1){
|
|
|
$v['is_ren'] = 1;
|
|
|
}else{
|
|
|
$v['is_ren'] = 2;
|
|
|
}
|
|
|
}else{
|
|
|
$v['is_ren'] = 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
$v['status'] = 1;
|
|
|
$v['is_guan'] = 2;
|
|
|
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
}
|
|
|
$user_id = $this->getUserId();
|
|
|
$page = $this->request->param('page',1,'intval');
|
|
|
$pageNum = $this->request->param('pageNum',10,'intval');
|
...
|
...
|
|