新增:批量提交文件支持参数选填
This commit is contained in:
parent
f417e42864
commit
35c6cb98db
|
@ -2,7 +2,11 @@ class Api::V1::Projects::ContentsController < Api::V1::BaseController
|
|||
before_action :require_operate_above, only: [:batch]
|
||||
|
||||
def batch
|
||||
@result_object = Api::V1::Projects::Contents::BatchCreateService.call(@project, batch_content_params, current_user&.gitea_token)
|
||||
@batch_content_params = batch_content_params
|
||||
# 处理下author和committer信息,如果没传则默认为当前用户信息
|
||||
@batch_content_params.merge!(author_email: current_user.mail, author_name: current_user.login) if batch_content_params[:author_email].blank? && batch_content_params[:author_name].blank?
|
||||
@batch_content_params.merge!(committer_email: current_user.mail, committer_name: current_user.login) if batch_content_params[:committer_email].blank? && batch_content_params[:committer_name].blank?
|
||||
@result_object = Api::V1::Projects::Contents::BatchCreateService.call(@project, @batch_content_params, current_user&.gitea_token)
|
||||
puts @result_object
|
||||
end
|
||||
|
||||
|
|
|
@ -1126,21 +1126,21 @@ await octokit.request('POST /api/v1/yystopf/ceshi/contents/batch.json')
|
|||
### 请求参数:
|
||||
参数 | 必选 | 默认 | 类型 | 字段说明
|
||||
--------- | ------- | ------- | -------- | ----------
|
||||
|owner |是| |string |用户登录名 |
|
||||
|repo |是| |string |项目标识identifier |
|
||||
|files.action_type |是| |string|操作类型 create: 创建 update: 更新 delete: 删除|
|
||||
|files.content |是| |string|文件内容|
|
||||
|files.encoding |是| |string|文件编码方式 text 文本 base64 加密|
|
||||
|files.file_path |是| |string|文件路径|
|
||||
|author_email |是| |string|作者邮箱|
|
||||
|author_name |是| |string|作者名称|
|
||||
|author_timeunix |是| |int|编码时间,精确到秒|
|
||||
|committer_email |是| |string|提交者邮箱|
|
||||
|committer_name |是| |string|提交者名称|
|
||||
|committer_timeunix|是| |int|提交时间戳,精确到秒|
|
||||
|branch |是| |string|提交分支|
|
||||
|new_branch |否| |string|如果需要创建新分支,这个需要填|
|
||||
|message |是| |string|提交信息|
|
||||
|owner |是| |string |用户登录名 |
|
||||
|repo |是| |string |项目标识identifier |
|
||||
|files.action_type |是| |string|操作类型 create: 创建 update: 更新 delete: 删除|
|
||||
|files.content |是| |string|文件内容|
|
||||
|files.encoding |是| |string|文件编码方式 text 文本 base64 加密|
|
||||
|files.file_path |是| |string|文件路径|
|
||||
|author_email |否| 当前用户邮箱 |string|作者邮箱,不填时需要与作者名称同时为空|
|
||||
|author_name |否| 当前用户标识 |string|作者名称,不填时需要与作者邮箱同时为空|
|
||||
|author_timeunix |否| 当前时间戳 |int|编码时间,精确到秒|
|
||||
|committer_email |否| 当前用户邮箱 |string|提交者邮箱,不填时需要与提交者名称同时为空|
|
||||
|committer_name |否| 当前用户标识 |string|提交者名称,不填时需要与提交者邮箱同时为空|
|
||||
|committer_timeunix|否| 当前时间戳 |int|提交时间戳,精确到秒|
|
||||
|branch |是| |string|提交分支|
|
||||
|new_branch |否| |string|如果需要创建新分支,这个需要填|
|
||||
|message |是| |string|提交信息|
|
||||
|
||||
> 请求的JSON示例:
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@ class Api::V1::Projects::Contents::BatchCreateService < ApplicationService
|
|||
@files = params[:files]
|
||||
@author_email = params[:author_email]
|
||||
@author_name = params[:author_name]
|
||||
@author_timeunix = params[:author_timeunix]
|
||||
@author_timeunix = params[:author_timeunix] || Time.now.to_i
|
||||
@branch = params[:branch]
|
||||
@committer_email = params[:committer_email]
|
||||
@committer_name = params[:committer_name]
|
||||
@committer_timeunix = params[:committer_timeunix]
|
||||
@committer_timeunix = params[:committer_timeunix] || Time.now.to_i
|
||||
@message = params[:message]
|
||||
@new_branch = params[:new_branch]
|
||||
end
|
||||
|
|
|
@ -9164,43 +9164,43 @@ http://localhost:3000/api/v1/yystopf/ceshi/contents/batch.json
|
|||
</tr>
|
||||
<tr>
|
||||
<td>author_email</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>否</td>
|
||||
<td>当前用户邮箱</td>
|
||||
<td>string</td>
|
||||
<td>作者邮箱</td>
|
||||
<td>作者邮箱,不填时需要与作者名称同时为空</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>author_name</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>否</td>
|
||||
<td>当前用户标识</td>
|
||||
<td>string</td>
|
||||
<td>作者名称</td>
|
||||
<td>作者名称,不填时需要与作者邮箱同时为空</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>author_timeunix</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>否</td>
|
||||
<td>当前时间戳</td>
|
||||
<td>int</td>
|
||||
<td>编码时间,精确到秒</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>committer_email</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>否</td>
|
||||
<td>当前用户邮箱</td>
|
||||
<td>string</td>
|
||||
<td>提交者邮箱</td>
|
||||
<td>提交者邮箱,不填时需要与提交者名称同时为空</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>committer_name</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>否</td>
|
||||
<td>当前用户标识</td>
|
||||
<td>string</td>
|
||||
<td>提交者名称</td>
|
||||
<td>提交者名称,不填时需要与提交者邮箱同时为空</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>committer_timeunix</td>
|
||||
<td>是</td>
|
||||
<td></td>
|
||||
<td>否</td>
|
||||
<td>当前时间戳</td>
|
||||
<td>int</td>
|
||||
<td>提交时间戳,精确到秒</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue