dev_forge
caicai8 5 years ago
commit 2469e0792f

@ -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|用户头像|

@ -328,7 +328,8 @@ class ApplicationController < ActionController::Base
def current_user
# User.current
User.find_by_id 50207
User.find_by_id 36401
# nil
end
## 默认输出json
@ -355,21 +356,21 @@ class ApplicationController < ActionController::Base
# 通关后,把最后一次成功的代码存到数据库
# type 0 创始内容, 1 最新内容
def game_passed_code(path, myshixun, game_id)
# 如果代码窗口是隐藏的,则不用保存代码
return if myshixun.shixun.hide_code || myshixun.shixun.vnc
file_content = git_fle_content myshixun.repo_path, path
#unless file_content.present?
# raise("获取文件代码异常")
#end
logger.info("#######game_id:#{game_id}, file_content:#{file_content}")
game_code = GameCode.where(:game_id => game_id, :path => path).first
if game_code.nil?
GameCode.create!(:game_id => game_id, :new_code => file_content, :path => path)
else
game_code.update_attributes!(:new_code => file_content)
end
end
# def game_passed_code(path, myshixun, game_id)
# # 如果代码窗口是隐藏的,则不用保存代码
# return if myshixun.shixun.hide_code || myshixun.shixun.vnc
# file_content = git_fle_content myshixun.repo_path, path
# #unless file_content.present?
# # raise("获取文件代码异常")
# #end
# logger.info("#######game_id:#{game_id}, file_content:#{file_content}")
# game_code = GameCode.where(:game_id => game_id, :path => path).first
# if game_code.nil?
# GameCode.create!(:game_id => game_id, :new_code => file_content, :path => path)
# else
# game_code.update_attributes!(:new_code => file_content)
# end
# end
# Post请求
def uri_post(uri, params)
@ -647,19 +648,20 @@ class ApplicationController < ActionController::Base
render_not_found("未找到’#{params[:id]}’相关的项目") unless @project
end
def find_project_with_identifier
@project = Project.find_by_identifier! params[:id]
render_not_found("未找到’#{params[:id]}’相关的项目") unless @project
end
def find_project_with_id
@project = Project.find params[:project_id]
@project = Project.find(params[:project_id] || params[:id])
rescue Exception => e
logger_error(e.message)
tip_exception(e.message)
end
def render_response(interactor)
if interactor.success?
render_ok
else
render_error(interactor.error)
end
interactor.success? ? render_ok : render_error(interactor.error)
end
private

@ -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

@ -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 }

Loading…
Cancel
Save