add: project menu list
This commit is contained in:
		
							parent
							
								
									f17e436d62
								
							
						
					
					
						commit
						a14459da50
					
				| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
class Projects::ProjectUnitsController < Projects::BaseController
 | 
			
		||||
  def create 
 | 
			
		||||
    if current_user.admin? ||  @project.owner?(current_user)
 | 
			
		||||
      ActiveRecord::Base.transaction do 
 | 
			
		||||
        ProjectUnit.update_by_unit_types!(@project, unit_types)
 | 
			
		||||
        render_ok
 | 
			
		||||
      end
 | 
			
		||||
    else 
 | 
			
		||||
      render_forbidden('你没有权限操作')
 | 
			
		||||
    end
 | 
			
		||||
  rescue Exception => e
 | 
			
		||||
    uid_logger_error(e.message)
 | 
			
		||||
    tip_exception(e.message)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  private 
 | 
			
		||||
  def unit_types
 | 
			
		||||
    params.fetch(:unit_types, [])
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -2,11 +2,26 @@ class ProjectsController < ApplicationController
 | 
			
		|||
  include ApplicationHelper
 | 
			
		||||
  include OperateProjectAbilityAble
 | 
			
		||||
  include ProjectsHelper
 | 
			
		||||
  before_action :require_login, except: %i[index branches group_type_list simple show fork_users praise_users watch_users recommend about]
 | 
			
		||||
  before_action :require_login, except: %i[index branches group_type_list simple show fork_users praise_users watch_users recommend about menu_list]
 | 
			
		||||
  before_action :load_project, except: %i[index group_type_list migrate create recommend]
 | 
			
		||||
  before_action :authorizate_user_can_edit_project!, only: %i[update]
 | 
			
		||||
  before_action :project_public?, only: %i[fork_users praise_users watch_users]
 | 
			
		||||
 | 
			
		||||
  def menu_list
 | 
			
		||||
    menu = []
 | 
			
		||||
 | 
			
		||||
    menu.append(menu_hash_by_name("home"))
 | 
			
		||||
    menu.append(menu_hash_by_name("code")) if @project.has_menu_permission("code")
 | 
			
		||||
    menu.append(menu_hash_by_name("issues")) if @project.has_menu_permission("issues")
 | 
			
		||||
    menu.append(menu_hash_by_name("pulls")) if @project.has_menu_permission("pulls")
 | 
			
		||||
    menu.append(menu_hash_by_name("devops")) if @project.has_menu_permission("devops")
 | 
			
		||||
    menu.append(menu_hash_by_name("versions")) if @project.has_menu_permission("versions")
 | 
			
		||||
    menu.append(menu_hash_by_name("activity"))
 | 
			
		||||
    menu.append(menu_hash_by_name("setting")) if current_user.admin? ||  @project.owner?(current_user)
 | 
			
		||||
    
 | 
			
		||||
    render json: menu
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def index
 | 
			
		||||
    scope = Projects::ListQuery.call(params)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,10 +11,8 @@ class RepositoriesController < ApplicationController
 | 
			
		|||
  before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
 | 
			
		||||
  before_action :get_statistics, only: %i[top_counts]
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def files
 | 
			
		||||
    result = @project.educoder? ? nil : Gitea::Repository::Files::GetService.call(@project.owner, @project.identifier, @ref)
 | 
			
		||||
    result = @project.educoder? ? nil : Gitea::Repository::Files::GetService.call(@owner, @project.identifier, @ref, params[:search], @owner.gitea_token)
 | 
			
		||||
    render json: result
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -168,6 +168,55 @@ Remember — a happy kitten is an authenticated kitten!
 | 
			
		|||
</aside>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## 项目导航
 | 
			
		||||
获取项目导航信息
 | 
			
		||||
 | 
			
		||||
> 示例:
 | 
			
		||||
 | 
			
		||||
```shell
 | 
			
		||||
curl -X GET \
 | 
			
		||||
http://localhost:3000/api/yystopf/ceshi/menu_list  | jq
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```javascript
 | 
			
		||||
await octokit.request('GET /api/yystopf/ceshi/menu_list')
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### HTTP 请求
 | 
			
		||||
`GET api/:owner/:repo/menu_list`
 | 
			
		||||
 | 
			
		||||
