作者 何书鹏
1 个管道 的构建 通过 耗费 12 秒

小区管理员优化

@@ -178,6 +178,10 @@ class HouseAdmin extends Api @@ -178,6 +178,10 @@ class HouseAdmin extends Api
178 empty($house_id) && $this->error('缺少必要参数'); 178 empty($house_id) && $this->error('缺少必要参数');
179 $info = HouseAdminModel::where(['user_id'=>$this->auth->id,'house_id'=>$house_id])->field('id,nickname,avatar,mobile') 179 $info = HouseAdminModel::where(['user_id'=>$this->auth->id,'house_id'=>$house_id])->field('id,nickname,avatar,mobile')
180 ->find(); 180 ->find();
  181 + if(!$info){
  182 + $admin_user_id = House::where('id',$house_id)->value('admin_user_id');
  183 + $info = HouseAdminModel::where(['id'=>$admin_user_id,'user_id'=>$this->auth->id])->field('id,nickname,avatar,mobile')->find();
  184 + }
181 $info['avatar'] = cdnurl($info['avatar'],true); 185 $info['avatar'] = cdnurl($info['avatar'],true);
182 $this->success('success',$info); 186 $this->success('success',$info);
183 } 187 }
@@ -335,11 +335,12 @@ class HouseBoard extends Api @@ -335,11 +335,12 @@ class HouseBoard extends Api
335 if(empty($house_id)){ 335 if(empty($house_id)){
336 $this->error('缺少必要参数'); 336 $this->error('缺少必要参数');
337 } 337 }
338 - 338 + $admin_user_id = Db::name('house')->where('id',$house_id)->value('admin_user_id');
339 $data = Db::name('house_admin') 339 $data = Db::name('house_admin')
340 ->alias('a') 340 ->alias('a')
341 ->join('user b','a.user_id = b.id') 341 ->join('user b','a.user_id = b.id')
342 ->where('a.house_id',$house_id) 342 ->where('a.house_id',$house_id)
  343 + ->whereOr('a.id',$admin_user_id)
343 ->field('a.user_id,b.avatar,b.nickname') 344 ->field('a.user_id,b.avatar,b.nickname')
344 ->order('a.is_direct') 345 ->order('a.is_direct')
345 ->select(); 346 ->select();