FIX check praise and watch project

dev_forge
Jasder 5 years ago
parent 0d8ed7925f
commit 406d762a7c

@ -1079,7 +1079,7 @@ curl -X DELETE http://localhost:3000/api/projects/3263/praise_tread/unlike | jq
|参数名|必选|类型|说明|
-|-|-|-
|id |是 |string |项目id |
|id |是 |int |项目id |
*返回参数说明:*
@ -1089,6 +1089,37 @@ curl -X DELETE http://localhost:3000/api/projects/3263/praise_tread/unlike | jq
|status |int|0:点赞成功,-1:操作失败2:表示还未点赞|
返回值
```
{
"status": 0,
"message": "success"
}
```
---
### 用户是否点过赞
```
GET /api/projects/:id/praise_tread/check_like
```
*示例*
```
curl -X GET http://localhost:3000/api/projects/3263/praise_tread/check_like | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|id |是 |int |项目id |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|status |int|1:已点过赞0:未点过赞, -1:请求操作失败|
返回值
```
{
@ -1207,6 +1238,37 @@ curl -X DELETE http://localhost:3000//api/projects/3263/watchers/unfollow | jq
```
---
### 用户是否关注过项目
```
GET /api/projects/:id/watchers/check_watch
```
*示例*
```
curl -X GET http://localhost:3000/api/projects/3263/watchers/check_watch | jq
```
*请求参数说明:*
|参数名|必选|类型|说明|
-|-|-|-
|id |是 |int |项目id |
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|status |int|1:已关注0:未关注, -1:请求操作失败|
返回值
```
{
"status": 0,
"message": "success"
}
```
---
### 项目的关注者列表
```
GET /api/projects/:id/watchers

@ -24,4 +24,8 @@ module RenderHelper
def render_unauthorized(message = I18n.t('error.unauthorized'))
render json: { status: 401, message: message }
end
end
def render_result(status=1, message='success')
render json: { status: status, message: message }
end
end

@ -31,4 +31,12 @@ class PraiseTreadController < ApplicationController
end
end
def check_like
is_like = current_user.liked?(@project)
render_result(is_like ? 1 : 0)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
end
end

@ -31,4 +31,12 @@ class WatchersController < ApplicationController
end
end
def check_watch
is_watch = current_user.watched?(@project)
render_result(is_watch ? 1 : 0)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
end
end

@ -63,12 +63,14 @@ Rails.application.routes.draw do
collection do
post :follow
delete :unfollow
get :check_watch
end
end
resources :praise_tread, only: [:index] do
collection do
post :like
delete :unlike
get :check_like
end
end

Loading…
Cancel
Save