### 请求参数
 | 
			
		||||
参数    | 必选 | 默认 | 类型 | 字段说明
 | 
			
		||||
--------- | ------- | ------- | -------- | ----------
 | 
			
		||||
owner             |是| |string |用户登录名
 | 
			
		||||
repo             |是| |string |项目标识identifier
 | 
			
		||||
 | 
			
		||||
### 返回字段说明
 | 
			
		||||
参数  | 类型 | 字段说明
 | 
			
		||||
--------- | ----------- | -----------
 | 
			
		||||
menu_name     |string|导航名称, home:主页,code:代码库,issues:易修,pulls:合并请求,devops:工作流,versions:里程碑,activity:动态,setting:仓库设置
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
> 返回的JSON示例:
 | 
			
		||||
 | 
			
		||||
```json
 | 
			
		||||
[
 | 
			
		||||
    {
 | 
			
		||||
        "menu_name": "home"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "menu_name": "code"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "menu_name": "pulls"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
        "menu_name": "activity"
 | 
			
		||||
    }
 | 
			
		||||
]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## 项目主页
 | 
			
		||||
获取项目主页信息
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -212,6 +261,46 @@ attachments     |array|附件
 | 
			
		|||
Remember — a happy kitten is an authenticated kitten!
 | 
			
		||||
</aside>
 | 
			
		||||
 | 
			
		||||
## 更改项目导航
 | 
			
		||||
更改项目导航信息
 | 
			
		||||
 | 
			
		||||
> 示例:
 | 
			
		||||
 | 
			
		||||
```shell
 | 
			
		||||
curl -X POST \
 | 
			
		||||
-H  "accept: application/json" \
 | 
			
		||||
-H  "Content-Type: application/json" \
 | 
			
		||||
-d "{ \"unit_typs\": [\"code\", \"pulls\"]}" \
 | 
			
		||||
