FIX repository show api

dev_forge
Jasder 5 years ago
parent bfb58c72b9
commit ddb3ff5f5b

@ -470,10 +470,10 @@ http://localhost:3000/api/projects/3263 | jq
|参数名|必选|类型|说明| |参数名|必选|类型|说明|
-|-|-|- -|-|-|-
|id |是|int |项目id | |id |是|int |项目id |
|name ||string |项目名称 | |name ||string |项目名称 |
|description ||string |项目描述 | |description ||string |项目描述 |
|project_category_id||int |项目类别id | |project_category_id||int |项目类别id |
|project_language_id||int |项目语言id | |project_language_id||int |项目语言id |
|private |否|boolean|项目是否私有, true为私有false: 公开,默认为公开 | |private |否|boolean|项目是否私有, true为私有false: 公开,默认为公开 |
@ -1274,11 +1274,15 @@ http://localhost:3000/api/18816895620/mirror_demo | jq
|参数名|类型|说明| |参数名|类型|说明|
-|-|- -|-|-
|identifier |string|仓库标识| |identifier |string|仓库标识|
|project_id |int|项目id|
|project_identifier|string|项目标识|
|praises_count |int|点赞数量| |praises_count |int|点赞数量|
|forked_count |int|fork数量| |forked_count |int|fork数量|
|watchers_count |int|关注数量| |watchers_count |int|关注数量|
|branches_count |int|分支数量| |branches_count |int|分支数量|
|commits_count |int|总提交记录数量| |commits_count |int|总提交记录数量|
|praised |boolean|当前登录用户是否已点赞true:已点赞fasle:未点赞, 用户未登录状态为null|
|watched |boolean|当前登录用户是否已关注true:已关注fasle:未关注, 用户未登录状态为null|
|permission |string|当前登录用户对该仓库的操作权限, Manager:管理员,可以在线编辑文件、在线新建文件、可以设置仓库的基本信息; Developer:开发人员,可在线编辑文件、在线新建文件、不能设置仓库信息; Reporter: 报告人员只能查看信息不能设置仓库信息、不能在线编辑文件、不能在线新建文件用户未登录时也会返回Reporter, 说明也只有读取文件的权限 | |permission |string|当前登录用户对该仓库的操作权限, Manager:管理员,可以在线编辑文件、在线新建文件、可以设置仓库的基本信息; Developer:开发人员,可在线编辑文件、在线新建文件、不能设置仓库信息; Reporter: 报告人员只能查看信息不能设置仓库信息、不能在线编辑文件、不能在线新建文件用户未登录时也会返回Reporter, 说明也只有读取文件的权限 |
|mirror_url |string|镜像地址, 只有通过镜像过来的项目才会有这个地址| |mirror_url |string|镜像地址, 只有通过镜像过来的项目才会有这个地址|
|author |object|提交用户| |author |object|提交用户|
@ -1289,6 +1293,8 @@ http://localhost:3000/api/18816895620/mirror_demo | jq
返回值 返回值
``` ```
{ {
"project_id": 3263,
"project_identifier": "mirror_demo",
"identifier": "mirror_demo", "identifier": "mirror_demo",
"praises_count": 1, "praises_count": 1,
"forked_count": 0, "forked_count": 0,
@ -1296,6 +1302,8 @@ http://localhost:3000/api/18816895620/mirror_demo | jq
"branches_count": 6, "branches_count": 6,
"commits_count": 105, "commits_count": 105,
"permission": "Manager", "permission": "Manager",
"watched": true,
"praised": true,
"mirror_url": "https://gitea.com/CasperVector/slew.git", "mirror_url": "https://gitea.com/CasperVector/slew.git",
"author": { "author": {
"name": "18816895620", "name": "18816895620",
@ -1488,7 +1496,7 @@ http://localhost:3000/api/projects/3263/praise_tread | jq
|参数名|类型|说明| |参数名|类型|说明|
-|-|- -|-|-
|total_count |int|总条数| |total_count |int|总条数|
|praises |array|关注数据| |praises |array|点赞数据|
|-- name |string|用户名称| |-- name |string|用户名称|
|-- login |string|用户标识/登录名(login)| |-- login |string|用户标识/登录名(login)|
|-- image_url |string|用户头像| |-- image_url |string|用户头像|

@ -3,6 +3,7 @@ class RepositoriesController < ApplicationController
before_action :find_user, :find_repository, :authorizate! before_action :find_user, :find_repository, :authorizate!
def show def show
@project = @repo.project
@branches_count = Gitea::Repository::BranchesService.new(@user, @repo.identifier).call.size @branches_count = Gitea::Repository::BranchesService.new(@user, @repo.identifier).call.size
@commits_count = Gitea::Repository::Commits::ListService.new(@user, @repo.identifier).call[:total_count] @commits_count = Gitea::Repository::Commits::ListService.new(@user, @repo.identifier).call[:total_count]
end end

@ -1,9 +1,13 @@
json.identifier @repo.identifier json.identifier @repo.identifier
json.project_id @project.id
json.project_identifier @project.identifier
json.praises_count @repo.project.praises_count json.praises_count @repo.project.praises_count
json.forked_count @repo.project.forked_count json.forked_count @repo.project.forked_count
json.watchers_count @repo.project.watchers_count json.watchers_count @repo.project.watchers_count
json.branches_count @branches_count json.branches_count @branches_count
json.commits_count @commits_count json.commits_count @commits_count
json.permission render_edit_project_permission(current_user, @repo.project) json.permission render_edit_project_permission(current_user, @project)
json.mirror_url @repo.mirror_url json.mirror_url @repo.mirror_url
json.watched current_user&.watched?(@project)
json.praised current_user&.liked?(@project)
json.partial! 'author', locals: { user: @repo.user } json.partial! 'author', locals: { user: @repo.user }

Loading…
Cancel
Save