正在显示
1 个修改的文件
包含
54 行增加
和
1 行删除
@@ -73,12 +73,54 @@ class Project extends Api | @@ -73,12 +73,54 @@ class Project extends Api | ||
73 | "good_num":"good_num",//点赞量 | 73 | "good_num":"good_num",//点赞量 |
74 | "status"://项目状态(0培育中1将收获2已收获) | 74 | "status"://项目状态(0培育中1将收获2已收获) |
75 | "createtime":"createtime",//创建时间 | 75 | "createtime":"createtime",//创建时间 |
76 | + "shou"://授权 0不显示1授权2已授权 | ||
76 | } | 77 | } |
77 | }) | 78 | }) |
78 | */ | 79 | */ |
79 | public function get_all() | 80 | public function get_all() |
80 | { | 81 | { |
81 | -// $domain_name = $this->request->domain();//域名 | 82 | + $token = $this->request->header('token'); |
83 | + if(empty($token)){ | ||
84 | + $page = $this->request->param('page',1,'intval'); | ||
85 | + $pageNum = $this->request->param('pageNum',10,'intval'); | ||
86 | + $farm_id = $this->request->param('farm_id'); | ||
87 | + if(empty($farm_id)){ | ||
88 | + $this->error('缺少必要参数'); | ||
89 | + } | ||
90 | + $data = Db::name('project') | ||
91 | + ->where('farm_id',$farm_id) | ||
92 | + ->field('id,project_name,image,content,look_num,good_num,status,createtime') | ||
93 | + ->order('id desc') | ||
94 | + ->page($page,$pageNum) | ||
95 | + ->select(); | ||
96 | + foreach ($data as &$v){ | ||
97 | + $v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image']; | ||
98 | + $v['createtime'] = date('Y-m-d',$v['createtime']); | ||
99 | + } | ||
100 | + $this->success('success',$data); | ||
101 | + }else{ | ||
102 | + $user_id = $this->getUserId(); | ||
103 | + $shen = Db::name('user')->where('id',$user_id)->field('id,identity')->find(); | ||
104 | + if($shen['identity'] == 1 || $shen['identity'] == 2 || $shen['identity'] == 5){ | ||
105 | + $page = $this->request->param('page',1,'intval'); | ||
106 | + $pageNum = $this->request->param('pageNum',10,'intval'); | ||
107 | + $farm_id = $this->request->param('farm_id'); | ||
108 | + if(empty($farm_id)){ | ||
109 | + $this->error('缺少必要参数'); | ||
110 | + } | ||
111 | + $data = Db::name('project') | ||
112 | + ->where('farm_id',$farm_id) | ||
113 | + ->field('id,project_name,image,content,look_num,good_num,status,createtime') | ||
114 | + ->order('id desc') | ||
115 | + ->page($page,$pageNum) | ||
116 | + ->select(); | ||
117 | + foreach ($data as &$v){ | ||
118 | + $v['shou'] = 0; | ||
119 | + $v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image']; | ||
120 | + $v['createtime'] = date('Y-m-d',$v['createtime']); | ||
121 | + } | ||
122 | + $this->success('success',$data); | ||
123 | + }else{ | ||
82 | $page = $this->request->param('page',1,'intval'); | 124 | $page = $this->request->param('page',1,'intval'); |
83 | $pageNum = $this->request->param('pageNum',10,'intval'); | 125 | $pageNum = $this->request->param('pageNum',10,'intval'); |
84 | $farm_id = $this->request->param('farm_id'); | 126 | $farm_id = $this->request->param('farm_id'); |
@@ -92,11 +134,20 @@ class Project extends Api | @@ -92,11 +134,20 @@ class Project extends Api | ||
92 | ->page($page,$pageNum) | 134 | ->page($page,$pageNum) |
93 | ->select(); | 135 | ->select(); |
94 | foreach ($data as &$v){ | 136 | foreach ($data as &$v){ |
137 | + $impower = Db::name('impower')->where('project_id',$v['id'])->find(); | ||
138 | + if(!empty($impower)){ | ||
139 | + $v['shou'] = 1; | ||
140 | + }else{ | ||
141 | + $v['shou'] = 2; | ||
142 | + } | ||
95 | $v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image']; | 143 | $v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image']; |
96 | $v['createtime'] = date('Y-m-d',$v['createtime']); | 144 | $v['createtime'] = date('Y-m-d',$v['createtime']); |
97 | } | 145 | } |
98 | $this->success('success',$data); | 146 | $this->success('success',$data); |
99 | } | 147 | } |
148 | + } | ||
149 | + | ||
150 | + } | ||
100 | 151 | ||
101 | /** | 152 | /** |
102 | * @ApiTitle (添加项目) | 153 | * @ApiTitle (添加项目) |
@@ -1175,4 +1226,6 @@ class Project extends Api | @@ -1175,4 +1226,6 @@ class Project extends Api | ||
1175 | $this->success('点赞成功'); | 1226 | $this->success('点赞成功'); |
1176 | } | 1227 | } |
1177 | } | 1228 | } |
1229 | + | ||
1230 | + | ||
1178 | } | 1231 | } |
-
请 注册 或 登录 后发表评论