http://localhost:3000/api/yystopf/ceshi/project_units.json
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```javascript
 | 
			
		||||
await octokit.request('POST /api/yystopf/ceshi/project_units')
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### HTTP 请求
 | 
			
		||||
`POST /api/yystopf/ceshi/project_units`
 | 
			
		||||
 | 
			
		||||
### 请求参数
 | 
			
		||||
参数    | 必选 | 默认 | 类型 | 字段说明
 | 
			
		||||
--------- | ------- | ------- | -------- | ----------
 | 
			
		||||
|unit_types |是| |array    | 项目模块内容, 支持以下参数:code:代码库,issues:易修,pulls:合并请求,devops:工作流,versions:里程碑 |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### 返回字段说明:
 | 
			
		||||
参数  | 类型 | 字段说明
 | 
			
		||||
--------- | ----------- | -----------
 | 
			
		||||
|status          |int|返回状态, 0: 表示操作成功 |
 | 
			
		||||
|message         |string|返回信息说明|
 | 
			
		||||
 | 
			
		||||
> 返回的JSON示例:
 | 
			
		||||
 | 
			
		||||
```json
 | 
			
		||||
{
 | 
			
		||||
    "status": 0,
 | 
			
		||||
    "message": "success"
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 创建项目
 | 
			
		||||
创建项目
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,11 +129,11 @@ await octokit.request('GET /api/yystopf/ceshi/detail.json')
 | 
			
		|||
|identifier                       |string   |项目标识   |
 | 
			
		||||
|name                             |string   |项目名称   |
 | 
			
		||||
|issues_count                     |int      |项目issue数量|
 | 
			
		||||
|pull_requests_count              |int      |项目issue数量|
 | 
			
		||||
|project_identifier               |int      |项目issue数量|
 | 
			
		||||
|praises_count                    |int      |项目issue数量|
 | 
			
		||||
|forked_count                     |int      |项目issue数量|
 | 
			
		||||
|watchers_count                   |int      |项目issue数量|
 | 
			
		||||
|pull_requests_count              |int      |项目合并请求数量|
 | 
			
		||||
|project_identifier               |int      |项目标识|
 | 
			
		||||
|praises_count                    |int      |项目点赞数量|
 | 
			
		||||
|forked_count                     |int      |项目复刻数量|
 | 
			
		||||
|watchers_count                   |int      |项目关注数量|
 | 
			
		||||
|versions_count                   |int      |项目里程碑数量|
 | 
			
		||||
|version_releases_count           |int      |项目发行版数量|
 | 
			
		||||
|version_releasesed_count         |int      |项目发行版已发行数量|
 | 
			
		||||
| 
						 | 
				
			
			@ -645,7 +645,9 @@ await octokit.request('GET /api/jasder/jasder_test/collaborators.json')
 | 
			
		|||
> 示例:
 | 
			
		||||
 | 
			
		||||
```shell
 | 
			
		||||
curl -X GET http://localhost:3000/api/yystopf/ceshi/files.json
 | 
			
		||||
curl -X GET \
 | 
			
		||||
-d "ref=develop" \
 | 
			
		||||
http://localhost:3000/api/yystopf/ceshi/files.json
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```javascript
 | 
			
		||||
| 
						 | 
				
			
			@ -658,8 +660,10 @@ await octokit.request('GET /api/yystopf/ceshi/files.json')
 | 
			
		|||
### 请求参数:
 | 
			
		||||
参数    | 必选 | 默认 | 类型 | 字段说明
 | 
			
		||||
--------- | ------- | ------- | -------- | ----------
 | 
			
		||||
|owner             |是| |string |用户登录名  |
 | 
			
		||||
|repo             |是| |string |项目标识identifier  |
 | 
			
		||||
|owner    |是|      |string |用户登录名  |
 | 
			
		||||
|repo     |是|      |string |项目标识identifier  |
 | 
			
		||||
|search   |否|      |string |文件搜索关键词  |
 | 
			
		||||
|ref      |是|      |string |分支名,默认为仓库默认分支  |
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### 返回字段说明:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,9 @@
 | 
			
		|||
module ProjectsHelper
 | 
			
		||||
  def menu_hash_by_name(name)
 | 
			
		||||
    {
 | 
			
		||||
      menu_name: name
 | 
			
		||||
    }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def render_zh_project_type(project_type)
 | 
			
		||||
    case project_type
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,4 +89,7 @@ module ProjectOperable
 | 
			
		|||
    member.member_roles.create!(role: role)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def has_menu_permission(unit_type)
 | 
			
		||||
    self.project_units.where(unit_type: unit_type).exists?
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,6 +113,7 @@ class Project < ApplicationRecord
 | 
			
		|||
  has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
 | 
			
		||||
  has_one :project_detail, dependent: :destroy
 | 
			
		||||
  has_many :team_projects, dependent: :destroy
 | 
			
		||||
  has_many :project_units, dependent: :destroy
 | 
			
		||||
 | 
			
		||||
  after_save :check_project_members
 | 
			
		||||
  scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,35 @@
 | 
			
		|||
# == Schema Information
 | 
			
		||||
#
 | 
			
		||||
# Table name: project_units
 | 
			
		||||
#
 | 
			
		||||
#  id         :integer          not null, primary key
 | 
			
		||||
#  project_id :integer
 | 
			
		||||
#  unit_type  :integer
 | 
			
		||||
#  created_at :datetime         not null
 | 
			
		||||
#  updated_at :datetime         not null
 | 
			
		||||
#
 | 
			
		||||
# Indexes
 | 
			
		||||
#
 | 
			
		||||
#  index_project_units_on_project_id  (project_id)
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
class ProjectUnit < ApplicationRecord
 | 
			
		||||
  belongs_to :project
 | 
			
		||||
 | 
			
		||||
  enum unit_type: {code: 1, issues: 2, pulls: 3, devops: 4, versions: 5}
 | 
			
		||||
 | 
			
		||||
  validates :unit_type, uniqueness: { scope: :project_id}
 | 
			
		||||
 | 
			
		||||
  def self.init_types(project_id)
 | 
			
		||||
    ProjectUnit::unit_types.each do |_, v|
 | 
			
		||||
      self.create!(project_id: project_id, unit_type: v)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self.update_by_unit_types!(project, types) 
 | 
			
		||||
    project.project_units.where.not(unit_type: types).each(&:destroy!)
 | 
			
		||||
    types.each do |type|
 | 
			
		||||
      project.project_units.find_or_create_by!(unit_type: type)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -13,6 +13,7 @@ class Projects::CreateService < ApplicationService
 | 
			
		|||
    ActiveRecord::Base.transaction do
 | 
			
		||||
      if @project.save!
 | 
			
		||||
        Project.update_common_projects_count!
 | 
			
		||||
        ProjectUnit.init_types(@project.id)
 | 
			
		||||
        Repositories::CreateService.new(user, @project, repository_params).call
 | 
			
		||||
      else
 | 
			
		||||
        Rails.logger.info("#############___________create_project_erros______###########{@project.errors.messages}")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -369,6 +369,7 @@ Rails.application.routes.draw do
 | 
			
		|||
 | 
			
		||||
      resource :projects, path: '/', except: [:show, :edit] do
 | 
			
		||||
        member do
 | 
			
		||||
          get :menu_list
 | 
			
		||||
          get :branches
 | 
			
		||||
          get :simple
 | 
			
		||||
          get :watchers, to: 'projects#watch_users'
 | 
			
		||||
| 
						 | 
				
			
			@ -528,6 +529,7 @@ Rails.application.routes.draw do
 | 
			
		|||
 | 
			
		||||
      scope module: :projects do
 | 
			
		||||
        resources :teams, only: [:index, :create, :destroy]
 | 
			
		||||
        resources :project_units, only: [:create]
 | 
			
		||||
        scope do
 | 
			
		||||
          get(
 | 
			
		||||
            '/blob/*id/diff',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
class CreateProjectUnits < ActiveRecord::Migration[5.2]
 | 
			
		||||
  def change
 | 
			
		||||
    create_table :project_units do |t|
 | 
			
		||||
      t.references :project 
 | 
			
		||||
      t.integer :unit_type
 | 
			
		||||
 | 
			
		||||
      t.timestamps
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -342,9 +342,15 @@
 | 
			
		|||
                  <li>
 | 
			
		||||
                    <a href="#43137706c6" class="toc-h2 toc-link" data-title="推荐项目">推荐项目</a>
 | 
			
		||||
                  </li>
 | 
			
		||||
                  <li>
 | 
			
		||||
                    <a href="#42ee1e960d" class="toc-h2 toc-link" data-title="项目导航">项目导航</a>
 | 
			
		||||
                  </li>
 | 
			
		||||
                  <li>
 | 
			
		||||
                    <a href="#144f9deebe" class="toc-h2 toc-link" data-title="项目主页">项目主页</a>
 | 
			
		||||
                  </li>
 | 
			
		||||
                  <li>
 | 
			
		||||
                    <a href="#870a1a6092" class="toc-h2 toc-link" data-title="更改项目导航">更改项目导航</a>
 | 
			
		||||
                  </li>
 | 
			
		||||
                  <li>
 | 
			
		||||
                    <a href="#80f5dfd187" class="toc-h2 toc-link" data-title="创建项目">创建项目</a>
 | 
			
		||||
                  </li>
 | 
			
		||||
| 
						 | 
				
			
			@ -972,17 +978,17 @@ http://localhost:3000/api/projects/recommend  | jq
 | 
			
		|||
<aside class="success">
 | 
			
		||||
Remember — a happy kitten is an authenticated kitten!
 | 
			
		||||
</aside>
 | 
			
		||||
<h2 id='144f9deebe'>项目主页</h2>
 | 
			
		||||
<p>获取项目主页信息</p>
 | 
			
		||||
<h2 id='42ee1e960d'>项目导航</h2>
 | 
			
		||||
<p>获取项目导航信息</p>
 | 
			
		||||
 | 
			
		||||
<blockquote>
 | 
			
		||||
<p>示例:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
 | 
			
		||||
http://localhost:3000/api/jasder/forgeplus/about  | jq
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/jasder/forgeplus/about</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
http://localhost:3000/api/yystopf/ceshi/menu_list  | jq
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/yystopf/ceshi/menu_list</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-3'>HTTP 请求</h3>
 | 
			
		||||
<p><code>GET api/:owner/:repo/about</code></p>
 | 
			
		||||
<p><code>GET api/:owner/:repo/menu_list</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-2'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
| 
						 | 
				
			
			@ -1017,6 +1023,74 @@ http://localhost:3000/api/jasder/forgeplus/about  | jq
 | 
			
		|||
</tr>
 | 
			
		||||
</thead><tbody>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>menu_name</td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>导航名称, home:主页,code:代码库,issues:易修,pulls:合并请求,devops:工作流,versions:里程碑,activity:动态,setting:仓库设置</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
 | 
			
		||||
<blockquote>
 | 
			
		||||
<p>返回的JSON示例:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">[</span><span class="w">
 | 
			
		||||
    </span><span class="p">{</span><span class="w">
 | 
			
		||||
        </span><span class="nl">"menu_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"home"</span><span class="w">
 | 
			
		||||
    </span><span class="p">},</span><span class="w">
 | 
			
		||||
    </span><span class="p">{</span><span class="w">
 | 
			
		||||
        </span><span class="nl">"menu_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"code"</span><span class="w">
 | 
			
		||||
    </span><span class="p">},</span><span class="w">
 | 
			
		||||
    </span><span class="p">{</span><span class="w">
 | 
			
		||||
        </span><span class="nl">"menu_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"pulls"</span><span class="w">
 | 
			
		||||
    </span><span class="p">},</span><span class="w">
 | 
			
		||||
    </span><span class="p">{</span><span class="w">
 | 
			
		||||
        </span><span class="nl">"menu_name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"activity"</span><span class="w">
 | 
			
		||||
    </span><span class="p">}</span><span class="w">
 | 
			
		||||
</span><span class="p">]</span><span class="w">
 | 
			
		||||
</span></code></pre></div><h2 id='144f9deebe'>项目主页</h2>
 | 
			
		||||
<p>获取项目主页信息</p>
 | 
			
		||||
 | 
			
		||||
<blockquote>
 | 
			
		||||
<p>示例:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
 | 
			
		||||
http://localhost:3000/api/jasder/forgeplus/about  | jq
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/jasder/forgeplus/about</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-4'>HTTP 请求</h3>
 | 
			
		||||
<p><code>GET api/:owner/:repo/about</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-3'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
<th>必选</th>
 | 
			
		||||
<th>默认</th>
 | 
			
		||||
<th>类型</th>
 | 
			
		||||
<th>字段说明</th>
 | 
			
		||||
</tr>
 | 
			
		||||
</thead><tbody>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>owner</td>
 | 
			
		||||
<td>是</td>
 | 
			
		||||
<td></td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>用户登录名</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>repo</td>
 | 
			
		||||
<td>是</td>
 | 
			
		||||
<td></td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>项目标识identifier</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='b302a98fa6-4'>返回字段说明</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
<th>类型</th>
 | 
			
		||||
<th>字段说明</th>
 | 
			
		||||
</tr>
 | 
			
		||||
</thead><tbody>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>identifier</td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>project's identifier</td>
 | 
			
		||||
| 
						 | 
				
			
			@ -1045,7 +1119,66 @@ http://localhost:3000/api/jasder/forgeplus/about  | jq
 | 
			
		|||
<aside class="success">
 | 
			
		||||
Remember — a happy kitten is an authenticated kitten!
 | 
			
		||||
</aside>
 | 
			
		||||
<h2 id='80f5dfd187'>创建项目</h2>
 | 
			
		||||
<h2 id='870a1a6092'>更改项目导航</h2>
 | 
			
		||||
<p>更改项目导航信息</p>
 | 
			
		||||
 | 
			
		||||
<blockquote>
 | 
			
		||||
<p>示例:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST <span class="se">\</span>
 | 
			
		||||
<span class="nt">-H</span>  <span class="s2">"accept: application/json"</span> <span class="se">\</span>
 | 
			
		||||
<span class="nt">-H</span>  <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span>
 | 
			
		||||
<span class="nt">-d</span> <span class="s2">"{ </span><span class="se">\"</span><span class="s2">unit_typs</span><span class="se">\"</span><span class="s2">: [</span><span class="se">\"</span><span class="s2">code</span><span class="se">\"</span><span class="s2">, </span><span class="se">\"</span><span class="s2">pulls</span><span class="se">\"</span><span class="s2">]}"</span> <span class="se">\</span>
 | 
			
		||||
http://localhost:3000/api/yystopf/ceshi/project_units.json
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/yystopf/ceshi/project_units</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-5'>HTTP 请求</h3>
 | 
			
		||||
<p><code>POST /api/yystopf/ceshi/project_units</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-4'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
<th>必选</th>
 | 
			
		||||
<th>默认</th>
 | 
			
		||||
<th>类型</th>
 | 
			
		||||
<th>字段说明</th>
 | 
			
		||||
</tr>
 | 
			
		||||
</thead><tbody>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>unit_types</td>
 | 
			
		||||
<td>是</td>
 | 
			
		||||
<td></td>
 | 
			
		||||
<td>array</td>
 | 
			
		||||
<td>项目模块内容, 支持以下参数:code:代码库,issues:易修,pulls:合并请求,devops:工作流,versions:里程碑</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='7447e4874e'>返回字段说明:</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
<th>类型</th>
 | 
			
		||||
<th>字段说明</th>
 | 
			
		||||
</tr>
 | 
			
		||||
</thead><tbody>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>status</td>
 | 
			
		||||
<td>int</td>
 | 
			
		||||
<td>返回状态, 0: 表示操作成功</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>message</td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>返回信息说明</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
 | 
			
		||||
<blockquote>
 | 
			
		||||
<p>返回的JSON示例:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
 | 
			
		||||
    </span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w">
 | 
			
		||||
    </span><span class="nl">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"success"</span><span class="w">
 | 
			
		||||
</span><span class="p">}</span><span class="w">
 | 
			
		||||
