新增: 更新文档

This commit is contained in:
yystopf 2022-06-24 11:04:16 +08:00
parent 211581cef0
commit b59b76be4a
4 changed files with 667 additions and 561 deletions

View File

@ -1139,7 +1139,6 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
|url |string|地址|
|http_method |string|请求方式|
|is_active |bool |是否激活|
|type |string|类型|
|last_status |string|最后一次推送的状态|
|create_time |string|创建时间|
@ -1155,7 +1154,6 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
"url": "https://oapi.dingtalk.com/robot/send?access_token=7e1e19d0eddb6a5e33c5c2c4e66f4c88f9437184b9ed2c2653194c6374c7d513",
"http_method": "",
"is_active": true,
"type": "dingtalk",
"last_status": "succeed",
"create_time": "2021-07-12 10:50:07"
},
@ -1164,7 +1162,6 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
"url": "http://localhost:3000",
"http_method": "GET",
"is_active": true,
"type": "gitea",
"last_status": "succeed",
"create_time": "2021-07-26 10:03:45"
},
@ -1173,7 +1170,6 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
"url": "http://localhost:10081",
"http_method": "POST",
"is_active": true,
"type": "gitea",
"last_status": "waiting",
"create_time": "2021-07-26 16:56:53"
},
@ -1182,7 +1178,6 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
"url": "http://localhost:3001",
"http_method": "POST",
"is_active": true,
"type": "gitea",
"last_status": "fail",
"create_time": "2021-07-26 16:58:23"
}
@ -1236,24 +1231,11 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3.json')
--------- | ------- | ------- |
|create|创建分支或标签|
|delete|分支或标签删除|
|fork|仓库被fork|
|push|git仓库推送|
|issue|疑修已打开、已关闭、已重新打开或编辑|
|issue_assign|疑修被指派|
|issue_label|疑修标签被更新或删除|
|issue_milestone|疑修被收入里程碑|
|issue_comment|疑修评论|
|pull_request|合并请求|
|pull_request_assign|合并请求被指派|
|pull_request_label|合并请求被贴上标签|
|pull_request_milestone|合并请求被记录于里程碑中|
|pull_request_comment|合并请求被评论|
|pull_request_review_approved|合并请求被批准|
|pull_request_review_rejected|合并请求被拒绝|
|pull_request_review_comment|合并请求被提出审查意见|
|pull_request_sync|合并请求被同步|
|repository|创建或删除仓库|
|release|版本发布|
> 返回的JSON示例:
@ -1270,22 +1252,9 @@ await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3.json')
"events": [
"create",
"delete",
"fork",
"issues",
"issue_assign",
"issue_label",
"issue_milestone",
"issue_comment",
"push",
"pull_request",
"pull_request_assign",
"pull_request_label",
"pull_request_milestone",
"pull_request_comment",
"pull_request_review",
"pull_request_sync",
"repository",
"release"
]
}
```
@ -1329,24 +1298,11 @@ await octokit.request('POST /api/v1/yystopf/ceshi/webhooks.json')
--------- | ------- | ------- |
|create|创建分支或标签|
|delete|分支或标签删除|
<!-- |fork|仓库被fork| -->
|push|git仓库推送|
<!-- |issue|疑修已打开、已关闭、已重新打开或编辑|
|issue_assign|疑修被指派|
|issue_label|疑修标签被更新或删除|
|issue_milestone|疑修被收入里程碑|
|issue_comment|疑修评论| -->
|pull_request|合并请求|
|pull_request_assign|合并请求被指派|
<!-- |pull_request_label|合并请求被贴上标签|
|pull_request_milestone|合并请求被记录于里程碑中|
|pull_request_comment|合并请求被评论| -->
|pull_request_review_approved|合并请求被批准|
|pull_request_review_rejected|合并请求被拒绝|
<!-- |pull_request_review_comment|合并请求被提出审查意见|
|pull_request_sync|合并请求被同步|
|repository|创建或删除仓库|
|release|版本发布| -->
> 请求的JSON示例:
@ -1438,24 +1394,11 @@ await octokit.request('PATCH /api/v1/yystopf/ceshi/webhooks/7.json')
--------- | ------- | ------- |
|create|创建分支或标签|
|delete|分支或标签删除|
<!-- |fork|仓库被fork| -->
|push|git仓库推送|
<!-- |issue|疑修已打开、已关闭、已重新打开或编辑|
|issue_assign|疑修被指派|
|issue_label|疑修标签被更新或删除|
|issue_milestone|疑修被收入里程碑|
|issue_comment|疑修评论| -->
|pull_request|合并请求|
|pull_request_assign|合并请求被指派|
<!-- |pull_request_label|合并请求被贴上标签|
|pull_request_milestone|合并请求被记录于里程碑中|
|pull_request_comment|合并请求被评论| -->
|pull_request_review_approved|合并请求被批准|
|pull_request_review_rejected|合并请求被拒绝|
<!-- |pull_request_review_comment|合并请求被提出审查意见|
|pull_request_sync|合并请求被同步|
|repository|创建或删除仓库|
|release|版本发布| -->
> 请求的JSON示例:
@ -1546,15 +1489,15 @@ await octokit.request('DELETE /api/v1/yystopf/ceshi/webhooks/7.json')
```shell
curl -X GET \
http://localhost:3000/api/yystopf/ceshi/webhooks/3/tasks.json
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
```
```javascript
await octokit.request('GET /api/yystopf/ceshi/webhooks/3/tasks.json')
await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3/hooktasks.json')
```
### HTTP 请求
`GET /api/:owner/:repo/webhooks/:id/tasks.json`
`GET /api/v1/:owner/:repo/webhooks/:id/hooktasks.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明
@ -1582,7 +1525,7 @@ await octokit.request('GET /api/yystopf/ceshi/webhooks/3/tasks.json')
```json
{
"total_count": 6,
"tasks": [
"hooktasks": [
{
"id": 20,
"type": "gitea",
@ -1758,15 +1701,15 @@ await octokit.request('GET /api/yystopf/ceshi/webhooks/3/tasks.json')
```shell
curl -X POST \
http://localhost:3000/api/yystopf/ceshi/webhooks/3/test.json
http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
```
```javascript
await octokit.request('POST /api/yystopf/ceshi/webhooks/3/test.json')
await octokit.request('POST /api/v1/yystopf/ceshi/webhooks/3/tests.json')
```
### HTTP 请求
`POST /api/:owner/:repo/webhooks/:id/test.json`
`POST /api/v1/:owner/:repo/webhooks/:id/tests.json`
### 请求参数:
参数 | 必选 | 默认 | 类型 | 字段说明

View File

@ -47,6 +47,105 @@ await octokit.request('GET /api/users/me.json')
Success Data.
</aside>
## 用户项目列表
获取用户项目列表
> 示例:
```shell
curl -X GET http://localhost:3000/api/v1/:login/projects.json
```
```javascript
await octokit.request('GET /api/v1/:login/projects.json')
```
### HTTP 请求
`GET api/v1/yystopf/projects.json`
### 请求字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|login | string | 用户的用户名|
|category | string | 归属项目,默认为全部项目, join: 参与项目, created: 创建项目, manage: 管理项目, watched: 关注项目, forked: 复刻项目 |
|is_public | boolean | 公/私有项目true为公开项目false为私有项目|
|project_type | string | 项目类型common为托管项目, mirror为镜像项目, sync_mirror为同步镜像项目|
|sort_by | string | 项目的排序字段,比如 created_on, updated_on等|
|sort_direction | string | 排序的类型desc 倒序asc 正序|
|limit | integer | 每页个数 |
|page | integer | 页码 |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|total_count | integer | 项目总数 |
|projects.owner.id | integer | 项目拥有者id |
|projects.owner.type | string | 项目拥有者类型User 用户Organization 组织 |
|projects.owner.name | string | 项目拥有者名称|
|projects.owner.login | string | 项目拥有者用户名 |
|projects.owner.image_url | string | 项目拥有者头像地址 |
|type | string | 项目类型common 托管项目mirror 镜像项目, sync 同步镜像项目 |
|description | string | 项目描述 |
|forked_count | integer | 项目复刻数量 |
|forked_from_project_id | integer | 项目复刻来源项目 |
|identifier | string | 项目标识 |
|issues_count | integer | 项目issues数量|
|pull_requests_count | integer | 项目合并请求数量 |
|invite_code | string | 项目邀请码|
|website | string | 项目网址|
|platform | string | 项目平台 |
|name | string | 项目名称|
|open_devops | boolean | 项目是否开启工作流 |
|praises_count | integer | 项目点赞数量|
|is_public | boolean | 项目是否公开|
|status | integer | 项目状态|
|watchers_count | integer | 项目关注数量|
|ignore_id | integer | 项目ignoreID|
|license_id | integer | 项目许可证ID|
|project_category_id | integer | 项目分类ID|
|project_language_id | integer | 项目语言ID|
> 返回的JSON示例:
```json
"total_count": 1,
"projects": [
{
"owner": {
"id": 2,
"type": "User",
"name": "heh",
"login": "yystopf",
"image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
},
"type": "common",
"description": null,
"forked_count": 1,
"forked_from_project_id": null,
"identifier": "hahahah",
"issues_count": 5,
"pull_requests_count": 3,
"invite_code": "8zfKtM",
"website": null,
"platform": "forge",
"name": "hahahah",
"open_devops": false,
"praises_count": 0,
"is_public": true,
"status": 1,
"watchers_count": 0,
"ignore_id": null,
"license_id": null,
"project_category_id": null,
"project_language_id": null
}
]
```
<aside class="success">
Success Data.
</aside>
## 用户消息列表
获取用户消息列表

View File

@ -4,8 +4,8 @@ class Api::V1::Users::Projects::ListService < ApplicationService
attr_reader :observe_user, :category, :is_public, :project_type, :sort_by, :sort_direction, :search, :current_user
attr_accessor :queried_projects
validates :category, inclusion: {in: %w(all join created watched forked), message: "请输入正确的Category"}
validates :is_public, inclusion: {in: [true, false], message: '请输入正确的IsPublic'}
validates :category, inclusion: {in: %w(all join created manage watched forked), message: "请输入正确的Category"}
validates :is_public, inclusion: {in: [true, false], message: '请输入正确的IsPublic'}, allow_nil: true
validates :project_type, inclusion: {in: %w(common mirror sync_mirror), message: '请输入正确的ProjectType'}, allow_nil: true
validates :sort_by, inclusion: {in: Project.column_names, message: '请输入正确的SortBy'}
validates :sort_direction, inclusion: {in: %w(asc desc), message: '请输入正确的SortDirection'}
@ -13,7 +13,7 @@ class Api::V1::Users::Projects::ListService < ApplicationService
def initialize(observe_user, params, current_user=nil)
@observe_user = observe_user
@category = params[:category] || 'all'
@is_public = params[:is_public] || true
@is_public = params[:is_public]
@project_type = params[:project_type]
@sort_by = params[:sort_by] || 'updated_on'
@sort_direction = params[:sort_direction] || 'desc'
@ -47,6 +47,10 @@ class Api::V1::Users::Projects::ListService < ApplicationService
projects = Project.from("( #{normal_projects} UNION #{org_projects} ) AS projects").distinct
when 'created'
projects = projects.where(user_id: observe_user.id)
when 'manage'
normal_projects = projects.joins(members: :roles).where(members: {user_id: observe_user.id}, roles: {name: 'Manager'}).to_sql
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: observe_user.id}, teams: {authorize: %w(owner admin)}).to_sql
projects = Project.from("( #{normal_projects} UNION #{org_projects} ) AS projects").distinct
when 'watched'
projects = projects.where.not(user_id: observe_user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: observe_user.id})
when 'forked'
@ -58,11 +62,14 @@ class Api::V1::Users::Projects::ListService < ApplicationService
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
end
if is_public
projects = projects.visible
else
projects = projects.is_private
unless is_public.nil?
if is_public
projects = projects.visible
else
projects = projects.is_private
end
end
projects = projects.with_project_type(project_type)

File diff suppressed because it is too large Load Diff