作者 郭盛
1 个管道 的构建 通过 耗费 1 秒

修改授权状态

... ... @@ -73,29 +73,80 @@ class Project extends Api
"good_num":"good_num",//点赞量
"status"://项目状态(0培育中1将收获2已收获)
"createtime":"createtime",//创建时间
"shou"://授权 0不显示1授权2已授权
}
})
*/
public function get_all()
{
// $domain_name = $this->request->domain();//域名
$page = $this->request->param('page',1,'intval');
$pageNum = $this->request->param('pageNum',10,'intval');
$farm_id = $this->request->param('farm_id');
if(empty($farm_id)){
$this->error('缺少必要参数');
}
$data = Db::name('project')
->where('farm_id',$farm_id)
->field('id,project_name,image,content,look_num,good_num,status,createtime')
->order('id desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
$v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image'];
$v['createtime'] = date('Y-m-d',$v['createtime']);
$token = $this->request->header('token');
if(empty($token)){
$page = $this->request->param('page',1,'intval');
$pageNum = $this->request->param('pageNum',10,'intval');
$farm_id = $this->request->param('farm_id');
if(empty($farm_id)){
$this->error('缺少必要参数');
}
$data = Db::name('project')
->where('farm_id',$farm_id)
->field('id,project_name,image,content,look_num,good_num,status,createtime')
->order('id desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
$v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image'];
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
$this->success('success',$data);
}else{
$user_id = $this->getUserId();
$shen = Db::name('user')->where('id',$user_id)->field('id,identity')->find();
if($shen['identity'] == 1 || $shen['identity'] == 2 || $shen['identity'] == 5){
$page = $this->request->param('page',1,'intval');
$pageNum = $this->request->param('pageNum',10,'intval');
$farm_id = $this->request->param('farm_id');
if(empty($farm_id)){
$this->error('缺少必要参数');
}
$data = Db::name('project')
->where('farm_id',$farm_id)
->field('id,project_name,image,content,look_num,good_num,status,createtime')
->order('id desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
$v['shou'] = 0;
$v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image'];
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
$this->success('success',$data);
}else{
$page = $this->request->param('page',1,'intval');
$pageNum = $this->request->param('pageNum',10,'intval');
$farm_id = $this->request->param('farm_id');
if(empty($farm_id)){
$this->error('缺少必要参数');
}
$data = Db::name('project')
->where('farm_id',$farm_id)
->field('id,project_name,image,content,look_num,good_num,status,createtime')
->order('id desc')
->page($page,$pageNum)
->select();
foreach ($data as &$v){
$impower = Db::name('impower')->where('project_id',$v['id'])->find();
if(!empty($impower)){
$v['shou'] = 1;
}else{
$v['shou'] = 2;
}
$v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image'];
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
$this->success('success',$data);
}
}
$this->success('success',$data);
}
/**
... ... @@ -1175,4 +1226,6 @@ class Project extends Api
$this->success('点赞成功');
}
}
}
\ No newline at end of file
... ...