</span></code></pre></div><h2 id='80f5dfd187'>创建项目</h2>
 | 
			
		||||
<p>创建项目</p>
 | 
			
		||||
 | 
			
		||||
<blockquote>
 | 
			
		||||
| 
						 | 
				
			
			@ -1062,9 +1195,9 @@ Remember — a happy kitten is an authenticated kitten!
 | 
			
		|||
<span class="nt">-d</span> <span class="s2">"license_id=1"</span> <span class="se">\</span>
 | 
			
		||||
http://localhost:3000/api/projects.json
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/projects.json</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-4'>HTTP 请求</h3>
 | 
			
		||||
</code></pre></div><h3 id='http-6'>HTTP 请求</h3>
 | 
			
		||||
<p><code>POST api/projects</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-3'>请求参数</h3>
 | 
			
		||||
<h3 id='1f9ac54b15-5'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1138,7 +1271,7 @@ http://localhost:3000/api/projects.json
 | 
			
		|||
<td>项目是否私有, true:为私有,false: 公开,默认为公开</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='b302a98fa6-4'>返回字段说明</h3>
 | 
			
		||||
<h3 id='b302a98fa6-5'>返回字段说明</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1180,9 +1313,9 @@ http://localhost:3000/api/projects.json
 | 
			
		|||
