diff --git a/README.md b/README.md index 688dda462..caa4f754f 100644 --- a/README.md +++ b/README.md @@ -379,49 +379,342 @@ http://localhost:3000/api/projects/migrate | jq ``` --- +#### 项目类别列表(用于项目列表左侧导航中的项目类别列表) +``` +GET api/project_categories/group_list +``` +*示例* +``` +curl -X GET http://localhost:3000/api/project_categories/group_list | jq +``` + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|id |int |项目分类id | +|name |string|项目分类名称| +|projects_count |int |项目数量| + + +返回值 +``` +[ + { + "id": 1, + "name": "大数据", + "projects_count": 30 + }, + { + "id": 2, + "name": "机器学习", + "projects_count": 1 + }, + { + "id": 3, + "name": "深度学习", + "projects_count": 1 + } +] +``` +--- + +#### 项目类型列表(用于项目列表左侧导航上方中的项目类型列表) +``` +GET api/projects/group_type_list +``` +*示例* +``` +curl -X GET http://localhost:3000/api/projects/group_type_list | jq +``` + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|project_type |string|项目类型 | +|name |string|项目类型名称| +|projects_count |int |项目数量| + + +返回值 +``` +[ + { + "project_type": "common", + "name": "开源托管项目", + "projects_count": 2106 + }, + { + "project_type": "mirror", + "name": "开源镜像项目", + "projects_count": 1 + } +] +``` +--- + #### 项目列表 ``` GET api/projects ``` *示例* ``` -curl -X POST \ --d "user_id=36401" \ --d "clone_addr=https://gitea.com/CasperVector/slew.git" \ --d "name=ni项目" \ --d "description=my first project" \ --d "repository_name=mirror_demo" \ --d "project_category_id=1" \ --d "project_language_id=2" \ -http://localhost:3000/api/projects/migrate | jq +curl -X GET \ +-d "page=1" \ +-d "limit=5" \ +http://localhost:3000/api/projects | jq ``` *请求参数说明:* |参数名|必选|类型|说明| -|-|-|- -|user_id |是|int |用户id或者组织id | -|name |是|string |项目名称 | -|clone_addr |是|string |镜像项目clone地址 | -|description |否|string |项目描述 | -|repository_name |是|string |仓库名称, 只含有数字、字母、下划线不能以下划线开头和结尾,且唯一 | -|project_category_id|是|int |项目类别id | -|project_language_id|是|int |项目语言id | -|private |否|boolean|项目是否私有, true:为私有,false: 非私有,默认为公开 | +|page |否|string |页数,第几页 | +|limit |否|string |每页多少条数据,默认15条 | +|sort_by |否|string |排序类型 | +|sort_direction|否|string |排序方式,取值为: desc \| asc; desc: 降序排序, asc: 升序排序, 默认为:desc | +|name |否|string |项目名称, 按照项目名称搜索 | +|category_id |否|int |项目类别id | +|language_id |否|int |项目语言id | +|project_type |否|string |项目类型, 取值为:common \| mirror; common:开源托管项目, mirror:开源镜像项目 | *返回参数说明:* |参数名|类型|说明| -|-|- -|id |int |id | +|id |string |项目标识 | |name |string|项目名称| +|description |string|项目简介| +|visits |int|流量数| +|forked_count |int|被fork的数量| +|is_public |boolean|是否公开, true:公开,false:未公开| +|mirror_url |string|镜像url| +|last_update_time |int|最后更新时间,为UNIX格式的时间戳| +|author |object|项目创建者| +|-- name |string|用户名,也是用户标识| +|category |object|项目类别| +|-- id |int|项目类型id| +|-- name |string|项目类型名称| +|language |object|项目语言| +|-- id |int|项目语言id| +|-- name |string|项目语言名称| + + + +返回值 +``` +[ + { + "id": "tongjj", + "name": "统计局", + "description": "my first project", + "visits": 0, + "forked_count": 0, + "is_public": true, + "mirror_url": null, + "last_update_time": 1577415173, + "author": { + "name": "18816895620" + }, + "category": { + "id": 1, + "name": "大数据" + }, + "language": { + "id": 2, + "name": "C" + } + }, + { + "id": null, + "name": "开源同名", + "description": "my first project", + "visits": 0, + "forked_count": 0, + "is_public": false, + "mirror_url": "https://gitea.com/CasperVector/slew.git", + "last_update_time": 1577346228, + "author": { + "name": "18816895620" + }, + "category": { + "id": 1, + "name": "大数据" + }, + "language": { + "id": 2, + "name": "C" + } + }, + { + "id": "mvp_demo", + "name": "开源支持", + "description": "my first project", + "visits": 0, + "forked_count": 0, + "is_public": true, + "mirror_url": null, + "last_update_time": 1577341572, + "author": { + "name": "18816895620" + }, + "category": { + "id": 1, + "name": "大数据" + }, + "language": { + "id": 2, + "name": "C" + } + }, + { + "id": null, + "name": "ni项目1", + "description": "my first project", + "visits": 0, + "forked_count": 0, + "is_public": true, + "mirror_url": "https://gitea.com/CasperVector/slew.git", + "last_update_time": 1577092908, + "author": { + "name": "18816895620" + }, + "category": { + "id": 1, + "name": "大数据" + }, + "language": { + "id": 2, + "name": "C" + } + }, + { + "id": "mirror_demo", + "name": "ni项目", + "description": "my first project", + "visits": 0, + "forked_count": 0, + "is_public": false, + "mirror_url": "https://gitea.com/CasperVector/slew.git", + "last_update_time": 1577085412, + "author": { + "name": "18816895620" + }, + "category": { + "id": 1, + "name": "大数据" + }, + "language": { + "id": 2, + "name": "C" + } + } +] +``` +--- + +### 获取分支列表 +``` +GET /api/projects/:identifier/branches +``` +*示例* +``` +curl -X GET http://localhost:3000/api/projects/mirror_demo/branches | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|identifier |是|string |项目标识 | + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|name |string|分支名称| + + +返回值 +``` +[ + { + "name": "develop" + }, + { + "name": "master" + } +] +``` +--- + +### 点赞 +``` +POST /api/praise_tread/like +``` +*示例* +``` +curl -X POST \ +-d 'object_id=1' \ +-d 'object_type=project' \ +http://localhost:3000/api/praise_tread/like | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|object_id |是 |int |项目id | +|object_type |否 |string | 点赞类型,默认为project| + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|status |int|0:点赞成功,-1:操作失败,2:表示已经点过赞了| 返回值 ``` { - "id": 3263, - "name": "ni项目" + "status": 0, + "message": "响应成功" +} +``` +--- + +### 取消点赞 +``` +DELETE /api/praise_tread/unlike +``` +*示例* +``` +curl -X DELETE \ +-d 'object_id=1' \ +-d 'object_type=project' \ +http://localhost:3000/api/praise_tread/unlike | jq +``` +*请求参数说明:* + +|参数名|必选|类型|说明| +-|-|-|- +|object_id |是 |string |点赞对象的唯一标识,如项目的identifier字段 | +|object_type |是 |string | 点赞类型,默认为project| + + +*返回参数说明:* + +|参数名|类型|说明| +-|-|- +|status |int|0:点赞成功,-1:操作失败,2:表示还未点赞| + + +返回值 +``` +{ + "status": 0, + "message": "响应成功" } ``` ---