正在显示
1 个修改的文件
包含
70 行增加
和
17 行删除
@@ -73,29 +73,80 @@ class Project extends Api | @@ -73,29 +73,80 @@ 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 | - $page = $this->request->param('page',1,'intval'); | ||
83 | - $pageNum = $this->request->param('pageNum',10,'intval'); | ||
84 | - $farm_id = $this->request->param('farm_id'); | ||
85 | - if(empty($farm_id)){ | ||
86 | - $this->error('缺少必要参数'); | ||
87 | - } | ||
88 | - $data = Db::name('project') | ||
89 | - ->where('farm_id',$farm_id) | ||
90 | - ->field('id,project_name,image,content,look_num,good_num,status,createtime') | ||
91 | - ->order('id desc') | ||
92 | - ->page($page,$pageNum) | ||
93 | - ->select(); | ||
94 | - foreach ($data as &$v){ | ||
95 | - $v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image']; | ||
96 | - $v['createtime'] = date('Y-m-d',$v['createtime']); | 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{ | ||
124 | + $page = $this->request->param('page',1,'intval'); | ||
125 | + $pageNum = $this->request->param('pageNum',10,'intval'); | ||
126 | + $farm_id = $this->request->param('farm_id'); | ||
127 | + if(empty($farm_id)){ | ||
128 | + $this->error('缺少必要参数'); | ||
129 | + } | ||
130 | + $data = Db::name('project') | ||
131 | + ->where('farm_id',$farm_id) | ||
132 | + ->field('id,project_name,image,content,look_num,good_num,status,createtime') | ||
133 | + ->order('id desc') | ||
134 | + ->page($page,$pageNum) | ||
135 | + ->select(); | ||
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 | + } | ||
143 | + $v['image'] = 'http://q2ugvq3qf.bkt.clouddn.com'.$v['image']; | ||
144 | + $v['createtime'] = date('Y-m-d',$v['createtime']); | ||
145 | + } | ||
146 | + $this->success('success',$data); | ||
147 | + } | ||
97 | } | 148 | } |
98 | - $this->success('success',$data); | 149 | + |
99 | } | 150 | } |
100 | 151 | ||
101 | /** | 152 | /** |
@@ -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 | } |
-
请 注册 或 登录 后发表评论