<span class="nt">-d</span> <span class="s2">"project_language_id=2"</span> <span class="se">\</span>
 | 
			
		||||
http://localhost:3000/api/projects/migrate.json
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/projects/migrate.json</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-5'>HTTP 请求</h3>
 | 
			
		||||
</code></pre></div><h3 id='http-7'>HTTP 请求</h3>
 | 
			
		||||
<p><code>POST api/projects/migrate.json</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-4'>请求参数</h3>
 | 
			
		||||
<h3 id='1f9ac54b15-6'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1270,7 +1403,7 @@ http://localhost:3000/api/projects/migrate.json
 | 
			
		|||
<td>项目是否私有, true:为私有,false: 非私有,默认为公开</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='b302a98fa6-5'>返回字段说明</h3>
 | 
			
		||||
<h3 id='b302a98fa6-6'>返回字段说明</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1305,9 +1438,9 @@ http://localhost:3000/api/projects/migrate.json
 | 
			
		|||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/repositories/1244/sync_mirror.json
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/repositories/1244/sync_mirror.json</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-6'>HTTP 请求</h3>
 | 
			
		||||
</code></pre></div><h3 id='http-8'>HTTP 请求</h3>
 | 
			
		||||
<p><code>POST api/repositories/:id/sync_mirror.json</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-5'>请求参数</h3>
 | 
			
		||||
