From 62733493349f9f6a737ba3d6745c7e9b96d4b3e8 Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 18 Jul 2022 11:37:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E:=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=AF=94=E8=BE=83blame=E3=80=81token=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8D=95=E8=8E=B7=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- .../api/v1/projects/commits_controller.rb | 1 - app/controllers/api/v1/projects_controller.rb | 6 +- .../slate/source/includes/_repositories.md | 207 ++++- .../v1/projects/branches/all_list_service.rb | 10 +- .../v1/projects/branches/create_service.rb | 14 +- .../api/v1/projects/commits/diff_service.rb | 7 +- .../api/v1/projects/compare_service.rb | 34 + app/services/api/v1/projects/get_service.rb | 12 +- .../api/v1/projects/git/blobs_service.rb | 10 +- .../api/v1/projects/git/trees_service.rb | 8 +- .../v1/projects/webhooks/create_service.rb | 12 +- .../v1/projects/webhooks/delete_service.rb | 10 +- .../api/v1/projects/webhooks/get_service.rb | 9 +- .../v1/projects/webhooks/hooktasks_service.rb | 7 +- .../api/v1/projects/webhooks/list_service.rb | 10 +- .../api/v1/projects/webhooks/tests_service.rb | 10 +- .../v1/projects/webhooks/update_service.rb | 12 +- .../_simple_gitea_diff_detail.json.jbuilder | 40 + .../v1/projects/commits/diff.json.jbuilder | 41 +- .../api/v1/projects/compare.json.jbuilder | 18 + config/routes/api.rb | 6 +- public/docs/api.html | 845 ++++++++++++------ 23 files changed, 912 insertions(+), 419 deletions(-) create mode 100644 app/services/api/v1/projects/compare_service.rb create mode 100644 app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder create mode 100644 app/views/api/v1/projects/compare.json.jbuilder diff --git a/Gemfile b/Gemfile index b6d5099ae..37687e78d 100644 --- a/Gemfile +++ b/Gemfile @@ -135,4 +135,4 @@ gem 'doorkeeper' gem 'doorkeeper-jwt' -gem 'gitea-client', '~> 0.9.3' \ No newline at end of file +gem 'gitea-client', '~> 0.9.4' \ No newline at end of file diff --git a/app/controllers/api/v1/projects/commits_controller.rb b/app/controllers/api/v1/projects/commits_controller.rb index 1e6c17bea..873dd4d93 100644 --- a/app/controllers/api/v1/projects/commits_controller.rb +++ b/app/controllers/api/v1/projects/commits_controller.rb @@ -3,6 +3,5 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController def diff @result_object = Api::V1::Projects::Commits::DiffService.call(@project, params[:sha], current_user&.gitea_token) - puts @result_object end end \ No newline at end of file diff --git a/app/controllers/api/v1/projects_controller.rb b/app/controllers/api/v1/projects_controller.rb index 05a3750ca..0873213de 100644 --- a/app/controllers/api/v1/projects_controller.rb +++ b/app/controllers/api/v1/projects_controller.rb @@ -1,5 +1,5 @@ class Api::V1::ProjectsController < Api::V1::BaseController - before_action :load_project, only: [:show] + before_action :require_public_and_member_above, only: [:show, :compare] def index render_ok @@ -8,4 +8,8 @@ class Api::V1::ProjectsController < Api::V1::BaseController def show @result_object = Api::V1::Projects::GetService.call(@project, current_user.gitea_token) end + + def compare + @result_object = Api::V1::Projects::CompareService.call(@project, params[:from], params[:to], current_user&.gitea_token) + end end \ No newline at end of file diff --git a/app/docs/slate/source/includes/_repositories.md b/app/docs/slate/source/includes/_repositories.md index afd099325..2b3ca1326 100644 --- a/app/docs/slate/source/includes/_repositories.md +++ b/app/docs/slate/source/includes/_repositories.md @@ -1474,9 +1474,9 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393 ```json { - "file_nums": 2, - "total_addition": 2, - "total_deletion": 2, + "file_nums": 1, + "total_addition": 1, + "total_deletion": 0, "files": [ { "name": "xinzeng3", @@ -1523,52 +1523,6 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393 "is_incomplete": false, "is_incomplete_line_too_long": false, "is_protected": false - }, - { - "name": "xinzeng4", - "oldname": "xinzeng4", - "addition": 1, - "deletion": 0, - "type": 1, - "is_created": true, - "is_deleted": false, - "is_bin": false, - "is_lfs_file": false, - "is_renamed": false, - "is_ambiguous": false, - "is_submodule": false, - "sections": [ - { - "file_name": "xinzeng4", - "name": "", - "lines": [ - { - "left_index": 0, - "right_index": 0, - "match": 0, - "type": 4, - "content": "@@ -0,0 +1 @@", - "section_path": "xinzeng4", - "section_last_left_index": 0, - "section_last_right_index": 0, - "section_left_index": 0, - "section_right_index": 1, - "section_left_hunk_size": 0, - "section_right_hunk_size": 0 - }, - { - "left_index": 0, - "right_index": 1, - "match": -1, - "type": 2, - "content": "+111112222" - } - ] - } - ], - "is_incomplete": false, - "is_incomplete_line_too_long": false, - "is_protected": false } ] } @@ -1577,6 +1531,161 @@ await octokit.request('GET /api/v1/yystopf/csfjkkj/commits/80dd40214a58622312393 Success Data. +## 获取比较提交blame +根据分支名、标签、commit ID来获取代码对比blame + +> 示例: + +```shell +curl -X GET \ +-d "from=hh_ceshi" \ +-d "to=master" \ +http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json +``` + +```javascript +await octokit.request('GET /api/v1/yystopf/csfjkkj/compare.json') +``` + +### HTTP 请求 +`GET /api/v1/:owner/:repo/compare.json` + +### 请求参数: +参数 | 必选 | 默认 | 类型 | 字段说明 +--------- | ------- | ------- | -------- | ---------- +|owner|是| | string |用户登录名 | +|repo |是| | string |项目标识identifier | +|from |是| | string |源分支、标签、commitID | +|to|是||string|目标分支、标签、commitID| +### 返回字段说明: +参数 | 类型 | 字段说明 +--------- | ----------- | ----------- +|commits_count|int|提交数量| +|commits.branch|string|提交分支| +|commits.author|object|提交作者| +|commits.committer|object|提交者| +|commits.commit_message|string|提交信息| +|commits.sha|string|提交ID| +|commits.parent_shas|array|提交父节点ID| +|diff.file_nums|int|文件数量| +|diff.total_addition|int|新增行数| +|diff.total_deletion|int|删除行数| +|diff.files.name|string|文件名称| +|diff.files.oldname|string|文件修改前名称| +|diff.files.addition|int|文件新增行数| +|diff.files.deletion|int|文件删除行数| +|diff.files.type|int|文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制| +|diff.files.is_created|bool|是否为新建文件| +|diff.files.is_deleted|bool|是否为删除文件| +|diff.files.is_bin|bool|是否为二进制文件| +|diff.files.is_lfs_file|bool|| +|diff.files.is_renamed|bool|是否重命名| +|diff.files.is_ambiguous|bool|| +|diff.files.is_submodule|bool|是否为子模块| +|diff.files.sections.file_name|string|文件名称| +|diff.files.sections.name|string|| +|diff.files.sections.lines.left_index|int|| +|diff.files.sections.lines.right_index|int|| +|diff.files.sections.lines.match|int|| +|diff.files.sections.lines.type|int|| +|diff.files.sections.lines.content|string|| +|diff.files.sections.lines.section_path|string|| +|diff.files.sections.lines.section_last_left_index|int|| +|diff.files.sections.lines.section_last_right_index|int|| +|diff.files.sections.lines.section_left_index|int|| +|diff.files.sections.lines.section_right_index|int|| +|diff.files.sections.lines.section_left_hunk_size|int|| +|diff.files.sections.lines.section_right_hunk_size|int|| + + + +> 返回的JSON示例: + +```json +{ + "commits_count": 1, + "last_commit_sha": "80dd40214a58622312393b2ae693756a4781fab2", + "commits": [ + { + "author": { + "id": "2", + "login": "yystopf", + "name": "heh", + "type": "User", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + }, + "committer": { + "id": "2", + "login": "yystopf", + "name": "heh", + "type": "User", + "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png" + }, + "branch": "", + "commit_message": "x拟增\n\nSigned-off-by: yystopf ", + "sha": "7e4d8bb3c28e24d4cd6b205f2eed32513e937524", + "parent_shas": null + } + ], + "diff": { + "file_nums": 1, + "total_addition": 1, + "total_deletion": 0, + "files": [ + { + "name": "ceshi123", + "oldname": "ceshi123", + "addition": 1, + "deletion": 0, + "type": 1, + "is_created": true, + "is_deleted": false, + "is_bin": false, + "is_lfs_file": false, + "is_renamed": false, + "is_ambiguous": false, + "is_submodule": false, + "sections": [ + { + "file_name": "ceshi123", + "name": "", + "lines": [ + { + "left_index": 0, + "right_index": 0, + "match": 0, + "type": 4, + "content": "@@ -0,0 +1 @@", + "section_path": "ceshi123", + "section_last_left_index": 0, + "section_last_right_index": 0, + "section_left_index": 0, + "section_right_index": 1, + "section_left_hunk_size": 0, + "section_right_hunk_size": 0 + }, + { + "left_index": 0, + "right_index": 1, + "match": -1, + "type": 2, + "content": "+1111122222" + } + ] + } + ], + "is_incomplete": false, + "is_incomplete_line_too_long": false, + "is_protected": false + } + ] + } +} +``` + + ## 获取仓库webhooks列表 获取仓库webhooks列表 diff --git a/app/services/api/v1/projects/branches/all_list_service.rb b/app/services/api/v1/projects/branches/all_list_service.rb index 9e97b6dd2..182495cdf 100644 --- a/app/services/api/v1/projects/branches/all_list_service.rb +++ b/app/services/api/v1/projects/branches/all_list_service.rb @@ -11,16 +11,20 @@ class Api::V1::Projects::Branches::AllListService < ApplicationService end def call - $gitea_client.token = token unless token.blank? load_gitea_data - $gitea_client.token = nil unless token.blank? gitea_data end private + def request_params + { + access_token: token + } + end + def load_gitea_data - @gitea_data = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo) + @gitea_data = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo, {query: request_params}) rescue nil raise Error, '获取所有分支失败!' unless @gitea_data.is_a?(Hash) end end \ No newline at end of file diff --git a/app/services/api/v1/projects/branches/create_service.rb b/app/services/api/v1/projects/branches/create_service.rb index a4d9f854b..33e561270 100644 --- a/app/services/api/v1/projects/branches/create_service.rb +++ b/app/services/api/v1/projects/branches/create_service.rb @@ -4,7 +4,7 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService attr_accessor :project, :token, :owner, :repo, :old_branch_name, :new_branch_name attr_accessor :gitea_data - validates :new_branch_name, :old_branch_name, presence: :true + validates :new_branch_name, :old_branch_name, presence: true def initialize(project, params, token=nil) @project = project @@ -17,16 +17,20 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService def call raise Error, errors.full_messages.join(",") unless valid? - $gitea_client.token = token unless token.blank? check_new_branch_exist excute_data_to_gitea - $gitea_client.token = nil unless token.blank? gitea_data end private + def request_params + { + access_token: token + } + end + def request_body { new_branch_name: new_branch_name, @@ -35,12 +39,12 @@ class Api::V1::Projects::Branches::CreateService < ApplicationService end def excute_data_to_gitea - @gitea_data = $gitea_client.post_repos_branches_by_owner_repo(owner, repo, {body: request_body.to_json}) + @gitea_data = $gitea_client.post_repos_branches_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil raise Error, '创建分支失败!' unless @gitea_data.is_a?(Hash) end def check_new_branch_exist - result = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo) + result = $gitea_client.get_repos_branch_name_set_by_owner_repo(owner, repo) rescue nil raise Error, '查询分支名称失败!' unless result.is_a?(Hash) raise Error, '分支已存在!' if result['branch_name'].include?(@new_branch_name) end diff --git a/app/services/api/v1/projects/commits/diff_service.rb b/app/services/api/v1/projects/commits/diff_service.rb index 8b12fc318..71dd155a0 100644 --- a/app/services/api/v1/projects/commits/diff_service.rb +++ b/app/services/api/v1/projects/commits/diff_service.rb @@ -1,7 +1,11 @@ class Api::V1::Projects::Commits::DiffService < ApplicationService + include ActiveModel::Model + attr_accessor :project, :sha, :token, :owner, :repo attr_accessor :gitea_data + validates :sha, presence: true + def initialize(project, sha, token = nil) @project = project @sha = sha @@ -11,6 +15,7 @@ class Api::V1::Projects::Commits::DiffService < ApplicationService end def call + raise Error, errors.full_messages.join(",") unless valid? load_gitea_data gitea_data @@ -24,7 +29,7 @@ class Api::V1::Projects::Commits::DiffService < ApplicationService end def load_gitea_data - @gitea_data = $gitea_client.get_repos_commits_diff_by_owner_repo_sha(owner, repo, sha, {query: request_params}) + @gitea_data = $gitea_client.get_repos_commits_diff_by_owner_repo_sha(owner, repo, sha, {query: request_params}) rescue nil raise Error, '获取提交对比失败!' unless @gitea_data.is_a?(Hash) end diff --git a/app/services/api/v1/projects/compare_service.rb b/app/services/api/v1/projects/compare_service.rb new file mode 100644 index 000000000..23a248305 --- /dev/null +++ b/app/services/api/v1/projects/compare_service.rb @@ -0,0 +1,34 @@ +class Api::V1::Projects::CompareService < ApplicationService + include ActiveModel::Model + attr_reader :project, :from, :to, :token, :owner, :repo + attr_accessor :gitea_data + + validates :from, :to, presence: true + + def initialize(project, from, to, token=nil) + @project = project + @owner = project&.owner.login + @repo = project&.identifier + @from = from + @to = to + @token = token + end + + def call + raise Error, errors.full_messages.join(",") unless valid? + load_gitea_data + raise Error, '获取对比信息失败!' unless gitea_data.is_a?(Hash) + gitea_data + end + + private + def request_params + { + access_token: token + } + end + + def load_gitea_data + @gitea_data = $gitea_client.get_repos_compare_by_owner_repo_from_to(owner, repo, from, to, {query: request_params}) rescue nil + end +end \ No newline at end of file diff --git a/app/services/api/v1/projects/get_service.rb b/app/services/api/v1/projects/get_service.rb index 1244938ce..ebb0d1cfa 100644 --- a/app/services/api/v1/projects/get_service.rb +++ b/app/services/api/v1/projects/get_service.rb @@ -11,18 +11,20 @@ class Api::V1::Projects::GetService < ApplicationService end def call - $gitea_client.token = token unless token.blank? load_gitea_data load_gitea_branch_tag_count - $gitea_client.token = nil unless token.blank? - result_object rescue raise Error, "服务器错误,请联系系统管理员!" end private + def request_params + { + access_token: token + } + end def result_object { @@ -39,10 +41,10 @@ class Api::V1::Projects::GetService < ApplicationService end def load_gitea_data - @gitea_data = $gitea_client.get_repos_by_owner_repo(owner, repo) + @gitea_data = $gitea_client.get_repos_by_owner_repo(owner, repo, {query: request_params}) rescue nil end def load_gitea_branch_tag_count - @gitea_branch_tag_count = $gitea_client.get_repos_branch_tag_count_by_owner_repo(owner, repo) + @gitea_branch_tag_count = $gitea_client.get_repos_branch_tag_count_by_owner_repo(owner, repo, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/git/blobs_service.rb b/app/services/api/v1/projects/git/blobs_service.rb index 0b197c106..e2097d933 100644 --- a/app/services/api/v1/projects/git/blobs_service.rb +++ b/app/services/api/v1/projects/git/blobs_service.rb @@ -16,15 +16,19 @@ class Api::V1::Projects::Git::BlobsService < ApplicationService end def call - $gitea_client.token = token unless token.blank? load_gitea_data - $gitea_client.token = nil unless token.blank? gitea_data end private + def request_params + { + access_token: token + } + end + def load_gitea_data - @gitea_data = $gitea_client.get_repos_git_blobs_by_owner_repo_sha(owner, repo, sha) + @gitea_data = $gitea_client.get_repos_git_blobs_by_owner_repo_sha(owner, repo, sha, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/git/trees_service.rb b/app/services/api/v1/projects/git/trees_service.rb index 2a72c11a5..4d6f5d181 100644 --- a/app/services/api/v1/projects/git/trees_service.rb +++ b/app/services/api/v1/projects/git/trees_service.rb @@ -33,18 +33,20 @@ class Api::V1::Projects::Git::TreesService < ApplicationService { recursive: recursive, page: page, - per_page: limit + per_page: limit, + access_token: token } else { page: page, - per_page: limit + per_page: limit, + access_token: token } end end def load_gitea_data - @gitea_data = $gitea_client.get_repos_git_trees_by_owner_repo_sha(owner, repo, sha, {query: request_query}) + @gitea_data = $gitea_client.get_repos_git_trees_by_owner_repo_sha(owner, repo, sha, {query: request_query}) rescue nil raise Error, '获取文件树列表失败!' unless @gitea_data.is_a?(Hash) end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/create_service.rb b/app/services/api/v1/projects/webhooks/create_service.rb index 401ff9ff6..bef0a3405 100644 --- a/app/services/api/v1/projects/webhooks/create_service.rb +++ b/app/services/api/v1/projects/webhooks/create_service.rb @@ -26,12 +26,8 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService def call raise Error, errors.full_messages.join(",") unless valid? begin - $gitea_client.token = token unless token.blank? - excute_data_to_gitea - $gitea_client.token = nil unless token.blank? - gitea_data rescue raise Error, "服务器错误,请联系系统管理员!" @@ -39,6 +35,12 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService end private + def request_params + { + access_token: token + } + end + def request_body { active: active, @@ -55,6 +57,6 @@ class Api::V1::Projects::Webhooks::CreateService < ApplicationService end def excute_data_to_gitea - @gitea_data = $gitea_client.post_repos_hooks_by_owner_repo(owner, repo, {body: request_body.to_json}) + @gitea_data = $gitea_client.post_repos_hooks_by_owner_repo(owner, repo, {body: request_body.to_json, query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/delete_service.rb b/app/services/api/v1/projects/webhooks/delete_service.rb index 5dd499e6d..8343a5b20 100644 --- a/app/services/api/v1/projects/webhooks/delete_service.rb +++ b/app/services/api/v1/projects/webhooks/delete_service.rb @@ -12,19 +12,21 @@ class Api::V1::Projects::Webhooks::DeleteService < ApplicationService end def call - $gitea_client.token = token unless token.blank? excute_data_to_gitea - $gitea_client.token = nil unless token.blank? - gitea_data rescue raise Error, "服务器错误,请联系系统管理员!" end private + def request_params + { + access_token: token + } + end def excute_data_to_gitea - @gitea_data = $gitea_client.delete_repos_hooks_by_owner_repo_id(owner, repo, id) + @gitea_data = $gitea_client.delete_repos_hooks_by_owner_repo_id(owner, repo, id, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/get_service.rb b/app/services/api/v1/projects/webhooks/get_service.rb index 1ae5c54e2..5c6c79d3e 100644 --- a/app/services/api/v1/projects/webhooks/get_service.rb +++ b/app/services/api/v1/projects/webhooks/get_service.rb @@ -12,10 +12,8 @@ class Api::V1::Projects::Webhooks::GetService < ApplicationService end def call - $gitea_client.token = token unless token.blank? load_gitea_data - $gitea_client.token = nil unless token.blank? gitea_data rescue @@ -23,8 +21,13 @@ class Api::V1::Projects::Webhooks::GetService < ApplicationService end private + def request_params + { + access_token: token + } + end def load_gitea_data - @gitea_data = $gitea_client.get_repos_hooks_by_owner_repo_id(owner, repo, id) + @gitea_data = $gitea_client.get_repos_hooks_by_owner_repo_id(owner, repo, id, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/hooktasks_service.rb b/app/services/api/v1/projects/webhooks/hooktasks_service.rb index 4dd90ee3e..6be9c67c8 100644 --- a/app/services/api/v1/projects/webhooks/hooktasks_service.rb +++ b/app/services/api/v1/projects/webhooks/hooktasks_service.rb @@ -23,8 +23,13 @@ class Api::V1::Projects::Webhooks::ListService < ApplicationService end private + def request_params + { + access_token: token + } + end def load_gitea_data - @gitea_data = $gitea_client.get_repos_hooks_hooktasks_by_owner_repo(owner, repo, id) + @gitea_data = $gitea_client.get_repos_hooks_hooktasks_by_owner_repo(owner, repo, id, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/list_service.rb b/app/services/api/v1/projects/webhooks/list_service.rb index fb746de48..2a76d196c 100644 --- a/app/services/api/v1/projects/webhooks/list_service.rb +++ b/app/services/api/v1/projects/webhooks/list_service.rb @@ -11,19 +11,21 @@ class Api::V1::Projects::Webhooks::ListService < ApplicationService end def call - $gitea_client.token = token unless token.blank? load_gitea_data - $gitea_client.token = nil unless token.blank? - gitea_data rescue raise Error, "服务器错误,请联系系统管理员!" end private + def request_params + { + access_token: token + } + end def load_gitea_data - @gitea_data = $gitea_client.get_repos_hooks_by_owner_repo(owner, repo) + @gitea_data = $gitea_client.get_repos_hooks_by_owner_repo(owner, repo, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/tests_service.rb b/app/services/api/v1/projects/webhooks/tests_service.rb index 3d8b99c97..3f9fe0642 100644 --- a/app/services/api/v1/projects/webhooks/tests_service.rb +++ b/app/services/api/v1/projects/webhooks/tests_service.rb @@ -12,19 +12,21 @@ class Api::V1::Projects::Webhooks::TestsService < ApplicationService end def call - $gitea_client.token = token unless token.blank? excute_data_to_gitea - $gitea_client.token = nil unless token.blank? - gitea_data rescue raise Error, "服务器错误,请联系系统管理员!" end private + def request_params + { + access_token: token + } + end def excute_data_to_gitea - @gitea_data = $gitea_client.post_repos_hooks_tests_by_owner_repo_id(owner, repo, id) + @gitea_data = $gitea_client.post_repos_hooks_tests_by_owner_repo_id(owner, repo, id, {query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/services/api/v1/projects/webhooks/update_service.rb b/app/services/api/v1/projects/webhooks/update_service.rb index 19ff4f32b..a632d6f2d 100644 --- a/app/services/api/v1/projects/webhooks/update_service.rb +++ b/app/services/api/v1/projects/webhooks/update_service.rb @@ -27,12 +27,8 @@ class Api::V1::Projects::Webhooks::UpdateService < ApplicationService def call raise Error, errors.full_messages.join(",") unless valid? begin - $gitea_client.token = token unless token.blank? - excute_data_to_gitea - $gitea_client.token = nil unless token.blank? - gitea_data rescue raise Error, "服务器错误,请联系系统管理员!" @@ -40,6 +36,12 @@ class Api::V1::Projects::Webhooks::UpdateService < ApplicationService end private + def request_params + { + access_token: token + } + end + def request_body { active: active, @@ -56,6 +58,6 @@ class Api::V1::Projects::Webhooks::UpdateService < ApplicationService end def excute_data_to_gitea - @gitea_data = $gitea_client.patch_repos_hooks_by_owner_repo_id(owner, repo, id, {body: request_body.to_json}) + @gitea_data = $gitea_client.patch_repos_hooks_by_owner_repo_id(owner, repo, id, {body: request_body.to_json, query: request_params}) rescue nil end end \ No newline at end of file diff --git a/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder b/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder new file mode 100644 index 000000000..5dff0b89d --- /dev/null +++ b/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder @@ -0,0 +1,40 @@ +json.file_nums diff['NumFiles'] +json.total_addition diff['TotalAddition'] +json.total_deletion diff['TotalDeletion'] +json.files diff['Files'].each do |file| + json.name file['Name'] + json.oldname file['OldName'] + json.addition file['Addition'] + json.deletion file['Deletion'] + json.type file['Type'] + json.is_created file['IsCreated'] + json.is_deleted file['IsDeleted'] + json.is_bin file['IsBin'] + json.is_lfs_file file['IsLFSFile'] + json.is_renamed file['IsRenamed'] + json.is_ambiguous file['IsAmbiguous'] + json.is_submodule file['IsSubmodule'] + json.sections file['Sections'] do |section| + json.file_name section['FileName'] + json.name section['Name'] + json.lines section['Lines'] do |line| + json.left_index line['LeftIdx'] + json.right_index line['RightIdx'] + json.match line['Match'] + json.type line['Type'] + json.content line['Content'] + unless line['SectionInfo'].blank? + json.section_path line['SectionInfo']['Path'] + json.section_last_left_index line['SectionInfo']['LastLeftIdx'] + json.section_last_right_index line['SectionInfo']['LastRightIdx'] + json.section_left_index line['SectionInfo']['LeftIdx'] + json.section_right_index line['SectionInfo']['RightIdx'] + json.section_left_hunk_size line['SectionInfo']['LeftHunkSize'] + json.section_right_hunk_size line['SectionInfo']['RightHunkSize'] + end + end + end + json.is_incomplete file['IsIncomplete'] + json.is_incomplete_line_too_long file['IsIncompleteLineTooLong'] + json.is_protected file['IsProtected'] +end \ No newline at end of file diff --git a/app/views/api/v1/projects/commits/diff.json.jbuilder b/app/views/api/v1/projects/commits/diff.json.jbuilder index e0237369f..8c280b7f5 100644 --- a/app/views/api/v1/projects/commits/diff.json.jbuilder +++ b/app/views/api/v1/projects/commits/diff.json.jbuilder @@ -1,40 +1 @@ -json.file_nums @result_object['NumFiles'] -json.total_addition @result_object['TotalAddition'] -json.total_deletion @result_object['TotalAddition'] -json.files @result_object['Files'].each do |file| - json.name file['Name'] - json.oldname file['OldName'] - json.addition file['Addition'] - json.deletion file['Deletion'] - json.type file['Type'] - json.is_created file['IsCreated'] - json.is_deleted file['IsDeleted'] - json.is_bin file['IsBin'] - json.is_lfs_file file['IsLFSFile'] - json.is_renamed file['IsRenamed'] - json.is_ambiguous file['IsAmbiguous'] - json.is_submodule file['IsSubmodule'] - json.sections file['Sections'] do |section| - json.file_name section['FileName'] - json.name section['Name'] - json.lines section['Lines'] do |line| - json.left_index line['LeftIdx'] - json.right_index line['RightIdx'] - json.match line['Match'] - json.type line['Type'] - json.content line['Content'] - unless line['SectionInfo'].blank? - json.section_path line['SectionInfo']['Path'] - json.section_last_left_index line['SectionInfo']['LastLeftIdx'] - json.section_last_right_index line['SectionInfo']['LastRightIdx'] - json.section_left_index line['SectionInfo']['LeftIdx'] - json.section_right_index line['SectionInfo']['RightIdx'] - json.section_left_hunk_size line['SectionInfo']['LeftHunkSize'] - json.section_right_hunk_size line['SectionInfo']['RightHunkSize'] - end - end - end - json.is_incomplete file['IsIncomplete'] - json.is_incomplete_line_too_long file['IsIncompleteLineTooLong'] - json.is_protected file['IsProtected'] -end \ No newline at end of file +json.partial! "api/v1/projects/simple_gitea_diff_detail", diff: @result_object \ No newline at end of file diff --git a/app/views/api/v1/projects/compare.json.jbuilder b/app/views/api/v1/projects/compare.json.jbuilder new file mode 100644 index 000000000..2d20c51e0 --- /dev/null +++ b/app/views/api/v1/projects/compare.json.jbuilder @@ -0,0 +1,18 @@ +json.commits_count @result_object['CommitsCount'] +json.last_commit_sha @result_object['LatestSha'] +json.commits @result_object['Commits'] do |commit| + json.author do + json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(commit['Author']), name: commit['Author']['Name'] } + end + + json.committer do + json.partial! 'api/v1/users/commit_user', locals: { user: render_cache_commit_author(commit['Committer']), name: commit['Committer']['Name'] } + end + json.branch commit['Branch'] + json.commit_message commit['CommitMessage'] + json.sha commit['Sha'] + json.parent_shas commit['Sha']['ParentShas'] +end +json.diff do + json.partial! "api/v1/projects/simple_gitea_diff_detail", diff: @result_object['Diff'] +end \ No newline at end of file diff --git a/config/routes/api.rb b/config/routes/api.rb index 789016968..fc07a9862 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -9,7 +9,11 @@ defaults format: :json do scope ':repo' do # projects - resource :projects, path: '/', only: [:show, :update, :edit, :destroy] + resource :projects, path: '/', only: [:show, :update, :edit, :destroy] do + collection do + get :compare + end + end # projects文件夹下的 scope module: :projects do diff --git a/public/docs/api.html b/public/docs/api.html index efc0432b7..505ab44cf 100644 --- a/public/docs/api.html +++ b/public/docs/api.html @@ -556,6 +556,9 @@
  • 获取单个提交的blame信息
  • +
  • + 获取比较提交blame +
  • 获取仓库webhooks列表
  • @@ -9863,9 +9866,9 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae

    返回的JSON示例:

    {
    -    "file_nums": 2,
    -    "total_addition": 2,
    -    "total_deletion": 2,
    +    "file_nums": 1,
    +    "total_addition": 1,
    +    "total_deletion": 0,
         "files": [
             {
                 "name": "xinzeng3",
    @@ -9912,52 +9915,6 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
                 "is_incomplete": false,
                 "is_incomplete_line_too_long": false,
                 "is_protected": false
    -        },
    -        {
    -            "name": "xinzeng4",
    -            "oldname": "xinzeng4",
    -            "addition": 1,
    -            "deletion": 0,
    -            "type": 1,
    -            "is_created": true,
    -            "is_deleted": false,
    -            "is_bin": false,
    -            "is_lfs_file": false,
    -            "is_renamed": false,
    -            "is_ambiguous": false,
    -            "is_submodule": false,
    -            "sections": [
    -                {
    -                    "file_name": "xinzeng4",
    -                    "name": "",
    -                    "lines": [
    -                        {
    -                            "left_index": 0,
    -                            "right_index": 0,
    -                            "match": 0,
    -                            "type": 4,
    -                            "content": "@@ -0,0 +1 @@",
    -                            "section_path": "xinzeng4",
    -                            "section_last_left_index": 0,
    -                            "section_last_right_index": 0,
    -                            "section_left_index": 0,
    -                            "section_right_index": 1,
    -                            "section_left_hunk_size": 0,
    -                            "section_right_hunk_size": 0
    -                        },
    -                        {
    -                            "left_index": 0,
    -                            "right_index": 1,
    -                            "match": -1,
    -                            "type": 2,
    -                            "content": "+111112222"
    -                        }
    -                    ]
    -                }
    -            ],
    -            "is_incomplete": false,
    -            "is_incomplete_line_too_long": false,
    -            "is_protected": false
             }
         ]
     }
    @@ -9965,17 +9922,19 @@ http://localhost:3000/api/v1/yystopf/csfjkkj/git/trees/80dd40214a58622312393b2ae
     
    -

    获取仓库webhooks列表

    -

    获取仓库webhooks列表

    +

    获取比较提交blame

    +

    根据分支名、标签、commit ID来获取代码对比blame

    示例:

    curl -X GET \
    -http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
    -
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
    +-d "from=hh_ceshi" \
    +-d "to=master" \
    +http://localhost:3000/api/v1/yystopf/csfjkkj/compare.json
    +
    await octokit.request('GET /api/v1/yystopf/csfjkkj/compare.json')
     

    HTTP 请求

    -

    GET /api/v1/:owner/:repo/webhooks.json

    +

    GET /api/v1/:owner/:repo/compare.json

    请求参数:

    @@ -10000,6 +9959,20 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json + + + + + + + + + + + + + +
    string 项目标识identifier
    fromstring源分支、标签、commitID
    tostring目标分支、标签、commitID

    返回字段说明:

    @@ -10010,6 +9983,318 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    commits_countint提交数量
    commits.branchstring提交分支
    commits.authorobject提交作者
    commits.committerobject提交者
    commits.commit_messagestring提交信息
    commits.shastring提交ID
    commits.parent_shasarray提交父节点ID
    diff.file_numsint文件数量
    diff.total_additionint新增行数
    diff.total_deletionint删除行数
    diff.files.namestring文件名称
    diff.files.oldnamestring文件修改前名称
    diff.files.additionint文件新增行数
    diff.files.deletionint文件删除行数
    diff.files.typeint文件类型 1: 新增 2: 更改 3: 删除 4: 重命名 5: 复制
    diff.files.is_createdbool是否为新建文件
    diff.files.is_deletedbool是否为删除文件
    diff.files.is_binbool是否为二进制文件
    diff.files.is_lfs_filebool
    diff.files.is_renamedbool是否重命名
    diff.files.is_ambiguousbool
    diff.files.is_submodulebool是否为子模块
    diff.files.sections.file_namestring文件名称
    diff.files.sections.namestring
    diff.files.sections.lines.left_indexint
    diff.files.sections.lines.right_indexint
    diff.files.sections.lines.matchint
    diff.files.sections.lines.typeint
    diff.files.sections.lines.contentstring
    diff.files.sections.lines.section_pathstring
    diff.files.sections.lines.section_last_left_indexint
    diff.files.sections.lines.section_last_right_indexint
    diff.files.sections.lines.section_left_indexint
    diff.files.sections.lines.section_right_indexint
    diff.files.sections.lines.section_left_hunk_sizeint
    diff.files.sections.lines.section_right_hunk_sizeint
    + +
    +

    返回的JSON示例:

    +
    +
    {
    +    "commits_count": 1,
    +    "last_commit_sha": "80dd40214a58622312393b2ae693756a4781fab2",
    +    "commits": [
    +        {
    +            "author": {
    +                "id": "2",
    +                "login": "yystopf",
    +                "name": "heh",
    +                "type": "User",
    +                "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +            },
    +            "committer": {
    +                "id": "2",
    +                "login": "yystopf",
    +                "name": "heh",
    +                "type": "User",
    +                "image_url": "system/lets/letter_avatars/2/H/188_239_142/120.png"
    +            },
    +            "branch": "",
    +            "commit_message": "x拟增\n\nSigned-off-by: yystopf <yystopf@163.com>",
    +            "sha": "7e4d8bb3c28e24d4cd6b205f2eed32513e937524",
    +            "parent_shas": null
    +        }
    +    ],
    +    "diff": {
    +        "file_nums": 1,
    +        "total_addition": 1,
    +        "total_deletion": 0,
    +        "files": [
    +            {
    +                "name": "ceshi123",
    +                "oldname": "ceshi123",
    +                "addition": 1,
    +                "deletion": 0,
    +                "type": 1,
    +                "is_created": true,
    +                "is_deleted": false,
    +                "is_bin": false,
    +                "is_lfs_file": false,
    +                "is_renamed": false,
    +                "is_ambiguous": false,
    +                "is_submodule": false,
    +                "sections": [
    +                    {
    +                        "file_name": "ceshi123",
    +                        "name": "",
    +                        "lines": [
    +                            {
    +                                "left_index": 0,
    +                                "right_index": 0,
    +                                "match": 0,
    +                                "type": 4,
    +                                "content": "@@ -0,0 +1 @@",
    +                                "section_path": "ceshi123",
    +                                "section_last_left_index": 0,
    +                                "section_last_right_index": 0,
    +                                "section_left_index": 0,
    +                                "section_right_index": 1,
    +                                "section_left_hunk_size": 0,
    +                                "section_right_hunk_size": 0
    +                            },
    +                            {
    +                                "left_index": 0,
    +                                "right_index": 1,
    +                                "match": -1,
    +                                "type": 2,
    +                                "content": "+1111122222"
    +                            }
    +                        ]
    +                    }
    +                ],
    +                "is_incomplete": false,
    +                "is_incomplete_line_too_long": false,
    +                "is_protected": false
    +            }
    +        ]
    +    }
    +}
    +
    + +

    获取仓库webhooks列表

    +

    获取仓库webhooks列表

    + +
    +

    示例:

    +
    +
    curl -X GET \
    +http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
    +
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks.json')
    +

    HTTP 请求

    +

    GET /api/v1/:owner/:repo/webhooks.json

    +

    请求参数:

    + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    +

    返回字段说明:

    + + + + + + + + @@ -10094,9 +10379,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
    curl -X GET \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
     
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/v1/:owner/:repo/webhooks/:id.json

    -

    请求参数:

    +

    请求参数:

    参数类型字段说明
    id int id
    @@ -10128,7 +10413,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
    参数webhook ID
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -10251,214 +10536,8 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3.json
    curl -X POST \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks.json
     
    await octokit.request('POST /api/v1/yystopf/ceshi/webhooks.json')
    -

    HTTP 请求

    -

    POST /api/v1/:owner/:repo/webhooks.json

    -

    请求参数:

    -
    参数
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    webhook.urlstring目标url
    webhook.http_methodstringhttp方法, POST和GET
    webhook.content_typestringPOST Content Type
    webhook.secretstring密钥文本
    webhook.activebool是否激活
    webhook.branch_filterstring分支过滤
    webhook.eventsarray触发事件
    - -

    触发事件字段说明

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数含义
    create创建分支或标签
    delete分支或标签删除
    pushgit仓库推送
    pull_request合并请求
    pull_request_assign合并请求被指派
    pull_request_review_approved合并请求被批准
    pull_request_review_rejected合并请求被拒绝
    - -
    -

    请求的JSON示例:

    -
    -
    {
    -    "active": true, 
    -    "content_type": "json",
    -    "http_method": "GET",
    -    "secret": "123456",
    -    "url": "http://localhost:10000",
    -    "branch_filter": "*",
    -    "events": ["push"]
    -}
    -

    返回字段说明:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数类型字段说明
    idintid
    urlstring地址
    content_typestringPOST Content Type
    is_activebool是否激活
    typestring类型
    eventsarray触发事件
    create_timestring创建时间
    - -
    -

    返回的JSON示例:

    -
    -
    {
    -    "id": 68,
    -    "content_type": "json",
    -    "http_method": "GET",
    -    "url": "http://127.0.0.1:3000",
    -    "events": [
    -        "create",
    -        "delete",
    -        "push",
    -        "pull_request",
    -        "pull_request_assign",
    -        "pull_request_review_approved",
    -        "pull_request_review_rejected"
    -    ],
    -    "active": true,
    -    "branch_filter": "*",
    -    "created_at": "2022-06-23 15:52"
    -}
    -
    - -

    更新仓库webhook

    -

    更新仓库webhook

    - -
    -

    示例:

    -
    -
    curl -X PATCH \
    -http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    -
    await octokit.request('PATCH /api/v1/yystopf/ceshi/webhooks/7.json')
     

    HTTP 请求

    -

    PATCH /api/v1/:owner/:repo/webhooks/68.json

    +

    POST /api/v1/:owner/:repo/webhooks.json

    请求参数:

    @@ -10484,13 +10563,6 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json - - - - - - - @@ -10592,6 +10664,219 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json "events": ["push"] }

    返回字段说明:

    +
    项目标识identifier
    idstringwebhook id
    webhook.url
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数类型字段说明
    idintid
    urlstring地址
    content_typestringPOST Content Type
    is_activebool是否激活
    typestring类型
    eventsarray触发事件
    create_timestring创建时间
    + +
    +

    返回的JSON示例:

    +
    +
    {
    +    "id": 68,
    +    "content_type": "json",
    +    "http_method": "GET",
    +    "url": "http://127.0.0.1:3000",
    +    "events": [
    +        "create",
    +        "delete",
    +        "push",
    +        "pull_request",
    +        "pull_request_assign",
    +        "pull_request_review_approved",
    +        "pull_request_review_rejected"
    +    ],
    +    "active": true,
    +    "branch_filter": "*",
    +    "created_at": "2022-06-23 15:52"
    +}
    +
    + +

    更新仓库webhook

    +

    更新仓库webhook

    + +
    +

    示例:

    +
    +
    curl -X PATCH \
    +http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    +
    await octokit.request('PATCH /api/v1/yystopf/ceshi/webhooks/7.json')
    +

    HTTP 请求

    +

    PATCH /api/v1/:owner/:repo/webhooks/68.json

    +

    请求参数:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数必选默认类型字段说明
    ownerstring用户登录名
    repostring项目标识identifier
    idstringwebhook id
    webhook.urlstring目标url
    webhook.http_methodstringhttp方法, POST和GET
    webhook.content_typestringPOST Content Type
    webhook.secretstring密钥文本
    webhook.activebool是否激活
    webhook.branch_filterstring分支过滤
    webhook.eventsarray触发事件
    + +

    触发事件字段说明

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数含义
    create创建分支或标签
    delete分支或标签删除
    pushgit仓库推送
    pull_request合并请求
    pull_request_assign合并请求被指派
    pull_request_review_approved合并请求被批准
    pull_request_review_rejected合并请求被拒绝
    + +
    +

    请求的JSON示例:

    +
    +
    {
    +    "active": true, 
    +    "content_type": "json",
    +    "http_method": "GET",
    +    "secret": "123456",
    +    "url": "http://localhost:10000",
    +    "branch_filter": "*",
    +    "events": ["push"]
    +}
    +

    返回字段说明:

    返回的JSON示例:

    @@ -10626,9 +10911,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    curl -X DELETE \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
     
    await octokit.request('DELETE /api/v1/yystopf/ceshi/webhooks/7.json')
    -

    HTTP 请求

    +

    HTTP 请求

    DELETE /api/v1/:owner/:repo/webhooks/:id.json

    -

    请求参数:

    +

    请求参数:

    @@ -10660,7 +10945,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    参数webhook id
    -

    返回字段说明:

    +

    返回字段说明:

    返回的JSON示例:

    @@ -10681,9 +10966,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/7.json
    curl -X GET \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
     
    await octokit.request('GET /api/v1/yystopf/ceshi/webhooks/3/hooktasks.json')
    -

    HTTP 请求

    +

    HTTP 请求

    GET /api/v1/:owner/:repo/webhooks/:id/hooktasks.json

    -

    请求参数:

    +

    请求参数:

    @@ -10715,7 +11000,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
    参数webhook ID
    -

    返回字段说明:

    +

    返回字段说明:

    @@ -10952,9 +11237,9 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/hooktasks.json
    curl -X POST \
     http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
     
    await octokit.request('POST /api/v1/yystopf/ceshi/webhooks/3/tests.json')
    -

    HTTP 请求

    +

    HTTP 请求

    POST /api/v1/:owner/:repo/webhooks/:id/tests.json

    -

    请求参数:

    +

    请求参数:

    参数
    @@ -10986,7 +11271,7 @@ http://localhost:3000/api/v1/yystopf/ceshi/webhooks/3/tests.json
    参数webhook ID
    -

    返回字段说明:

    +

    返回字段说明:

    返回的JSON示例: