...
|
...
|
@@ -211,6 +211,62 @@ class Project extends Api |
|
|
*/
|
|
|
public function detail()
|
|
|
{
|
|
|
$token = $this->request->header('token');
|
|
|
if(empty($token)){
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$data = Db::name('project')
|
|
|
->where('id',$id)
|
|
|
->find();
|
|
|
$look_num = $data['look_num']+1;
|
|
|
Db::name('project')->where('id',$id)->update(['look_num'=>$look_num]);
|
|
|
$data['image'] = explode(',',$data['image']);
|
|
|
foreach ($data['image'] as &$val){
|
|
|
$val = 'http://q2ugvq3qf.bkt.clouddn.com'.$val;
|
|
|
}
|
|
|
$data['images'] = explode(',',$data['images']);
|
|
|
foreach ($data['images'] as &$v){
|
|
|
$v = 'http://q2ugvq3qf.bkt.clouddn.com'.$v;
|
|
|
}
|
|
|
//查出项目对应的农场名称以及农场简介
|
|
|
$farm = Db::name('farm')
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->where('a.id',$data['farm_id'])
|
|
|
->field('a.id,a.name,a.content,a.province,a.city,a.address,a.user_id,b.avatar')
|
|
|
->find();
|
|
|
$data['farm_address'] = $farm['address'];
|
|
|
$data['avatar'] = $farm['avatar'];
|
|
|
$data['farm_id'] = $farm['id'];
|
|
|
$data['farm_name'] = $farm['name'];
|
|
|
$data['farm_content'] = $farm['content'];
|
|
|
|
|
|
//查看用户对该项目是否点过赞 默认都为未点赞
|
|
|
$data['is_zan'] = 1;
|
|
|
|
|
|
//查看用户是否关注过该农场 默认都为未关注
|
|
|
$data['is_guan'] = 1;
|
|
|
|
|
|
$user = Db::name('user')->where('id',$farm['user_id'])->field('identity')->find();
|
|
|
if($user['identity'] == 3){
|
|
|
$company = Db::name('company')
|
|
|
->where('user_id',$farm['user_id'])
|
|
|
->field('company_name,name')
|
|
|
->find();
|
|
|
$data['nong_name'] = $company['name'];
|
|
|
$data['company_name'] = $company['company_name'];
|
|
|
}else{
|
|
|
$company = Db::name('personage')
|
|
|
->where('user_id',$farm['user_id'])
|
|
|
->field('id,name')
|
|
|
->find();
|
|
|
$data['nong_name'] = $company['name'];
|
|
|
$data['company_name'] = '';
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
$user_id = $this->getUserId();
|
|
|
$id = $this->request->param('id');
|
|
|
if(empty($id)){
|
...
|
...
|
@@ -736,16 +792,22 @@ class Project extends Api |
|
|
$v['user_avatar'] = $user['avatar'];
|
|
|
$v['nickname'] = $user['nickname'];
|
|
|
$v['is_guan'] = 1;
|
|
|
$v['name'] = '';
|
|
|
$v['project_num'] = '';
|
|
|
$v['fun_num'] = '';
|
|
|
}else{
|
|
|
//查出关注我的用户 自己的农场信息
|
|
|
$user_farm = Db::name('farm')
|
|
|
->field('id,name,project_num,fun_num')
|
|
|
->where('user_id',$v['user_id'])
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->field('a.id,a.name,a.project_num,a.fun_num,b.avatar as user_avatar,b.nickname')
|
|
|
->where('a.user_id',$v['user_id'])
|
|
|
->find();
|
|
|
$v['name'] = $user_farm['name'];
|
|
|
$v['project_num'] = $user_farm['project_num'];
|
|
|
$v['fun_num'] = $user_farm['fun_num'];
|
|
|
|
|
|
$v['user_avatar'] = $user_farm['user_avatar'];
|
|
|
$v['nickname'] = $user_farm['nickname'];
|
|
|
$guanzhu = Db::name('guanzhu')
|
|
|
->where('user_id',$user_id)
|
|
|
->where('farm_id',$user_farm['id'])
|
...
|
...
|
|