diff --git a/app/api/controller/Resource.php b/app/api/controller/Resource.php index 9e02c07..20929f9 100644 --- a/app/api/controller/Resource.php +++ b/app/api/controller/Resource.php @@ -47,4 +47,16 @@ class Resource extends Api $detail = ResourceLogic::detail($id,$this->user_id); return JsonServer::success('获取成功', $detail); } + + /** + * @Notes: 文章详细 + * @Author: 张无忌 + */ + public function downloadLog() + { + $id = $this->request->get('id'); + $detail = ResourceLogic::downloadLog($id,$this->user_id); + return JsonServer::success('获取成功', ["data"=>$detail]); + } + } \ No newline at end of file diff --git a/app/api/logic/ResourceLogic.php b/app/api/logic/ResourceLogic.php index 68587bf..a53aa4e 100644 --- a/app/api/logic/ResourceLogic.php +++ b/app/api/logic/ResourceLogic.php @@ -161,6 +161,7 @@ class ResourceLogic extends Logic } $article['goodsType'] = $goodsType; + $article['path'] = $article['path']?UrlServer::getFileUrl($article['path']):''; $article['address'] = $article['province_id']?AreaServer::getAddress([ $article['province_id'], @@ -171,4 +172,32 @@ class ResourceLogic extends Logic return $article; } + + /** + * @Notes: 文章详细 + * @Author: 张无忌 + * @param $id + * @return int + */ + public static function downloadLog($id,$uid) + { + $article = Resource::field('*')->where('id', $id)->findOrEmpty(); + if($article->isEmpty()) { + return 0; + }else{ + $article->download = $article->download + 1; + $article->save(); + + //下载记录 + $userResource = []; + $userResource['user_id'] = $uid; + $userResource['resource_id'] = $id; + $userResource['type'] = 0; + $userResource['create_time'] = time(); + $userResourceModel = new UserResource(); + $userResourceModel->insert($userResource); + return 1; + } + } + } \ No newline at end of file