ADD edit repository api

dev_forge
Jasder 5 years ago
parent 00d69dd934
commit a0bd1bd9b4

@ -451,6 +451,42 @@ curl -X GET http://localhost:3000/api/projects/3263 | jq
```
---
#### 编辑仓库信息
```
GET /api/:login/:repo_identifier/edit.json
```
*示例*
```
curl -X GET http://localhost:3000/api/18816895620/mirror_demo/edit.json | jq
```
*返回参数说明:*
|参数名|类型|说明|
-|-|-
|identifier |string |仓库标识 |
|project_id |int|项目id|
|project_name |string|项目名称|
|project_identifier |string|项目标识|
|project_description |string|项目简介|
|project_category_id |int|项目类别id|
|project_language_id |int|项目语言id|
返回值
```
{
"identifier": "mirror_demo",
"project_id": 3263,
"project_name": "ni项目",
"project_identifier": "mirror_demo",
"project_description": "my first project mirror_demo",
"project_category_id": 1,
"project_language_id": 2
}
```
---
#### 修改项目信息
```
PATCH api/projects/:id

@ -1,6 +1,7 @@
class RepositoriesController < ApplicationController
include ApplicationHelper
before_action :find_user, :find_repository, :authorizate!
before_action :require_login, only: %i[edit]
def show
@project = @repo.project
@ -43,6 +44,9 @@ class RepositoriesController < ApplicationController
@tags = Gitea::Repository::Tags::ListService.new(@user, @repo.identifier).call
end
def edit
end
private
def authorizate!
if @repo.hidden? && @repo.user != current_user

@ -0,0 +1,7 @@
json.identifier @repo.identifier
json.project_id @repo&.project.id
json.project_name @repo&.project.name
json.project_identifier @repo.project.identifier
json.project_description @repo&.project.description
json.project_category_id @repo&.project.project_category_id
json.project_language_id @repo&.project.project_language_id

@ -161,6 +161,7 @@ Rails.application.routes.draw do
end
get '/:login/:repo_identifier', to: 'repositories#show'
get '/:login/:repo_identifier/edit', to: 'repositories#edit'
resources :repositories, path: '/:login/:repo_identifier', only: [:index] do
collection do
get :entries

Loading…
Cancel
Save