diff --git a/README.md b/README.md index 311e91aea..9d456b372 100644 --- a/README.md +++ b/README.md @@ -470,10 +470,10 @@ http://localhost:3000/api/projects/3263 | jq |参数名|必选|类型|说明| -|-|-|- |id |是|int |项目id | -|name |是|string |项目名称 | -|description |是|string |项目描述 | -|project_category_id|是|int |项目类别id | -|project_language_id|是|int |项目语言id | +|name |否|string |项目名称 | +|description |否|string |项目描述 | +|project_category_id|否|int |项目类别id | +|project_language_id|否|int |项目语言id | |private |否|boolean|项目是否私有, true:为私有,false: 公开,默认为公开 | @@ -1274,11 +1274,15 @@ http://localhost:3000/api/18816895620/mirror_demo | jq |参数名|类型|说明| -|-|- |identifier |string|仓库标识| +|project_id |int|项目id| +|project_identifier|string|项目标识| |praises_count |int|点赞数量| |forked_count |int|fork数量| |watchers_count |int|关注数量| |branches_count |int|分支数量| |commits_count |int|总提交记录数量| +|praised |boolean|当前登录用户是否已点赞,true:已点赞,fasle:未点赞, 用户未登录状态为null| +|watched |boolean|当前登录用户是否已关注,true:已关注,fasle:未关注, 用户未登录状态为null| |permission |string|当前登录用户对该仓库的操作权限, Manager:管理员,可以在线编辑文件、在线新建文件、可以设置仓库的基本信息; Developer:开发人员,可在线编辑文件、在线新建文件、不能设置仓库信息; Reporter: 报告人员,只能查看信息,不能设置仓库信息、不能在线编辑文件、不能在线新建文件;用户未登录时也会返回Reporter, 说明也只有读取文件的权限 | |mirror_url |string|镜像地址, 只有通过镜像过来的项目才会有这个地址| |author |object|提交用户| @@ -1289,6 +1293,8 @@ http://localhost:3000/api/18816895620/mirror_demo | jq 返回值 ``` { + "project_id": 3263, + "project_identifier": "mirror_demo", "identifier": "mirror_demo", "praises_count": 1, "forked_count": 0, @@ -1296,6 +1302,8 @@ http://localhost:3000/api/18816895620/mirror_demo | jq "branches_count": 6, "commits_count": 105, "permission": "Manager", + "watched": true, + "praised": true, "mirror_url": "https://gitea.com/CasperVector/slew.git", "author": { "name": "18816895620", @@ -1488,7 +1496,7 @@ http://localhost:3000/api/projects/3263/praise_tread | jq |参数名|类型|说明| -|-|- |total_count |int|总条数| -|praises |array|关注数据| +|praises |array|点赞数据| |-- name |string|用户名称| |-- login |string|用户标识/登录名(login)| |-- image_url |string|用户头像| diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index c68c4eaa8..9a53d6191 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -3,6 +3,7 @@ class RepositoriesController < ApplicationController before_action :find_user, :find_repository, :authorizate! def show + @project = @repo.project @branches_count = Gitea::Repository::BranchesService.new(@user, @repo.identifier).call.size @commits_count = Gitea::Repository::Commits::ListService.new(@user, @repo.identifier).call[:total_count] end diff --git a/app/views/repositories/show.json.jbuilder b/app/views/repositories/show.json.jbuilder index 1fc9700f7..7b1a5abe1 100644 --- a/app/views/repositories/show.json.jbuilder +++ b/app/views/repositories/show.json.jbuilder @@ -1,9 +1,13 @@ json.identifier @repo.identifier +json.project_id @project.id +json.project_identifier @project.identifier json.praises_count @repo.project.praises_count json.forked_count @repo.project.forked_count json.watchers_count @repo.project.watchers_count json.branches_count @branches_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.watched current_user&.watched?(@project) +json.praised current_user&.liked?(@project) json.partial! 'author', locals: { user: @repo.user }