<h3 id='1f9ac54b15-7'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1325,7 +1458,7 @@ http://localhost:3000/api/projects/migrate.json
 | 
			
		|||
<td>仓库id</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='b302a98fa6-6'>返回字段说明</h3>
 | 
			
		||||
<h3 id='b302a98fa6-7'>返回字段说明</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1360,9 +1493,9 @@ http://localhost:3000/api/projects/migrate.json
 | 
			
		|||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/jasder/forgeplus/forks.json
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">POST /api/jaser/jasder_test/forks.json</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-7'>HTTP 请求</h3>
 | 
			
		||||
</code></pre></div><h3 id='http-9'>HTTP 请求</h3>
 | 
			
		||||
<p><code>POST api/:owner/:repo/forks.json</code></p>
 | 
			
		||||
<h3 id='1f9ac54b15-6'>请求参数</h3>
 | 
			
		||||
<h3 id='1f9ac54b15-8'>请求参数</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1387,7 +1520,7 @@ http://localhost:3000/api/projects/migrate.json
 | 
			
		|||
<td>项目标识identifier</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='b302a98fa6-7'>返回字段说明</h3>
 | 
			
		||||
<h3 id='b302a98fa6-8'>返回字段说明</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
<tr>
 | 
			
		||||
<th>参数</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -1672,27 +1805,27 @@ http://localhost:3000/api/projects/migrate.json
 | 
			
		|||
