正在显示
1 个修改的文件
包含
34 行增加
和
3 行删除
@@ -343,7 +343,6 @@ class Project extends Api | @@ -343,7 +343,6 @@ class Project extends Api | ||
343 | * @ApiSummary (项目溯源) | 343 | * @ApiSummary (项目溯源) |
344 | * @ApiMethod (POST) | 344 | * @ApiMethod (POST) |
345 | * @ApiRoute (/api/project/pro_record) | 345 | * @ApiRoute (/api/project/pro_record) |
346 | - * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
347 | * | 346 | * |
348 | * @ApiParams (name="id", type="int", required=false, description="项目id") | 347 | * @ApiParams (name="id", type="int", required=false, description="项目id") |
349 | * | 348 | * |
@@ -371,7 +370,6 @@ class Project extends Api | @@ -371,7 +370,6 @@ class Project extends Api | ||
371 | */ | 370 | */ |
372 | public function pro_record() | 371 | public function pro_record() |
373 | { | 372 | { |
374 | - $user_id = $this->getUserId(); | ||
375 | $project_id = $this->request->param('id'); | 373 | $project_id = $this->request->param('id'); |
376 | $data = Db::name('record') | 374 | $data = Db::name('record') |
377 | ->alias('a') | 375 | ->alias('a') |
@@ -1070,6 +1068,7 @@ class Project extends Api | @@ -1070,6 +1068,7 @@ class Project extends Api | ||
1070 | "project_id"://项目id | 1068 | "project_id"://项目id |
1071 | "user_id"://用户ID | 1069 | "user_id"://用户ID |
1072 | "content"://评论内容 | 1070 | "content"://评论内容 |
1071 | + "num"://评论个数 | ||
1073 | "good_name"://点赞数 | 1072 | "good_name"://点赞数 |
1074 | "createtime"://评论时间 | 1073 | "createtime"://评论时间 |
1075 | "is_zan"://是否点过赞(1否2是) | 1074 | "is_zan"://是否点过赞(1否2是) |
@@ -1078,6 +1077,38 @@ class Project extends Api | @@ -1078,6 +1077,38 @@ class Project extends Api | ||
1078 | */ | 1077 | */ |
1079 | public function commentlist() | 1078 | public function commentlist() |
1080 | { | 1079 | { |
1080 | + $token = $this->request->header('token'); | ||
1081 | + if(empty($token)){ | ||
1082 | + $param = $this->request->param(); | ||
1083 | + $validate = new Validate([ | ||
1084 | + 'farm_id' => 'require', | ||
1085 | + 'project_id' => 'require', | ||
1086 | + ]); | ||
1087 | + if (!$validate->check($param)) { | ||
1088 | + $this->error($validate->getError()); | ||
1089 | + } | ||
1090 | + $where['a.farm_id'] = $param['farm_id']; | ||
1091 | + $where['a.project_id'] = $param['project_id']; | ||
1092 | + $where['a.status'] = 2; | ||
1093 | + $data = Db::name('comment') | ||
1094 | + ->alias('a') | ||
1095 | + ->join('user b','a.user_id = b.id') | ||
1096 | + ->field('a.*,b.avatar,b.nickname,a.createtime') | ||
1097 | + ->where($where) | ||
1098 | + ->select() | ||
1099 | + ->toArray(); | ||
1100 | + $data['num'] = Db::name('comment') | ||
1101 | + ->alias('a') | ||
1102 | + ->join('user b','a.user_id = b.id') | ||
1103 | + ->field('a.*,b.avatar,b.nickname') | ||
1104 | + ->where($where) | ||
1105 | + ->count(); | ||
1106 | + foreach ($data as &$v){ | ||
1107 | + $v['is_zan'] = 1; | ||
1108 | + $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); | ||
1109 | + } | ||
1110 | + $this->success('success',$data); | ||
1111 | + } | ||
1081 | $user_id = $this->getUserId(); | 1112 | $user_id = $this->getUserId(); |
1082 | $param = $this->request->param(); | 1113 | $param = $this->request->param(); |
1083 | $validate = new Validate([ | 1114 | $validate = new Validate([ |
@@ -1093,7 +1124,7 @@ class Project extends Api | @@ -1093,7 +1124,7 @@ class Project extends Api | ||
1093 | $data = Db::name('comment') | 1124 | $data = Db::name('comment') |
1094 | ->alias('a') | 1125 | ->alias('a') |
1095 | ->join('user b','a.user_id = b.id') | 1126 | ->join('user b','a.user_id = b.id') |
1096 | - ->field('a.*,b.avatar,b.nickname') | 1127 | + ->field('a.*,b.avatar,b.nickname,a.createtime') |
1097 | ->where($where) | 1128 | ->where($where) |
1098 | ->select(); | 1129 | ->select(); |
1099 | foreach ($data as &$v){ | 1130 | foreach ($data as &$v){ |
-
请 注册 或 登录 后发表评论