<tr>
 | 
			
		||||
<td>pull_requests_count</td>
 | 
			
		||||
<td>int</td>
 | 
			
		||||
<td>项目issue数量</td>
 | 
			
		||||
<td>项目合并请求数量</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>project_identifier</td>
 | 
			
		||||
<td>int</td>
 | 
			
		||||
<td>项目issue数量</td>
 | 
			
		||||
<td>项目标识</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>praises_count</td>
 | 
			
		||||
<td>int</td>
 | 
			
		||||
<td>项目issue数量</td>
 | 
			
		||||
<td>项目点赞数量</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>forked_count</td>
 | 
			
		||||
<td>int</td>
 | 
			
		||||
<td>项目issue数量</td>
 | 
			
		||||
<td>项目复刻数量</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>watchers_count</td>
 | 
			
		||||
<td>int</td>
 | 
			
		||||
<td>项目issue数量</td>
 | 
			
		||||
<td>项目关注数量</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>versions_count</td>
 | 
			
		||||
| 
						 | 
				
			
			@ -2635,7 +2768,9 @@ http://localhost:3000/api/jasder/jasder_test/collaborators.json
 | 
			
		|||
<blockquote>
 | 
			
		||||
<p>示例:</p>
 | 
			
		||||
</blockquote>
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET http://localhost:3000/api/yystopf/ceshi/files.json
 | 
			
		||||
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span>
 | 
			
		||||
<span class="nt">-d</span> <span class="s2">"ref=develop"</span> <span class="se">\</span>
 | 
			
		||||
http://localhost:3000/api/yystopf/ceshi/files.json
 | 
			
		||||
</code></pre></div><div class="highlight"><pre class="highlight javascript tab-javascript"><code><span class="k">await</span> <span class="nx">octokit</span><span class="p">.</span><span class="nx">request</span><span class="p">(</span><span class="dl">'</span><span class="s1">GET /api/yystopf/ceshi/files.json</span><span class="dl">'</span><span class="p">)</span>
 | 
			
		||||
</code></pre></div><h3 id='http-11'>HTTP 请求</h3>
 | 
			
		||||
<p><code>GET /api/:owner/:repo/files</code></p>
 | 
			
		||||
| 
						 | 
				
			
			@ -2663,6 +2798,20 @@ http://localhost:3000/api/jasder/jasder_test/collaborators.json
 | 
			
		|||
<td>string</td>
 | 
			
		||||
<td>项目标识identifier</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>search</td>
 | 
			
		||||
<td>否</td>
 | 
			
		||||
<td></td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>文件搜索关键词</td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr>
 | 
			
		||||
<td>ref</td>
 | 
			
		||||
<td>是</td>
 | 
			
		||||
<td></td>
 | 
			
		||||
<td>string</td>
 | 
			
		||||
<td>分支名,默认为仓库默认分支</td>
 | 
			
		||||
</tr>
 | 
			
		||||
</tbody></table>
 | 
			
		||||
<h3 id='7447e4874e-11'>返回字段说明:</h3>
 | 
			
		||||
<table><thead>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,5 @@
 | 
			
		|||
require 'rails_helper'
 | 
			
		||||
 | 
			
		||||
RSpec.describe ProjectUnit, type: :model do
 | 
			
		||||
  pending "add some examples to (or delete) #{__FILE__}"
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
		Reference in New Issue