fix meger develop branch

This commit is contained in:
jasder 2021-06-17 17:30:11 +08:00
commit 80a6ad6712
78 changed files with 1699 additions and 249 deletions

View File

@ -32,7 +32,7 @@ class Admins::AuthSchoolsController < Admins::BaseController
def search_manager def search_manager
school = School.find_by(id: params[:school_id]) school = School.find_by(id: params[:school_id])
user_ids = school&.ec_school_users&.pluck(:user_id) user_ids = school&.ec_school_users&.pluck(:user_id)
@users = User.where.not(id: user_ids).where("CONCAT_WS(lastname, firstname, nickname) like ?", "%#{params[:name].strip.to_s}%").limit(10) @users = User.where.not(id: user_ids).where("CONCAT(lastname, firstname) like ? OR nickname like ?", "%#{params[:name].strip.to_s}%", "%#{params[:name].strip.to_s}%").limit(10)
end end
# 添加认证学校管理员 # 添加认证学校管理员

View File

@ -2,8 +2,8 @@ class Admins::FaqsController < Admins::BaseController
before_action :find_faq, only: [:edit,:update, :destroy] before_action :find_faq, only: [:edit,:update, :destroy]
def index def index
sort_by = params[:sort_by] ||= 'updated_at' sort_by = Faq.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'updated_at'
sort_direction = params[:sort_direction] ||= 'desc' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
collection = Faq.search_question(keyword).order("#{sort_by} #{sort_direction}") collection = Faq.search_question(keyword).order("#{sort_by} #{sort_direction}")

View File

@ -32,8 +32,8 @@ class Admins::LaboratoriesController < Admins::BaseController
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword.present? if keyword.present?
like_sql = 'shixuns.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword '\ like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword '\
'OR mirror_repositories.name LIKE :keyword' 'users.nickname LIKE :keyword OR mirror_repositories.name LIKE :keyword'
shixuns = shixuns.joins(:user, :mirror_repositories).where(like_sql, keyword: "%#{keyword}%") shixuns = shixuns.joins(:user, :mirror_repositories).where(like_sql, keyword: "%#{keyword}%")
end end
@ -48,7 +48,7 @@ class Admins::LaboratoriesController < Admins::BaseController
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword.present? if keyword.present?
like_sql = 'subjects.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword' like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword OR users.nickname LIKE :keyword'
subjects = subjects.joins(:user).where(like_sql, keyword: "%#{keyword}%") subjects = subjects.joins(:user).where(like_sql, keyword: "%#{keyword}%")
end end

View File

@ -3,8 +3,8 @@ class Admins::ProjectCategoriesController < Admins::BaseController
before_action :validate_names, only: [:create, :update] before_action :validate_names, only: [:create, :update]
def index def index
sort_by = params[:sort_by] ||= 'created_at' sort_by = ProjectCategory.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
sort_direction = params[:sort_direction] ||= 'desc' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
q = ProjectCategory.ransack(name_cont: params[:name]) q = ProjectCategory.ransack(name_cont: params[:name])
project_categories = q.result(distinct: true).order("#{sort_by} #{sort_direction}") project_categories = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_categories = paginate(project_categories) @project_categories = paginate(project_categories)

View File

@ -3,8 +3,8 @@ class Admins::ProjectIgnoresController < Admins::BaseController
before_action :validate_params, only: [:create, :update] before_action :validate_params, only: [:create, :update]
def index def index
sort_by = params[:sort_by] ||= 'created_at' sort_by = Ignore.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
sort_direction = params[:sort_direction] ||= 'desc' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
q = Ignore.ransack(name_cont: params[:search]) q = Ignore.ransack(name_cont: params[:search])
project_ignores = q.result(distinct: true).order("#{sort_by} #{sort_direction}") project_ignores = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_ignores = paginate(project_ignores) @project_ignores = paginate(project_ignores)

View File

@ -3,8 +3,8 @@ class Admins::ProjectLanguagesController < Admins::BaseController
before_action :validate_names, only: [:create, :update] before_action :validate_names, only: [:create, :update]
def index def index
sort_by = params[:sort_by] ||= 'created_at' sort_by = ProjectLanguage.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
sort_direction = params[:sort_direction] ||= 'desc' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
q = ProjectLanguage.ransack(name_cont: params[:search]) q = ProjectLanguage.ransack(name_cont: params[:search])
project_languages = q.result(distinct: true).order("#{sort_by} #{sort_direction}") project_languages = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_languages = paginate(project_languages) @project_languages = paginate(project_languages)

View File

@ -3,8 +3,8 @@ class Admins::ProjectLicensesController < Admins::BaseController
before_action :validate_params, only: [:create, :update] before_action :validate_params, only: [:create, :update]
def index def index
sort_by = params[:sort_by] ||= 'created_at' sort_by = License.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
sort_direction = params[:sort_direction] ||= 'desc' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
q = License.ransack(name_cont: params[:search]) q = License.ransack(name_cont: params[:search])
project_licenses = q.result(distinct: true).order("#{sort_by} #{sort_direction}") project_licenses = q.result(distinct: true).order("#{sort_by} #{sort_direction}")
@project_licenses = paginate(project_licenses) @project_licenses = paginate(project_licenses)

View File

@ -1,9 +1,8 @@
class Admins::ProjectsController < Admins::BaseController class Admins::ProjectsController < Admins::BaseController
def index def index
sort_by = params[:sort_by] ||= 'created_on' sort_by = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_on'
sort_direction = params[:sort_direction] ||= 'desc' sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
search = params[:search].to_s.strip search = params[:search].to_s.strip
projects = Project.where("name like ?", "%#{search}%").order("#{sort_by} #{sort_direction}") projects = Project.where("name like ?", "%#{search}%").order("#{sort_by} #{sort_direction}")
@projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score) @projects = paginate projects.includes(:owner, :members, :issues, :versions, :attachments, :project_score)

View File

@ -615,8 +615,8 @@ class ApplicationController < ActionController::Base
end end
# 排序 # 排序
rorder = option[:order] || "updated_at" rorder = UserExtension.column_names.include?(option[:order]) ? option[:order] : "updated_at"
b_order = option[:b_order] || "desc" b_order = %w(desc asc).include?(option[:b_order]) ? option[:b_order] : "desc"
if rorder == "created_at" || rorder == "work_score" if rorder == "created_at" || rorder == "work_score"
work_list = work_list.order("graduation_works.#{rorder} #{b_order}") work_list = work_list.order("graduation_works.#{rorder} #{b_order}")
elsif rorder == "student_id" elsif rorder == "student_id"

View File

@ -0,0 +1,13 @@
class AppliedProjectsController < ApplicationController
before_action :require_login
def create
@applied_project = Projects::ApplyJoinService.call(current_user, applied_params)
rescue Projects::ApplyJoinService::Error => ex
render_error(ex.message)
end
private
def applied_params
params.require(:applied_project).permit(:code, :role)
end
end

View File

@ -3,13 +3,12 @@ class ComposesController < ApplicationController
before_action :find_compose, except: [:index, :new,:create] before_action :find_compose, except: [:index, :new,:create]
def index def index
@order_type = params[:order] || "created_at"
@search_name = params[:search] @search_name = params[:search]
composes = Compose.compose_includes composes = Compose.compose_includes
if @search_name.present? if @search_name.present?
composes = composes.where("title like ?", "%#{@search_name}%") composes = composes.where("title like ?", "%#{@search_name}%")
end end
composes = composes.order("#{@order_type} desc") composes = composes.order("#{order_type} desc")
@page = params[:page] || 1 @page = params[:page] || 1
@limit = params[:limit] || 15 @limit = params[:limit] || 15
@composes_size = composes.size @composes_size = composes.size
@ -96,4 +95,8 @@ class ComposesController < ApplicationController
end end
end end
def order_type
Compose.column_names.include?(params[:order_type]) ? params[:order_type] : 'created_at'
end
end end

View File

@ -7,9 +7,6 @@ class IssueTagsController < ApplicationController
def index def index
order_name = params[:order_name] || "created_at"
order_type = params[:order_type] || "desc"
issue_tags = @project.issue_tags.order("#{order_name} #{order_type}") issue_tags = @project.issue_tags.order("#{order_name} #{order_type}")
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user)) @user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
@page = params[:page] || 1 @page = params[:page] || 1
@ -138,4 +135,14 @@ class IssueTagsController < ApplicationController
end end
end end
private
def order_name
IssueTag.column_names.include?(params[:order_name]) ? params[:order_name] : 'created_at'
end
def order_type
%w(desc asc).include?(params[:order_type]) ? params[:order_type] : 'desc'
end
end end

View File

@ -17,13 +17,17 @@ class IssuesController < ApplicationController
issues = @project.issues.issue_issue.issue_index_includes issues = @project.issues.issue_issue.issue_index_includes
issues = issues.where(is_private: false) unless @user_admin_or_member issues = issues.where(is_private: false) unless @user_admin_or_member
@all_issues_size = issues.size @all_issues = issues
@open_issues_size = issues.where.not(status_id: 5).size @filter_issues = @all_issues
@close_issues_size = issues.where(status_id: 5).size @filter_issues = @filter_issues.where.not(status_id: 5) if params[:status_type].to_i == 1
@assign_to_me_size = issues.where(assigned_to_id: current_user&.id).size @filter_issues = @filter_issues.where(status_id: 5) if params[:status_type].to_i == 2
@my_published_size = issues.where(author_id: current_user&.id).size @filter_issues = @filter_issues.where("subject LIKE ? OR description LIKE ? ", "%#{params[:search]}%", "%#{params[:search]}%") if params[:search].present?
@open_issues = @all_issues.where.not(status_id: 5)
@close_issues = @all_issues.where(status_id: 5)
@assign_to_me = @filter_issues.where(assigned_to_id: current_user&.id)
@my_published = @filter_issues.where(author_id: current_user&.id)
scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "Issue") scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "Issue")
@issues_size = scopes.size @issues_size = @filter_issues.size
@issues = paginate(scopes) @issues = paginate(scopes)
respond_to do |format| respond_to do |format|

View File

@ -18,7 +18,7 @@ class MembersController < ApplicationController
scope = @project.members.includes(:roles, user: :user_extension) scope = @project.members.includes(:roles, user: :user_extension)
search = params[:search].to_s.downcase search = params[:search].to_s.downcase
role = params[:role].to_s role = params[:role].to_s
scope = scope.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.mail, users.nickname)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present? scope = scope.joins(:user).merge(User.like(search))
scope = scope.joins(:roles).where("roles.name LIKE ?", "%#{role}%") if role.present? scope = scope.joins(:roles).where("roles.name LIKE ?", "%#{role}%") if role.present?
@total_count = scope.size @total_count = scope.size

View File

@ -5,7 +5,7 @@ class Organizations::OrganizationUsersController < Organizations::BaseController
def index def index
@organization_users = @organization.organization_users.includes(:user) @organization_users = @organization.organization_users.includes(:user)
search = params[:search].to_s.downcase search = params[:search].to_s.downcase
@organization_users = @organization_users.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.mail, users.nickname)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present? @organization_users = @organization_users.joins(:user).merge(User.like(search))
@organization_users = kaminari_paginate(@organization_users) @organization_users = kaminari_paginate(@organization_users)
end end

View File

@ -88,11 +88,11 @@ class Organizations::OrganizationsController < Organizations::BaseController
end end
def sort_by def sort_by
params.fetch(:sort_by, "created_at") OrganizationExtension.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
end end
def sort_direction def sort_direction
params.fetch(:sort_direction, "desc") %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
end end
end end

View File

@ -36,10 +36,10 @@ class Organizations::ProjectsController < Organizations::BaseController
end end
def sort def sort
params.fetch(:sort_by, "updated_on") Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'updated_on'
end end
def sort_direction def sort_direction
params.fetch(:sort_direction, "desc") %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
end end
end end

View File

@ -8,7 +8,7 @@ class Organizations::TeamUsersController < Organizations::BaseController
@team_users = @team.team_users.includes(:user) @team_users = @team.team_users.includes(:user)
search = params[:search].to_s.downcase search = params[:search].to_s.downcase
@team_users = @team_users.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.mail, users.nickname)) LIKE ?", "%#{search.split(" ").join('|')}%") if search.present? @team_users = @team_users.joins(:user).merge(User.like(search))
@team_users = kaminari_paginate(@team_users) @team_users = kaminari_paginate(@team_users)
end end

View File

@ -12,14 +12,16 @@ class PullRequestsController < ApplicationController
# @issues = Gitea::PullRequest::ListService.new(@user,@repository.try(:identifier)).call #通过gitea获取 # @issues = Gitea::PullRequest::ListService.new(@user,@repository.try(:identifier)).call #通过gitea获取
issues = @project.issues.issue_pull_request.issue_index_includes.includes(pull_request: :user) issues = @project.issues.issue_pull_request.issue_index_includes.includes(pull_request: :user)
issues = issues.where(is_private: false) unless current_user.present? && (current_user.admin? || @project.member?(current_user)) issues = issues.where(is_private: false) unless current_user.present? && (current_user.admin? || @project.member?(current_user))
@all_issues_size = issues.size @all_issues = issues.distinct
@open_issues_size = issues.joins(:pull_request).where(pull_requests: {status: 0}).size @filter_issues = @all_issues
@close_issues_size = issues.joins(:pull_request).where(pull_requests: {status: 2}).size @filter_issues = @filter_issues.where("subject LIKE ? OR description LIKE ? ", "%#{params[:search]}%", "%#{params[:search]}%") if params[:search].present?
@merged_issues_size = issues.joins(:pull_request).where(pull_requests: {status: 1}).size @open_issues = @filter_issues.joins(:pull_request).where(pull_requests: {status: 0})
@close_issues = @filter_issues.joins(:pull_request).where(pull_requests: {status: 2})
@merged_issues = @filter_issues.joins(:pull_request).where(pull_requests: {status: 1})
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user)) @user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "PullRequest") scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "PullRequest")
@issues_size = scopes.size @issues_size = @filter_issues.size
@issues = paginate(scopes) @issues = paginate(scopes)
end end

View File

@ -9,7 +9,7 @@ class Users::AppliedMessagesController < Users::BaseController
private private
def check_auth def check_auth
return render_forbidden unless observed_logged_user? return render_forbidden unless current_user.admin? || observed_logged_user?
end end
def view_messages def view_messages

View File

@ -0,0 +1,39 @@
class Users::AppliedProjectsController < Users::BaseController
before_action :check_auth
before_action :find_applied_project, except: [:index]
before_action :find_project, except: [:index]
def index
@applied_projects = AppliedProject.where(project_id: observed_user.full_admin_projects)
@applied_projects = paginate @applied_projects.order("created_at desc")
end
# 接受申请
def accept
@applied_project = Projects::AcceptJoinService.call(current_user, @applied_project)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
end
# 拒绝申请
def refuse
@applied_project = Projects::RefuseJoinService.call(current_user, @applied_project)
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
end
private
def check_auth
return render_forbidden unless current_user.admin? || observed_logged_user?
end
def find_applied_project
@applied_project = AppliedProject.find_by_id params[:id]
end
def find_project
@project = @applied_project.project
end
end

View File

@ -28,7 +28,7 @@ class Users::AppliedTransferProjectsController < Users::BaseController
private private
def check_auth def check_auth
return render_forbidden unless observed_logged_user? return render_forbidden unless current_user.admin? || observed_logged_user?
end end
def find_applied_transfer_project def find_applied_transfer_project

View File

@ -1,8 +1,8 @@
class Users::BanksController < Users::BaseController class Users::BanksController < Users::BaseController
before_action :params_filter before_action :params_filter
def index def index
order = params[:order] || "updated_at" order = CourseList.column_names.include?(params[:order]) ? params[:order] : "updated_at"
sort = params[:sort] || "desc" sort = %w(desc asc).includes?(params[:sort]) ? params[:sort] : "desc"
@banks = @object_type.classify.constantize.where(@object_filter) @banks = @object_type.classify.constantize.where(@object_filter)
@course_lists = CourseList.where(id: @banks.pluck(:course_list_id)) @course_lists = CourseList.where(id: @banks.pluck(:course_list_id))
@banks = @banks.where(course_list_id: params[:tag_id]) unless params[:tag_id].blank? @banks = @banks.where(course_list_id: params[:tag_id]) unless params[:tag_id].blank?

View File

@ -16,10 +16,10 @@ class Users::OrganizationsController < Users::BaseController
private private
def sort_by def sort_by
params.fetch(:sort_by, "created_at") OrganizationExtension.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'created_at'
end end
def sort_direction def sort_direction
params.fetch(:sort_direction, "desc") %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
end end
end end

View File

@ -28,13 +28,15 @@ class UsersController < ApplicationController
def show def show
#待办事项,现在未做 #待办事项,现在未做
if User.current.login == @user.login if User.current.admin? || User.current.login == @user.login
@waiting_applied_messages = @user.applied_messages.waiting @waiting_applied_messages = @user.applied_messages.waiting
@common_applied_transfer_projects = AppliedTransferProject.where(owner_id: @user.id).common + AppliedTransferProject.where(owner_id: Organization.joins(team_users: :team).where(team_users: {user_id: @user.id}, teams: {authorize: %w(admin owner)} )).common @common_applied_transfer_projects = AppliedTransferProject.where(owner_id: @user.id).common + AppliedTransferProject.where(owner_id: Organization.joins(team_users: :team).where(team_users: {user_id: @user.id}, teams: {authorize: %w(admin owner)} )).common
@undo_events = @waiting_applied_messages.size + @common_applied_transfer_projects.size @common_applied_projects = AppliedProject.where(project_id: @user.full_admin_projects).common
@undo_events = @waiting_applied_messages.size + @common_applied_transfer_projects.size + @common_applied_projects.size
else else
@waiting_applied_messages = AppliedMessage.none @waiting_applied_messages = AppliedMessage.none
@common_applied_transfer_projects = AppliedTransferProject.none @common_applied_transfer_projects = AppliedTransferProject.none
@common_applied_projects = AppliedProject.none
@undo_events = 0 @undo_events = 0
end end
#用户的组织数量 #用户的组织数量
@ -63,8 +65,7 @@ class UsersController < ApplicationController
def fan_users def fan_users
watchers = @user.watchers.includes(:user).order("watchers.created_at desc") watchers = @user.watchers.includes(:user).order("watchers.created_at desc")
watchers = watchers.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.login, users.nickname)) LIKE ?", "%#{params[:search].split(" ").join('|')}%") if params[:search].present? watchers = watchers.joins(:user).merge(User.like(params[:search]))
@watchers_count = watchers.size @watchers_count = watchers.size
@watchers = paginate(watchers) @watchers = paginate(watchers)
end end

View File

@ -11,7 +11,7 @@ class UsersForPrivateMessagesController < ApplicationController
return return
end end
users = users.where('LOWER(CONCAT_WS(lastname, firstname, nickname)) LIKE ?', "%#{keyword}%") users = users.like(keyword)
@users = users.limit(10).includes(:user_extension) @users = users.limit(10).includes(:user_extension)
end end

View File

@ -7,8 +7,6 @@ class VersionsController < ApplicationController
def index def index
return render_not_found unless @project.has_menu_permission("versions") return render_not_found unless @project.has_menu_permission("versions")
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user)) @user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
order_name = params[:order_name] || "created_on"
order_type = params[:order_type] || "desc"
status = params[:status] status = params[:status]
versions = @project.versions.version_includes versions = @project.versions.version_includes
@open_versions_size = versions.where(status: "open")&.size @open_versions_size = versions.where(status: "open")&.size
@ -27,9 +25,6 @@ class VersionsController < ApplicationController
end end
def show def show
order_name = params[:order_name] || "created_on"
order_type = params[:order_type] || "desc"
version_issues = @version.issues.issue_includes version_issues = @version.issues.issue_includes
status_type = params[:status_type] || "1" status_type = params[:status_type] || "1"
@ -167,4 +162,12 @@ class VersionsController < ApplicationController
end end
end end
def order_name
Version.column_names.include?(params[:order_name]) ? params[:order_name] : 'created_on'
end
def order_type
%w(desc asc).include?(params[:order_type]) ? params[:order_type] : 'desc'
end
end end

View File

@ -86,7 +86,7 @@ class Weapps::CoursesController < Weapps::BaseController
end end
if search.present? if search.present?
@teacher_list = @teacher_list.joins(:user).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) like ?", "%#{search}%") @teacher_list = @teacher_list.joins(:user).where("LOWER(CONCAT(users.lastname, users.firstname)) like ? OR users.nickname like ?", "%#{search}%", "%#{search}%")
end end
@teacher_list_size = @teacher_list.size @teacher_list_size = @teacher_list.size
@ -127,8 +127,8 @@ class Weapps::CoursesController < Weapps::BaseController
@students = CourseMember.students(@course) @students = CourseMember.students(@course)
if search.present? if search.present?
@students = @students.joins(user: :user_extension).where("LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) like ? or @students = @students.joins(user: :user_extension).where("LOWER(CONCAT(users.lastname, users.firstname)) like ? or users.nickname like ? or
user_extensions.student_id like ?", "%#{search}%", "%#{search}%") user_extensions.student_id like ?", "%#{search}%", "%#{search}%", "%#{search}%")
end end
if course_group_id.present? if course_group_id.present?

View File

@ -86,7 +86,7 @@ class ZipsController < ApplicationController
#搜索 #搜索
if params[:search].present? if params[:search].present?
@ex_users = @ex_users.joins(user: :user_extension).where("CONCAT_WS(lastname, firstname, nickname) like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") @ex_users = @ex_users.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR nickname like ? OR student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%", "%#{params[:search]}%")
end end
default_ex_users_size = @ex_users&.size default_ex_users_size = @ex_users&.size
@ -130,8 +130,8 @@ class ZipsController < ApplicationController
end end
unless params[:search].blank? unless params[:search].blank?
@all_student_works = @all_student_works.joins(user: :user_extension).where("CONCAT_WS(lastname, firstname, nickname) like ? @all_student_works = @all_student_works.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? or nickname like ?
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%") or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%", "%#{params[:search]}%")
end end
student_work_sizes = @all_student_works&.size student_work_sizes = @all_student_works&.size

View File

@ -1,5 +1,91 @@
# Projects # Projects
## 申请加入项目
申请加入项目
> 示例:
```shell
curl -X POST http://localhost:3000/api/applied_projects.json
```
```javascript
await octokit.request('POST /api/appliedr_projects.json')
```
### HTTP 请求
`POST /api/applied_projects.json`
### 请求参数
参数 | 必选 | 默认 | 类型 | 字段说明
--------- | ------- | ------- | -------- | ----------
|applied_project.code |是| |string |邀请码 |
|applied_project.role |否| |string |项目权限reporter: 报告者, developer: 开发者manager管理员 |
> 请求的JSON示例
```json
{
"applied_project": {
"code": "1una34",
"role": "developer"
}
}
```
### 返回字段说明
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|id |int |申请id |
|status |string |申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝|
|time_ago |string |项目申请创建的时间 |
|project.id |int |申请项目的id |
|project.identifier |string |申请项目的标识 |
|project.name |string |申请项目的名称 |
|project.description |string |申请项目的描述 |
|project.is_public |bool |申请项目是否公开 |
|project.owner.id |bool |申请项目拥有者id |
|project.owner.type |string |申请项目拥有者类型 |
|project.owner.name |string |申请项目拥有者昵称 |
|project.owner.login |string |申请项目拥有者标识 |
|project.owner.image_url |string |申请项目拥有者头像 |
|user.id |int |申请创建者的id |
|user.type |string |申请创建者的类型 |
|user.name |string |申请创建者的名称 |
|user.login |string |申请创建者的标识 |
|user.image_url |string |申请创建者头像 |
> 返回的JSON示例:
```json
{
"project": {
"id": 74,
"identifier": "hehuisssjssjjsjs",
"name": "hehuisssjssjjsjs",
"description": "wwww",
"is_public": false,
"owner": {
"id": 10,
"type": "User",
"name": "testforge1",
"login": "testforge1",
"image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png"
}
},
"user": {
"id": 6,
"type": "User",
"name": "何慧",
"login": "yystopf",
"image_url": "images/avatars/User/6?t=1622513134"
},
"id": 7,
"status": "common",
"created_at": "2021-06-09 16:41",
"time_ago": "1分钟前"
}
```
## 获取项目列表 ## 获取项目列表
获取项目列表,也可以更加相关条件过滤搜素 获取项目列表,也可以更加相关条件过滤搜素

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Date: 2021-03-01 10:35:21 * @Date: 2021-03-01 10:35:21
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-03 10:18:53 * @LastEditTime: 2021-06-11 16:28:51
* @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md * @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md
--> -->
# Users # Users
@ -1002,11 +1002,11 @@ await octokit.request('GET /api/users/:login/applied_messages.json')
|applied.user.name |string |通知主体的迁移创建者的名称 | |applied.user.name |string |通知主体的迁移创建者的名称 |
|applied.user.login |string |通知主体的迁移创建者的标识 | |applied.user.login |string |通知主体的迁移创建者的标识 |
|applied.user.image_url |string |通知主体的迁移创建者头像 | |applied.user.image_url |string |通知主体的迁移创建者头像 |
|applied.owner.id |int |通知主体的迁移接受者的id | |applied_user.id |int |通知发起者的id |
|applied.owner.type |string |通知主体的迁移接受者的类型 | |applied_user.type |string |通知发起者的类型 |
|applied.owner.name |string |通知主体的迁移接受者的名称 | |applied_user.name |string |通知发起者的名称 |
|applied.owner.login |string |通知主体的迁移接受者的标识 | |applied_user.login |string |通知发起者的标识 |
|applied.owner.image_url |string |通知主体的迁移接受者头像 | |applied_user.image_url |string |通知发起者头像 |
|applied_type |string |通知类型 | |applied_type |string |通知类型 |
|name |string | 通知内容 | |name |string | 通知内容 |
|viewed |string|是否已读waiting:未读,viewed:已读| |viewed |string|是否已读waiting:未读,viewed:已读|
@ -1020,6 +1020,48 @@ await octokit.request('GET /api/users/:login/applied_messages.json')
{ {
"total_count": 5, "total_count": 5,
"applied_messages": [ "applied_messages": [
{
"applied": {
"project": {
"id": 74,
"identifier": "hehuisssjssjjsjs",
"name": "hehuisssjssjjsjs",
"description": "wwww",
"is_public": false,
"owner": {
"id": 10,
"type": "User",
"name": "testforge1",
"login": "testforge1",
"image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png"
}
},
"user": {
"id": 6,
"type": "User",
"name": "何慧",
"login": "yystopf",
"image_url": "images/avatars/User/6?t=1622513134"
},
"id": 6,
"status": "accepted",
"created_at": "2021-06-09 16:34",
"time_ago": "1分钟前"
},
"applied_user": {
"id": 6,
"type": "User",
"name": "何慧",
"login": "yystopf",
"image_url": "images/avatars/User/6?t=1622513134"
},
"applied_type": "AppliedProject",
"name": "已通过你加入【hehuisssjssjjsjs】仓库的申请。",
"viewed": "waiting",
"status": "successed",
"created_at": "2021-06-09 16:34",
"time_ago": "1分钟前"
},
{ {
"applied": { "applied": {
"project": { "project": {
@ -1344,4 +1386,240 @@ await octokit.request('GET /api/users/:login/applied_transfer_projects/:id/refus
"created_at": "2021-04-25 18:06", "created_at": "2021-04-25 18:06",
"time_ago": "16小时前" "time_ago": "16小时前"
} }
```
## 待办事项-项目申请
待办事项-项目申请
> 示例:
```shell
curl -X GET http://localhost:3000/api/users/yystopf/applied_projects.json
```
```javascript
await octokit.request('GET /api/users/:login/applied_projects.json')
```
### HTTP 请求
`GET /api/users/:login/applied_projects.json`
### 请求字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|login |string |用户标识 |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|id |int |申请id |
|status |string |申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝|
|time_ago |string |申请创建的时间 |
|project.id |int |申请项目的id |
|project.identifier |string |申请项目的标识 |
|project.name |string |申请项目的名称 |
|project.description |string |申请项目的描述 |
|project.is_public |bool |申请项目是否公开 |
|project.owner.id |bool |申请项目拥有者id |
|project.owner.type |string |申请项目拥有者类型 |
|project.owner.name |string |申请项目拥有者昵称 |
|project.owner.login |string |申请项目拥有者标识 |
|project.owner.image_url |string |申请项目拥有者头像 |
|user.id |int |申请创建者的id |
|user.type |string |申请创建者的类型 |
|user.name |string |申请创建者的名称 |
|user.login |string |申请创建者的标识 |
|user.image_url |string |申请创建者头像 |
> 返回的JSON示例:
```json
{
"total_count": 4,
"applied_transfer_projects": [
{
"project": {
"id": 74,
"identifier": "hehuisssjssjjsjs",
"name": "hehuisssjssjjsjs",
"description": "wwww",
"is_public": false,
"owner": {
"id": 10,
"type": "User",
"name": "testforge1",
"login": "testforge1",
"image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png"
}
},
"user": {
"id": 6,
"type": "User",
"name": "何慧",
"login": "yystopf",
"image_url": "images/avatars/User/6?t=1622513134"
},
"id": 7,
"status": "common",
"created_at": "2021-06-09 16:41",
"time_ago": "7分钟前"
},
...
]
}
```
## 用户接受申请
用户接受申请
> 示例:
```shell
curl -X POST http://localhost:3000/api/users/yystopf/applied_projects/2/accept.json
```
```javascript
await octokit.request('GET /api/users/:login/applied_projects/:id/accept.json')
```
### HTTP 请求
`GET /api/users/:login/applied_projects/:id/accept.json`
### 请求字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|login |string |用户标识 |
|id |int |申请id |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|id |int |申请id |
|status |string |申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝|
|time_ago |string |申请创建的时间 |
|project.id |int |申请项目的id |
|project.identifier |string |申请项目的标识 |
|project.name |string |申请项目的名称 |
|project.description |string |申请项目的描述 |
|project.is_public |bool |申请项目是否公开 |
|project.owner.id |bool |申请项目拥有者id |
|project.owner.type |string |申请项目拥有者类型 |
|project.owner.name |string |申请项目拥有者昵称 |
|project.owner.login |string |申请项目拥有者标识 |
|project.owner.image_url |string |申请项目拥有者头像 |
|user.id |int |申请创建者的id |
|user.type |string |申请创建者的类型 |
|user.name |string |申请创建者的名称 |
|user.login |string |申请创建者的标识 |
|user.image_url |string |申请创建者头像 |
> 返回的JSON示例:
```json
{
"project": {
"id": 74,
"identifier": "hehuisssjssjjsjs",
"name": "hehuisssjssjjsjs",
"description": "wwww",
"is_public": false,
"owner": {
"id": 10,
"type": "User",
"name": "testforge1",
"login": "testforge1",
"image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png"
}
},
"user": {
"id": 6,
"type": "User",
"name": "何慧",
"login": "yystopf",
"image_url": "images/avatars/User/6?t=1622513134"
},
"id": 7,
"status": "accept",
"created_at": "2021-06-09 16:41",
"time_ago": "7分钟前"
}
```
## 用户拒绝申请
用户拒绝申请
> 示例:
```shell
curl -X POST http://localhost:3000/api/users/yystopf/applied_projects/2/refuse.json
```
```javascript
await octokit.request('GET /api/users/:login/applied_projects/:id/refuse.json')
```
### HTTP 请求
`GET /api/users/:login/applied_projects/:id/refuse.json`
### 请求字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|login |string |用户标识 |
|id |int |申请id |
### 返回字段说明:
参数 | 类型 | 字段说明
--------- | ----------- | -----------
|id |int |申请id |
|status |string |申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝|
|time_ago |string |申请创建的时间 |
|project.id |int |申请项目的id |
|project.identifier |string |申请项目的标识 |
|project.name |string |申请项目的名称 |
|project.description |string |申请项目的描述 |
|project.is_public |bool |申请项目是否公开 |
|project.owner.id |bool |申请项目拥有者id |
|project.owner.type |string |申请项目拥有者类型 |
|project.owner.name |string |申请项目拥有者昵称 |
|project.owner.login |string |申请项目拥有者标识 |
|project.owner.image_url |string |申请项目拥有者头像 |
|user.id |int |申请创建者的id |
|user.type |string |申请创建者的类型 |
|user.name |string |申请创建者的名称 |
|user.login |string |申请创建者的标识 |
|user.image_url |string |申请创建者头像 |
> 返回的JSON示例:
```json
{
"project": {
"id": 74,
"identifier": "hehuisssjssjjsjs",
"name": "hehuisssjssjjsjs",
"description": "wwww",
"is_public": false,
"owner": {
"id": 10,
"type": "User",
"name": "testforge1",
"login": "testforge1",
"image_url": "system/lets/letter_avatars/2/T/19_237_174/120.png"
}
},
"user": {
"id": 6,
"type": "User",
"name": "何慧",
"login": "yystopf",
"image_url": "images/avatars/User/6?t=1622513134"
},
"id": 7,
"status": "accept",
"created_at": "2021-06-09 16:41",
"time_ago": "7分钟前"
}
``` ```

View File

@ -23,7 +23,7 @@ module Projects
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
gitea_result = Gitea::Repository::Members::AddService.new(owner, project.identifier, collaborator.login, permission).call gitea_result = Gitea::Repository::Members::AddService.new(owner, project.identifier, collaborator.login, permission).call
if gitea_result.status == 204 if gitea_result.status == 204
project.add_member!(collaborator.id) project.add_member!(collaborator.id, role_name)
end end
fail!(nil) fail!(nil)
end end
@ -38,5 +38,20 @@ module Projects
@error = error @error = error
end end
def role_name
case permission
when 'read'
'Reporter'
when 'write'
'Developer'
when 'admin'
'Manager'
when 'owner'
'Manager'
else
'Reporter'
end
end
end end
end end

View File

@ -0,0 +1,27 @@
class SendJoinProjectAppliedMessageJob < ApplicationJob
queue_as :default
def perform(applied_project, applied_user, message_status)
project = applied_project.project
return unless project.present?
return unless applied_user.present?
return unless applied_project.user.present?
AppliedMessage.find_or_create_by!(user_id: applied_project.user_id,
applied: applied_project,
status: message_status,
name: build_name(project.name, message_status),
applied_user_id: applied_user.id,
project_id: project.id)
end
private
def build_name(repo_name, message_status, applied_name="")
case message_status
when 'successed'
return "已通过你加入【#{repo_name}】仓库的申请。"
when 'failure'
return "已拒绝你加入【#{repo_name}】仓库的申请。"
end
""
end
end

View File

@ -17,6 +17,7 @@
# #
class AppliedMessage < ApplicationRecord class AppliedMessage < ApplicationRecord
self.table_name = 'forge_applied_messages'
belongs_to :user belongs_to :user
belongs_to :applied, polymorphic: true belongs_to :applied, polymorphic: true
belongs_to :project belongs_to :project

View File

@ -7,14 +7,19 @@
# user_id :integer not null # user_id :integer not null
# role :integer default("0") # role :integer default("0")
# status :integer default("0") # status :integer default("0")
# created_at :datetime
# updated_at :datetime
# #
class AppliedProject < ApplicationRecord class AppliedProject < ApplicationRecord
self.table_name = "forge_applied_projects"
belongs_to :user belongs_to :user
belongs_to :project belongs_to :project
has_many :applied_messages, as: :applied, dependent: :destroy has_many :applied_messages, as: :applied, dependent: :destroy
has_many :forge_activities, as: :forge_act, dependent: :destroy # has_many :forge_activities, as: :forge_act, dependent: :destroy
enum role: {manager: 3, developer: 4, reporter: 5}
enum status: {canceled: -1, common: 0, accepted: 1, refused: 2} # -1 已取消 0 待操作 1 已接收 2 已拒绝
scope :pending, -> { where(status: 0) }
end end

View File

@ -37,6 +37,7 @@
# index_attachments_on_quotes (quotes) # index_attachments_on_quotes (quotes)
# #
class Attachment < ApplicationRecord class Attachment < ApplicationRecord
include BaseModel include BaseModel
include Publicable include Publicable
@ -51,7 +52,7 @@ class Attachment < ApplicationRecord
# 二级目录 # 二级目录
# belongs_to :course_second_category, optional: true # belongs_to :course_second_category, optional: true
scope :by_filename_or_user_name, -> (keywords) { joins(:author).where("filename like :search or LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) LIKE :search", scope :by_filename_or_user_name, -> (keywords) { joins(:author).where("filename like :search or LOWER(CONCAT(users.lastname, users.firstname)) LIKE :search OR users.nickname LIKE :search",
:search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank? } :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank? }
scope :by_keywords, -> (keywords) { where("filename LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank? } scope :by_keywords, -> (keywords) { where("filename LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank? }
scope :ordered, -> (opts = {}) { order("#{opts[:sort_type]} #{opts[:sort] == 1 ? 'asc': 'desc'}") } scope :ordered, -> (opts = {}) { order("#{opts[:sort_type]} #{opts[:sort] == 1 ? 'asc': 'desc'}") }

View File

@ -46,6 +46,10 @@
# is_sync_pwd :boolean default("1") # is_sync_pwd :boolean default("1")
# watchers_count :integer default("0") # watchers_count :integer default("0")
# devops_step :integer default("0") # devops_step :integer default("0")
# sponsor_certification :integer default("0")
# sponsor_num :integer default("0")
# sponsored_num :integer default("0")
# award_time :datetime
# #
# Indexes # Indexes
# #

View File

@ -0,0 +1,28 @@
module Dcodes
DCODES = %W(1 2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
extend ActiveSupport::Concern
def generate_dcode(field, num, pre='')
code = DCODES.sample(num).join
while self.class.exists?("#{field}": pre+code) do
code = DCODES.sample(num).join
end
code
end
def init_project_invite_code
while Project.where(invite_code: nil).size > 0 do
projects = Project.where(invite_code: nil).limit(1000)
set_sql = ""
projects.each do |p|
set_sql += "WHEN #{p.id} THEN '#{DCODES.sample(6).join}' "
end
sql = "UPDATE projects SET invite_code = CASE id "+ set_sql+ "END WHERE id IN(#{projects.ids.join(",")})"
Project.connection.execute(sql)
end
repeat_codes = Project.group(:invite_code).count.select{|k,v| v>1}
Project.where(invite_code: repeat_code.keys).update_all(invite_code: nil)
end
end

View File

@ -65,7 +65,7 @@ module ProjectOperable
if owner.is_a?(User) if owner.is_a?(User)
managers.exists?(user_id: user.id) managers.exists?(user_id: user.id)
elsif owner.is_a?(Organization) elsif owner.is_a?(Organization)
managers.exists?(user_id: user.id) || owner.is_admin?(user.id) managers.exists?(user_id: user.id) || owner.is_only_admin?(user.id)
else else
false false
end end
@ -76,7 +76,7 @@ module ProjectOperable
if owner.is_a?(User) if owner.is_a?(User)
developers.exists?(user_id: user.id) developers.exists?(user_id: user.id)
elsif owner.is_a?(Organization) elsif owner.is_a?(Organization)
developers.exists?(user_id: user.id) || owner.is_write?(user.id) developers.exists?(user_id: user.id) || owner.is_only_write?(user.id)
else else
false false
end end

View File

@ -6,7 +6,7 @@
# tracker_id :integer not null # tracker_id :integer not null
# project_id :integer not null # project_id :integer not null
# subject :string(255) default(""), not null # subject :string(255) default(""), not null
# description :text(65535) # description :text(4294967295)
# due_date :date # due_date :date
# category_id :integer # category_id :integer
# status_id :integer not null # status_id :integer not null
@ -14,7 +14,6 @@
# priority_id :integer not null # priority_id :integer not null
# fixed_version_id :integer # fixed_version_id :integer
# author_id :integer not null # author_id :integer not null
# lock_version :integer default("0"), not null
# created_on :datetime # created_on :datetime
# updated_on :datetime # updated_on :datetime
# start_date :date # start_date :date
@ -28,7 +27,7 @@
# closed_on :datetime # closed_on :datetime
# project_issues_index :integer # project_issues_index :integer
# issue_type :string(255) # issue_type :string(255)
# token :string(255) # token :integer default("0")
# issue_tags_value :string(255) # issue_tags_value :string(255)
# is_lock :boolean default("0") # is_lock :boolean default("0")
# issue_classify :string(255) # issue_classify :string(255)
@ -74,7 +73,7 @@ class Issue < ApplicationRecord
scope :issue_issue, ->{where(issue_classify: [nil,"issue"])} scope :issue_issue, ->{where(issue_classify: [nil,"issue"])}
scope :issue_pull_request, ->{where(issue_classify: "pull_request")} scope :issue_pull_request, ->{where(issue_classify: "pull_request")}
scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)} scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)}
scope :closed, ->{where(status_id: 5)}
after_update :change_versions_count after_update :change_versions_count
after_save :reset_cache_data after_save :reset_cache_data
after_destroy :update_closed_issues_count_in_project!, :reset_cache_data after_destroy :update_closed_issues_count_in_project!, :reset_cache_data

View File

@ -7,6 +7,7 @@
# content :text(65535) # content :text(65535)
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# is_secret :boolean default("0")
# #
class License < ApplicationRecord class License < ApplicationRecord

View File

@ -11,6 +11,7 @@
# course_group_id :integer default("0") # course_group_id :integer default("0")
# is_collect :integer default("1") # is_collect :integer default("1")
# graduation_group_id :integer default("0") # graduation_group_id :integer default("0")
# is_apply_signature :boolean default("0")
# #
# Indexes # Indexes
# #

View File

@ -46,6 +46,10 @@
# is_sync_pwd :boolean default("1") # is_sync_pwd :boolean default("1")
# watchers_count :integer default("0") # watchers_count :integer default("0")
# devops_step :integer default("0") # devops_step :integer default("0")
# sponsor_certification :integer default("0")
# sponsor_num :integer default("0")
# sponsored_num :integer default("0")
# award_time :datetime
# #
# Indexes # Indexes
# #
@ -106,6 +110,14 @@ class Organization < Owner
team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(read write admin owner)}).present? team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(read write admin owner)}).present?
end end
def is_only_admin?(user_id)
team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(admin)}).present?
end
def is_only_write?(user_id)
team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(write)}).present?
end
def is_only_read?(user_id) def is_only_read?(user_id)
team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(read)}).present? team_users.joins(:team).where(user_id: user_id, teams: {authorize: %w(read)}).present?
end end

View File

@ -1,19 +1,20 @@
# == Schema Information # == Schema Information
# #
# Table name: praise_treads # Table name: praise_treads
# #
# id :integer not null, primary key # id :integer not null, primary key
# user_id :integer not null # user_id :integer not null
# praise_tread_object_id :integer # praise_tread_object_id :integer
# praise_tread_object_type :string(255) # praise_tread_object_type :string(255)
# praise_or_tread :integer default("1") # praise_or_tread :integer default("1")
# created_at :datetime not null # created_at :datetime not null
# updated_at :datetime not null # updated_at :datetime not null
# #
# Indexes # Indexes
# #
# praise_tread (praise_tread_object_id,praise_tread_object_type) # praise_tread (praise_tread_object_id,praise_tread_object_type)
# #
class PraiseTread < ApplicationRecord class PraiseTread < ApplicationRecord
belongs_to :user belongs_to :user

View File

@ -1,63 +1,78 @@
# == Schema Information # == Schema Information
# #
# Table name: projects # Table name: projects
# #
# id :integer not null, primary key # id :integer not null, primary key
# name :string(255) default(""), not null # name :string(255) default(""), not null
# description :text(65535) # description :text(4294967295)
# homepage :string(255) default("") # homepage :string(255) default("")
# is_public :boolean default("1"), not null # is_public :boolean default("1"), not null
# parent_id :integer # parent_id :integer
# created_on :datetime # created_on :datetime
# updated_on :datetime # updated_on :datetime
# identifier :string(255) # identifier :string(255)
# status :integer default("1"), not null # status :integer default("1"), not null
# lft :integer # lft :integer
# rgt :integer # rgt :integer
# inherit_members :boolean default("0"), not null # inherit_members :boolean default("0"), not null
# project_type :integer default("0") # project_type :integer default("0")
# hidden_repo :boolean default("0"), not null # hidden_repo :boolean default("0"), not null
# attachmenttype :integer default("1") # attachmenttype :integer default("1")
# user_id :integer # user_id :integer
# dts_test :integer default("0") # dts_test :integer default("0")
# enterprise_name :string(255) # enterprise_name :string(255)
# organization_id :integer # organization_id :integer
# project_new_type :integer # project_new_type :integer
# gpid :integer # gpid :integer
# forked_from_project_id :integer # forked_from_project_id :integer
# forked_count :integer default("0") # forked_count :integer default("0")
# publish_resource :integer default("0") # publish_resource :integer default("0")
# visits :integer default("0") # visits :integer default("0")
# hot :integer default("0") # hot :integer default("0")
# invite_code :string(255) # invite_code :string(255)
# qrcode :string(255) # qrcode :string(255)
# qrcode_expiretime :integer default("0") # qrcode_expiretime :integer default("0")
# script :text(65535) # script :text(65535)
# training_status :integer default("0") # training_status :integer default("0")
# rep_identifier :string(255) # rep_identifier :string(255)
# project_category_id :integer # project_category_id :integer
# project_language_id :integer # project_language_id :integer
# license_id :integer # license_id :integer
# ignore_id :integer # ignore_id :integer
# praises_count :integer default("0") # praises_count :integer default("0")
# watchers_count :integer default("0") # watchers_count :integer default("0")
# issues_count :integer default("0") # issues_count :integer default("0")
# pull_requests_count :integer default("0") # pull_requests_count :integer default("0")
# # language :string(255)
# Indexes # versions_count :integer default("0")
# # issue_tags_count :integer default("0")
# index_projects_on_forked_from_project_id (forked_from_project_id) # closed_issues_count :integer default("0")
# index_projects_on_identifier (identifier) # open_devops :boolean default("0")
# index_projects_on_is_public (is_public) # gitea_webhook_id :integer
# index_projects_on_lft (lft) # open_devops_count :integer default("0")
# index_projects_on_name (name) # recommend :boolean default("0")
# index_projects_on_platform (platform) # platform :integer default("0")
# index_projects_on_project_type (project_type) # default_branch :string(255) default("master")
# index_projects_on_recommend (recommend) # website :string(255)
# index_projects_on_rgt (rgt) # order_index :integer default("0")
# index_projects_on_status (status) # lesson_url :string(255)
# index_projects_on_updated_on (updated_on) #
# # Indexes
#
# index_projects_on_forked_from_project_id (forked_from_project_id)
# index_projects_on_identifier (identifier)
# index_projects_on_invite_code (invite_code)
# index_projects_on_is_public (is_public)
# index_projects_on_lft (lft)
# index_projects_on_name (name)
# index_projects_on_platform (platform)
# index_projects_on_project_type (project_type)
# index_projects_on_recommend (recommend)
# index_projects_on_rgt (rgt)
# index_projects_on_status (status)
# index_projects_on_updated_on (updated_on)
#
@ -66,6 +81,7 @@ class Project < ApplicationRecord
include Publicable include Publicable
include Watchable include Watchable
include ProjectOperable include ProjectOperable
include Dcodes
# common:开源托管项目 # common:开源托管项目
# mirror:普通镜像项目,没有定时同步功能 # mirror:普通镜像项目,没有定时同步功能
@ -106,6 +122,7 @@ class Project < ApplicationRecord
has_many :has_pinned_users, through: :pinned_projects, source: :user has_many :has_pinned_users, through: :pinned_projects, source: :user
after_save :check_project_members, :reset_cache_data after_save :check_project_members, :reset_cache_data
before_save :set_invite_code
after_destroy :reset_cache_data after_destroy :reset_cache_data
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)} 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)}
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)} scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
@ -123,6 +140,12 @@ class Project < ApplicationRecord
self.reset_user_cache_async_job(self.owner) self.reset_user_cache_async_job(self.owner)
end end
def set_invite_code
if self.invite_code.nil?
self.invite_code= self.generate_dcode('invite_code', 6)
end
end
def self.search_project(search) def self.search_project(search)
ransack(name_or_identifier_cont: search) ransack(name_or_identifier_cont: search)
end end

View File

@ -16,6 +16,11 @@
# head :string(255) # head :string(255)
# base :string(255) # base :string(255)
# issue_id :integer # issue_id :integer
# fork_project_id :integer
# is_original :boolean default("0")
# comments_count :integer default("0")
# commits_count :integer default("0")
# files_count :integer default("0")
# #
class PullRequest < ApplicationRecord class PullRequest < ApplicationRecord
@ -33,6 +38,9 @@ class PullRequest < ApplicationRecord
has_many :project_trends, as: :trend, dependent: :destroy has_many :project_trends, as: :trend, dependent: :destroy
has_many :attachments, as: :container, dependent: :destroy has_many :attachments, as: :container, dependent: :destroy
scope :merged_and_closed, ->{where.not(status: 0)}
scope :opening, -> {where(status: 0)}
after_save :reset_cache_data after_save :reset_cache_data
after_destroy :reset_cache_data after_destroy :reset_cache_data

View File

@ -46,6 +46,10 @@
# is_sync_pwd :boolean default("1") # is_sync_pwd :boolean default("1")
# watchers_count :integer default("0") # watchers_count :integer default("0")
# devops_step :integer default("0") # devops_step :integer default("0")
# sponsor_certification :integer default("0")
# sponsor_num :integer default("0")
# sponsored_num :integer default("0")
# award_time :datetime
# #
# Indexes # Indexes
# #
@ -170,7 +174,7 @@ class User < Owner
# Groups and active users # Groups and active users
scope :active, lambda { where(status: STATUS_ACTIVE) } scope :active, lambda { where(status: STATUS_ACTIVE) }
scope :like, lambda { |keywords| scope :like, lambda { |keywords|
sql = "CONCAT_WS(lastname, firstname, nickname) LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search" sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank? where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
} }
@ -206,6 +210,13 @@ class User < Owner
return Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct return Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
end end
# 用户管理的所有项目
def full_admin_projects
normal_projects = Project.joins(members: :roles).where(roles: {name: 'Manager'}, members: {user_id: self.id}).to_sql
org_projects = Project.joins(teams: :team_users).where(teams: {authorize: %w(admin owner)}, team_users: {user_id: self.id}).to_sql
return Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
end
def name def name
login login
end end

View File

@ -29,6 +29,8 @@ class Version < ApplicationRecord
belongs_to :user, optional: true belongs_to :user, optional: true
scope :version_includes, ->{includes(:issues, :user)} scope :version_includes, ->{includes(:issues, :user)}
scope :closed, ->{where(status: 'closed')}
scope :opening, ->{where(status: 'open')}
# def open_issues_count # def open_issues_count
# issues.select(:id,:status_id).where(status_id: [1,2,3,4,6]).size # issues.select(:id,:status_id).where(status_id: [1,2,3,4,6]).size

View File

@ -26,7 +26,7 @@ class Admins::ApplyItemBankQuery < ApplicationQuery
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword.present? if keyword.present?
applies = applies.joins(user: { user_extension: :school }) applies = applies.joins(user: { user_extension: :school })
.where('CONCAT_WS(lastname,firstname, nickname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%") .where('CONCAT(lastname,firstname) LIKE :keyword OR users.nickname LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
end end
custom_sort(applies, params[:sort_by], params[:sort_direction]) custom_sort(applies, params[:sort_by], params[:sort_direction])

View File

@ -26,7 +26,7 @@ class Admins::ApplyUserAuthenticationQuery < ApplicationQuery
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword.present? if keyword.present?
applies = applies.joins(user: { user_extension: :school }) applies = applies.joins(user: { user_extension: :school })
.where('CONCAT_WS(lastname,firstname,nickname) LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%") .where('CONCAT(lastname,firstname) LIKE :keyword OR users.nickname LIKE :keyword OR schools.name LIKE :keyword', keyword: "%#{keyword}%")
end end
custom_sort(applies, params[:sort_by], params[:sort_direction]) custom_sort(applies, params[:sort_by], params[:sort_direction])

View File

@ -19,7 +19,7 @@ class Admins::CourseListQuery < ApplicationQuery
case search_type case search_type
when "0" when "0"
course_lists = course_lists.joins(:user) course_lists = course_lists.joins(:user)
.where('CONCAT_WS(lastname, firstname, nickname) like :keyword', keyword: "%#{keyword}%") .where('CONCAT(lastname, firstname) like :keyword OR users.nickname like :keyword', keyword: "%#{keyword}%")
when "1" when "1"
course_lists = course_lists.where('name like :keyword', keyword: "%#{keyword}%") course_lists = course_lists.where('name like :keyword', keyword: "%#{keyword}%")
end end

View File

@ -35,7 +35,7 @@ class Admins::CourseQuery < ApplicationQuery
# 关键字 # 关键字
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword if keyword
sql = 'CONCAT_WS(lastname, firstname, nickname) LIKE :keyword OR courses.name LIKE :keyword OR course_lists.name LIKE :keyword' sql = 'CONCAT(lastname, firstname) LIKE :keyword OR users.nickname LIKE :keyword OR courses.name LIKE :keyword OR course_lists.name LIKE :keyword'
courses = courses.joins(:teacher, :course_list).where(sql, keyword: "%#{keyword}%") courses = courses.joins(:teacher, :course_list).where(sql, keyword: "%#{keyword}%")
end end

View File

@ -11,7 +11,7 @@ class Admins::LaboratoryShixunQuery < ApplicationQuery
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword.present? if keyword.present?
like_sql = 'shixuns.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword' like_sql = 'shixuns.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword OR users.nickname LIKE :keyword'
laboratory_shixuns = laboratory_shixuns.joins(shixun: :user).where(like_sql, keyword: "%#{keyword}%") laboratory_shixuns = laboratory_shixuns.joins(shixun: :user).where(like_sql, keyword: "%#{keyword}%")
end end

View File

@ -11,7 +11,7 @@ class Admins::LaboratorySubjectQuery < ApplicationQuery
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword.present? if keyword.present?
like_sql = 'subjects.name LIKE :keyword OR CONCAT_WS(users.lastname, users.firstname, users.nickname) LIKE :keyword' like_sql = 'subjects.name LIKE :keyword OR CONCAT(users.lastname, users.firstname) LIKE :keyword OR users.nickname LIKE :keyword'
laboratory_subjects = laboratory_subjects.joins(subject: :user).where(like_sql, keyword: "%#{keyword}%") laboratory_subjects = laboratory_subjects.joins(subject: :user).where(like_sql, keyword: "%#{keyword}%")
end end

View File

@ -40,7 +40,7 @@ class Admins::SubjectQuery < ApplicationQuery
# 关键字 # 关键字
keyword = params[:keyword].to_s.strip keyword = params[:keyword].to_s.strip
if keyword if keyword
sql = 'CONCAT_WS(lastname, firstname, nickname) LIKE :keyword OR subjects.name LIKE :keyword' sql = 'CONCAT(lastname, firstname) LIKE :keyword OR users.nickname LIKE :keyword OR subjects.name LIKE :keyword'
subjects = subjects.joins(:user).where(sql, keyword: "%#{keyword}%") subjects = subjects.joins(:user).where(sql, keyword: "%#{keyword}%")
end end

View File

@ -30,14 +30,14 @@ class Admins::UserQuery < ApplicationQuery
# 关键字检索 # 关键字检索
keyword = params[:keyword].to_s.strip.presence keyword = params[:keyword].to_s.strip.presence
if keyword if keyword
sql = 'CONCAT_WS(lastname, firstname, nickname) LIKE :keyword OR login LIKE :keyword OR mail LIKE :keyword OR phone LIKE :keyword' sql = 'CONCAT(lastname, firstname) LIKE :keyword OR nickname LIKE :keyword OR login LIKE :keyword OR mail LIKE :keyword OR phone LIKE :keyword'
users = users.where(sql, keyword: "%#{keyword}%") users = users.where(sql, keyword: "%#{keyword}%")
end end
# 姓名 # 姓名
name = params[:name].to_s.strip.presence name = params[:name].to_s.strip.presence
if name.present? if name.present?
users = users.where('CONCAT_WS(lastname, firstname, nickname) LIKE :name', name: "%#{name}%") users = users.where('CONCAT(lastname, firstname) LIKE :name OR nickname LIKE :name', name: "%#{name}%")
end end
# 单位ID # 单位ID

View File

@ -55,8 +55,8 @@ class Projects::ListMyQuery < ApplicationQuery
scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users) scope = q.result.includes(:project_category, :project_language,:owner, :repository, :has_pinned_users)
sort = params[:sort_by] || "updated_on" sort = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : "updated_on"
sort_direction = params[:sort_direction] || "desc" sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : "desc"
if params[:choosed].present? && params[:choosed].is_a?(Array) if params[:choosed].present? && params[:choosed].is_a?(Array)
scope.order("FIELD(id, #{params[:choosed].reverse.join(",")}) desc") scope.order("FIELD(id, #{params[:choosed].reverse.join(",")}) desc")

View File

@ -10,7 +10,7 @@ class UserQuery < ApplicationQuery
# 真实姓名 # 真实姓名
if name = strip_param(:name) if name = strip_param(:name)
users = users.where('LOWER(CONCAT_WS(users.lastname, users.firstname, users.nickname)) LIKE ?', "%#{name.downcase}%") users = users.where('LOWER(CONCAT(users.lastname, users.firstname)) LIKE ? OR users.nickname LIKE ?', "%#{name.downcase}%", "%#{name.downcase}%")
end end
# 单位名称 # 单位名称

View File

@ -28,10 +28,10 @@ class Weapps::SubjectQuery < ApplicationQuery
private private
def order_type def order_type
params[:order] || "updated_at" Subject.column_names.include?(params[:order]) ? params[:order] : 'updated_at'
end end
def sort_type def sort_type
params[:sort] || "desc" %w(desc asc).include?(params[:sort]) ? params[:sort] : "desc"
end end
end end

View File

@ -84,7 +84,7 @@ class Admins::ImportUserService < ApplicationService
if data.identity.to_i == 1 if data.identity.to_i == 1
users = users.where(user_extensions: { student_id: data.student_id }) users = users.where(user_extensions: { student_id: data.student_id })
else else
users = users.where(user_extensions: { technical_title: data.technical_title }).where('CONCAT_WS(users.lastname,users.firstname,users.nickname) = ?', data.name) users = users.where(user_extensions: { technical_title: data.technical_title }).where('CONCAT(users.lastname,users.firstname) = ? OR users.nickname = ?', data.name, data.name)
end end
users.first users.first

View File

@ -45,9 +45,17 @@ class Issues::ListQueryService < ApplicationService
issues = issues.where(issue_type: params[:issue_type].to_s) if params[:issue_type].present? && params[:issue_type].to_s != "all" issues = issues.where(issue_type: params[:issue_type].to_s) if params[:issue_type].present? && params[:issue_type].to_s != "all"
issues = issues.joins(:issue_tags).where(issue_tags: {id: params[:issue_tag_id].to_i}) if params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all" issues = issues.joins(:issue_tags).where(issue_tags: {id: params[:issue_tag_id].to_i}) if params[:issue_tag_id].present? && params[:issue_tag_id].to_s != "all"
order_type = params[:order_type] || "desc" #或者"asc"
order_name = params[:order_name] || "updated_on" #或者"updated_on"
issues.reorder("issues.#{order_name} #{order_type}") issues.reorder("issues.#{order_name} #{order_type}")
end end
private
def order_name
Issue.column_names.include?(params[:order_name]) ? params[:order_name] : 'updated_on'
end
def order_type
%w(desc asc).include?(params[:order_type]) ? params[:order_type] : 'desc'
end
end end

View File

@ -0,0 +1,61 @@
class Projects::AcceptJoinService < ApplicationService
attr_accessor :applied_project, :owner
attr_reader :user, :project
def initialize(user, applied_project)
@user = user
@project = applied_project.project
@applied_project = applied_project
end
def call
Rails.logger.info("###### Project accept_join_service begin ######")
ActiveRecord::Base.transaction do
validate!
update_apply
operate_project_member
send_apply_message
end
Rails.logger.info("##### Project accept_join_service end ######")
return @applied_project
end
private
def permission
case @applied_project.role
when 'manager'
'admin'
when 'developer'
'write'
when 'reporter'
'read'
else
'read'
end
end
def validate!
raise Error, '该申请已经被接受' if @applied_project.accepted?
raise Error, '该申请不存在' unless @applied_project.present?
raise Error, '未拥有接受申请权限' unless is_permit_operator
end
def is_permit_operator
return @user.admin? || @project.manager?(@user)
end
def update_apply
@applied_project.update!(status: 'accepted')
end
def operate_project_member
Projects::AddMemberInteractor.call(@project.owner, @project, @applied_project.user, permission)
end
def send_apply_message
SendJoinProjectAppliedMessageJob.perform_now(@applied_project, @user, 'successed')
end
end

View File

@ -9,26 +9,25 @@ class Projects::ApplyJoinService < ApplicationService
end end
def call def call
validate!
# 项目报告人员直接加入项目 # 项目报告人员直接加入项目
if params[:role] == 'reporter' # if params[:role] == 'reporter'
# Projects::JoinService.call(project, user, role: 'reporter') # # Projects::JoinService.call(project, user, role: 'reporter')
return project # return project
end # end
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
validate!
apply = user.applied_projects.create!(project: project, role: role_value) apply = user.applied_projects.create!(project: project, role: role_value)
apply
# apply.forge_activities.find_or_create_by!(user: user, project: project)
apply.forge_activities.find_or_create_by!(user: user, project: project) # notify_project_manager!(apply)
notify_project_manager!(apply)
end end
# notify_project_owner # notify_project_owner
ApplyJoinProjectNotifyJob.perform_later(user.id, project.id, role_value) # ApplyJoinProjectNotifyJob.perform_later(user.id, project.id, role_value)
project
end end
private private
@ -43,7 +42,8 @@ class Projects::ApplyJoinService < ApplicationService
when 'manager' then 3 when 'manager' then 3
when 'developer' then 4 when 'developer' then 4
when 'reporter' then 5 when 'reporter' then 5
else raise Error, '角色无效' else
5
end end
end end
@ -74,12 +74,18 @@ class Projects::ApplyJoinService < ApplicationService
def validate! def validate!
# params check # params check
raise Error, '邀请码不能为空' if params[:code].blank? raise Error, '邀请码不能为空' if params[:code].blank?
raise Error, '角色不能为空' if params[:role].blank? raise Error, '请输入6位项目邀请码' unless valid_invite_code( params[:code])
raise Error, '角色无效' unless %w(manager developer reporter).include?(params[:role])
# logical check # logical check
raise Error, '邀请码无效' if project.blank? raise Error, '邀请码无效' if project.blank?
raise Error, '您已在该项目中' if project.member?(user) raise Error, '您已是项目成员' if project.member?(user)
raise Error, '您已经提交过申请' if user.applied_projects.pending.exists?(project: project) raise Error, '您已经提交过申请' if user.applied_projects.common.exists?(project: project)
end
def valid_invite_code(str)
if (str =~ /^[A-Za-z0-9]{6}+$/)
return true
end
return false
end end
end end

View File

@ -0,0 +1,39 @@
class Projects::RefuseJoinService < ApplicationService
attr_accessor :applied_project, :owner
attr_reader :user, :project
def initialize(user, applied_project)
@user = user
@project = applied_project.project
@applied_project = applied_project
end
def call
Rails.logger.info("###### Project refuse_join_service begin ######")
validate!
update_apply
send_apply_message
Rails.logger.info("###### Project refuse_join_service end ######")
return @applied_project
end
private
def validate!
raise Error, '该申请已被拒绝' if @applied_project.refused?
raise Error, '该申请不存在' unless @applied_project.present?
raise Error, '未拥有接受申请权限' unless is_permit_operator
end
def is_permit_operator
return @user.admin? || @project.manager?(@user)
end
def update_apply
@applied_project.update!(status: 'refused')
end
def send_apply_message
SendJoinProjectAppliedMessageJob.perform_now(@applied_project, @user, 'failure')
end
end

View File

@ -0,0 +1,19 @@
project = object.project
json.project do
json.id project.id
json.identifier project.identifier
json.name project.name
json.description project.description
json.is_public project.is_public
json.owner do
json.partial! "/users/user_simple", locals: {user: project.owner}
end
end
json.user do
json.partial! "/users/user_simple", locals: {user: object.user}
end
json.id object.id
json.status object.status
json.role object.role
json.created_at format_time(object.created_at)
json.time_ago time_from_now(object.created_at)

View File

@ -0,0 +1 @@
json.partial! "detail", locals: {object: @applied_project}

View File

@ -1,9 +1,9 @@
json.partial! "commons/success" json.partial! "commons/success"
json.all_count @all_issues_size json.all_count @all_issues.size
json.open_count @open_issues_size json.open_count @open_issues.size
json.close_count @close_issues_size json.close_count @close_issues.size
json.assign_me_count @assign_to_me_size json.assign_me_count @assign_to_me.size
json.my_published_count @my_published_size json.my_published_count @my_published.size
json.search_count @issues_size json.search_count @issues_size
json.limit @limit json.limit @limit
json.user_admin_or_member @user_admin_or_member json.user_admin_or_member @user_admin_or_member

View File

@ -1,8 +1,8 @@
json.partial! "commons/success" json.partial! "commons/success"
json.all_count @all_issues_size json.all_count @all_issues.size
json.open_count @open_issues_size json.open_count @open_issues.size
json.close_count @close_issues_size json.close_count @close_issues.size
json.merged_issues_size @merged_issues_size json.merged_issues_size @merged_issues.size
json.search_count @issues_size json.search_count @issues_size
json.limit @limit json.limit @limit
json.user_admin_or_member @user_admin_or_member json.user_admin_or_member @user_admin_or_member

View File

@ -7,17 +7,18 @@ else
json.readme @result[:readme].merge(content: readme_render_decode64_content(@result[:readme]["content"], nil)) json.readme @result[:readme].merge(content: readme_render_decode64_content(@result[:readme]["content"], nil))
end end
json.identifier render_identifier(@project) json.identifier render_identifier(@project)
json.invite_code @project.invite_code
json.name @project.name json.name @project.name
json.description @project.description json.description @project.description
json.project_id @project.id json.project_id @project.id
json.repo_id @repository.id json.repo_id @repository.id
json.issues_count @project.issues_count.to_i - @project.pull_requests_count.to_i json.issues_count @project.issues.issue_issue.size - @project.issues.issue_issue.closed.size
json.pull_requests_count @project.pull_requests_count json.pull_requests_count @project.pull_requests.opening.size
json.project_identifier render_identifier(@project) json.project_identifier render_identifier(@project)
json.praises_count @project.praises_count.to_i json.praises_count @project.praises_count.to_i
json.forked_count @project.forked_count.to_i json.forked_count @project.forked_count.to_i
json.watchers_count @project.watchers_count.to_i json.watchers_count @project.watchers_count.to_i
json.versions_count @project.versions_count #里程碑数量 json.versions_count @project.versions.opening.size #里程碑数量
json.version_releases_count @project.releases_size(@user.try(:id), "all") json.version_releases_count @project.releases_size(@user.try(:id), "all")
json.version_releasesed_count @project.releases_size(@user.try(:id), "released") #已发行的版本 json.version_releasesed_count @project.releases_size(@user.try(:id), "released") #已发行的版本
json.permission render_permission(@user, @project) json.permission render_permission(@user, @project)
@ -42,6 +43,7 @@ json.fork_info do
json.fork_project_user_login @fork_project_user.try(:login) json.fork_project_user_login @fork_project_user.try(:login)
json.fork_project_identifier @fork_project.identifier json.fork_project_identifier @fork_project.identifier
json.fork_project_user_name @fork_project_user.try(:show_real_name) json.fork_project_user_name @fork_project_user.try(:show_real_name)
json.fork_project_user_type @fork_project_user.try(:type)
end end
end end
if @result[:repo] if @result[:repo]

View File

@ -13,7 +13,12 @@
# json.partial! "/users/user_simple", locals: {user: object.user} # json.partial! "/users/user_simple", locals: {user: object.user}
# end # end
json.applied do json.applied do
json.partial! "/projects/applied_transfer_projects/detail", locals: {object: object.applied} case object.applied_type
when 'AppliedTransferProject'
json.partial! "/projects/applied_transfer_projects/detail", locals: {object: object.applied}
when 'AppliedProject'
json.partial! "/applied_projects/detail", locals: {object: object.applied}
end
end end
json.applied_user do json.applied_user do
json.partial! "/users/user_simple", locals: {user: object.applied_user} json.partial! "/users/user_simple", locals: {user: object.applied_user}

View File

@ -0,0 +1 @@
json.partial! "/applied_projects/detail", locals: {object: @applied_project}

View File

@ -0,0 +1,4 @@
json.total_count @applied_projects.total_count
json.applied_projects @applied_projects do |apply|
json.partial! "/applied_projects/detail", locals: {object: apply}
end

View File

@ -0,0 +1 @@
json.partial! "/applied_projects/detail", locals: {object: @applied_project}

View File

@ -1,6 +1,7 @@
json.partial! 'users/user', locals: { user: @user } json.partial! 'users/user', locals: { user: @user }
json.undo_messages @waiting_applied_messages.size json.undo_messages @waiting_applied_messages.size
json.undo_transfer_projects @common_applied_transfer_projects.size json.undo_transfer_projects @common_applied_transfer_projects.size
json.undo_join_projects @common_applied_projects.size
json.undo_events @undo_events json.undo_events @undo_events
json.user_composes_count @user_composes_count json.user_composes_count @user_composes_count
json.user_org_count @user_org_count json.user_org_count @user_org_count

View File

@ -148,6 +148,8 @@ Rails.application.routes.draw do
resources :issue_depends, only: [:create, :destroy] resources :issue_depends, only: [:create, :destroy]
end end
resources :applied_projects, only: [:create]
resources :project_categories, only: [:index, :show] do resources :project_categories, only: [:index, :show] do
get :group_list, on: :collection get :group_list, on: :collection
end end
@ -266,6 +268,12 @@ Rails.application.routes.draw do
post :refuse post :refuse
end end
end end
resources :applied_projects, only: [:index] do
member do
post :accept
post :refuse
end
end
resources :headmaps, only: [:index] resources :headmaps, only: [:index]
resources :is_pinned_projects, only: [:index, :update] do resources :is_pinned_projects, only: [:index, :update] do
collection do collection do

View File

@ -0,0 +1,5 @@
class AddTimestampToAppliedProjects < ActiveRecord::Migration[5.2]
def change
add_timestamps(:applied_projects, null: true)
end
end

View File

@ -0,0 +1,8 @@
class AddInviteCodeIndexToProjects < ActiveRecord::Migration[5.2]
def change
add_index :projects, :invite_code
execute <<-SQL
ALTER TABLE projects MODIFY COLUMN invite_code VARCHAR(255) BINARY CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL;
SQL
end
end

View File

@ -373,11 +373,23 @@
<li> <li>
<a href="#5e6ed41015" class="toc-h2 toc-link" data-title="用户拒绝迁移">用户拒绝迁移</a> <a href="#5e6ed41015" class="toc-h2 toc-link" data-title="用户拒绝迁移">用户拒绝迁移</a>
</li> </li>
<li>
<a href="#ba97e431b8" class="toc-h2 toc-link" data-title="待办事项-项目申请">待办事项-项目申请</a>
</li>
<li>
<a href="#e8ec937c34" class="toc-h2 toc-link" data-title="用户接受申请">用户接受申请</a>
</li>
<li>
<a href="#f2ee84ecf7" class="toc-h2 toc-link" data-title="用户拒绝申请">用户拒绝申请</a>
</li>
</ul> </ul>
</li> </li>
<li> <li>
<a href="#projects" class="toc-h1 toc-link" data-title="Projects">Projects</a> <a href="#projects" class="toc-h1 toc-link" data-title="Projects">Projects</a>
<ul class="toc-list-h2"> <ul class="toc-list-h2">
<li>
<a href="#ac55469b06" class="toc-h2 toc-link" data-title="申请加入项目">申请加入项目</a>
</li>
<li> <li>
<a href="#bfdfb34952" class="toc-h2 toc-link" data-title="获取项目列表">获取项目列表</a> <a href="#bfdfb34952" class="toc-h2 toc-link" data-title="获取项目列表">获取项目列表</a>
</li> </li>
@ -617,7 +629,7 @@ Success — a happy kitten is an authenticated kitten!
<!-- <!--
* @Date: 2021-03-01 10:35:21 * @Date: 2021-03-01 10:35:21
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-03 10:18:53 * @LastEditTime: 2021-06-11 16:28:51
* @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md * @FilePath: /forgeplus/app/docs/slate/source/includes/_users.md
--> -->
<h1 id='users'>Users</h1><h2 id='1ae74893b1'>获取当前登陆用户信息</h2> <h1 id='users'>Users</h1><h2 id='1ae74893b1'>获取当前登陆用户信息</h2>
@ -2016,29 +2028,29 @@ Success — a happy kitten is an authenticated kitten!
<td>通知主体的迁移创建者头像</td> <td>通知主体的迁移创建者头像</td>
</tr> </tr>
<tr> <tr>
<td>applied.owner.id</td> <td>applied_user.id</td>
<td>int</td> <td>int</td>
<td>通知主体的迁移接受者的id</td> <td>通知发起者的id</td>
</tr> </tr>
<tr> <tr>
<td>applied.owner.type</td> <td>applied_user.type</td>
<td>string</td> <td>string</td>
<td>通知主体的迁移接受者的类型</td> <td>通知发起者的类型</td>
</tr> </tr>
<tr> <tr>
<td>applied.owner.name</td> <td>applied_user.name</td>
<td>string</td> <td>string</td>
<td>通知主体的迁移接受者的名称</td> <td>通知发起者的名称</td>
</tr> </tr>
<tr> <tr>
<td>applied.owner.login</td> <td>applied_user.login</td>
<td>string</td> <td>string</td>
<td>通知主体的迁移接受者的标识</td> <td>通知发起者的标识</td>
</tr> </tr>
<tr> <tr>
<td>applied.owner.image_url</td> <td>applied_user.image_url</td>
<td>string</td> <td>string</td>
<td>通知主体的迁移接受者头像</td> <td>通知发起者头像</td>
</tr> </tr>
<tr> <tr>
<td>applied_type</td> <td>applied_type</td>
@ -2073,6 +2085,48 @@ Success — a happy kitten is an authenticated kitten!
<div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w"> <div class="highlight"><pre class="highlight json tab-json"><code><span class="p">{</span><span class="w">
</span><span class="nl">"total_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="nl">"total_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w">
</span><span class="nl">"applied_messages"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="nl">"applied_messages"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nl">"applied"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">74</span><span class="p">,</span><span class="w">
</span><span class="nl">"identifier"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"description"</span><span class="p">:</span><span class="w"> </span><span class="s2">"wwww"</span><span class="p">,</span><span class="w">
</span><span class="nl">"is_public"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nl">"owner"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/T/19_237_174/120.png"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"user"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"何慧"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"images/avatars/User/6?t=1622513134"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"accepted"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-06-09 16:34"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1分钟前"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"applied_user"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"何慧"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"images/avatars/User/6?t=1622513134"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"applied_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"AppliedProject"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"已通过你加入【hehuisssjssjjsjs】仓库的申请。"</span><span class="p">,</span><span class="w">
</span><span class="nl">"viewed"</span><span class="p">:</span><span class="w"> </span><span class="s2">"waiting"</span><span class="p">,</span><span class="w">
</span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"successed"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-06-09 16:34"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1分钟前"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="p">{</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"applied"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"applied"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nl">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
@ -2699,7 +2753,660 @@ Success — a happy kitten is an authenticated kitten!
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-04-25 18:06"</span><span class="p">,</span><span class="w"> </span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-04-25 18:06"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"16小时前"</span><span class="w"> </span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"16小时前"</span><span class="w">
</span><span class="p">}</span><span class="w"> </span><span class="p">}</span><span class="w">
</span></code></pre></div><h1 id='projects'>Projects</h1><h2 id='bfdfb34952'>获取项目列表</h2> </span></code></pre></div><h2 id='ba97e431b8'>待办事项-项目申请</h2>
<p>待办事项-项目申请</p>
<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/users/yystopf/applied_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/users/:login/applied_projects.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-16'>HTTP 请求</h3>
<p><code>GET /api/users/:login/applied_projects.json</code></p>
<h3 id='aa883f5d52-13'>请求字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>login</td>
<td>string</td>
<td>用户标识</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-13'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>申请id</td>
</tr>
<tr>
<td>status</td>
<td>string</td>
<td>申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝</td>
</tr>
<tr>
<td>time_ago</td>
<td>string</td>
<td>申请创建的时间</td>
</tr>
<tr>
<td>project.id</td>
<td>int</td>
<td>申请项目的id</td>
</tr>
<tr>
<td>project.identifier</td>
<td>string</td>
<td>申请项目的标识</td>
</tr>
<tr>
<td>project.name</td>
<td>string</td>
<td>申请项目的名称</td>
</tr>
<tr>
<td>project.description</td>
<td>string</td>
<td>申请项目的描述</td>
</tr>
<tr>
<td>project.is_public</td>
<td>bool</td>
<td>申请项目是否公开</td>
</tr>
<tr>
<td>project.owner.id</td>
<td>bool</td>
<td>申请项目拥有者id</td>
</tr>
<tr>
<td>project.owner.type</td>
<td>string</td>
<td>申请项目拥有者类型</td>
</tr>
<tr>
<td>project.owner.name</td>
<td>string</td>
<td>申请项目拥有者昵称</td>
</tr>
<tr>
<td>project.owner.login</td>
<td>string</td>
<td>申请项目拥有者标识</td>
</tr>
<tr>
<td>project.owner.image_url</td>
<td>string</td>
<td>申请项目拥有者头像</td>
</tr>
<tr>
<td>user.id</td>
<td>int</td>
<td>申请创建者的id</td>
</tr>
<tr>
<td>user.type</td>
<td>string</td>
<td>申请创建者的类型</td>
</tr>
<tr>
<td>user.name</td>
<td>string</td>
<td>申请创建者的名称</td>
</tr>
<tr>
<td>user.login</td>
<td>string</td>
<td>申请创建者的标识</td>
</tr>
<tr>
<td>user.image_url</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">"total_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w">
</span><span class="nl">"applied_transfer_projects"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="nl">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">74</span><span class="p">,</span><span class="w">
</span><span class="nl">"identifier"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"description"</span><span class="p">:</span><span class="w"> </span><span class="s2">"wwww"</span><span class="p">,</span><span class="w">
</span><span class="nl">"is_public"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nl">"owner"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/T/19_237_174/120.png"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"user"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"何慧"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"images/avatars/User/6?t=1622513134"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w">
</span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"common"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-06-09 16:41"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"7分钟前"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="err">...</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='e8ec937c34'>用户接受申请</h2>
<p>用户接受申请</p>
<blockquote>
<p>示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/users/yystopf/applied_projects/2/accept.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/users/:login/applied_projects/:id/accept.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-17'>HTTP 请求</h3>
<p><code>GET /api/users/:login/applied_projects/:id/accept.json</code></p>
<h3 id='aa883f5d52-14'>请求字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>login</td>
<td>string</td>
<td>用户标识</td>
</tr>
<tr>
<td>id</td>
<td>int</td>
<td>申请id</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-14'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>申请id</td>
</tr>
<tr>
<td>status</td>
<td>string</td>
<td>申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝</td>
</tr>
<tr>
<td>time_ago</td>
<td>string</td>
<td>申请创建的时间</td>
</tr>
<tr>
<td>project.id</td>
<td>int</td>
<td>申请项目的id</td>
</tr>
<tr>
<td>project.identifier</td>
<td>string</td>
<td>申请项目的标识</td>
</tr>
<tr>
<td>project.name</td>
<td>string</td>
<td>申请项目的名称</td>
</tr>
<tr>
<td>project.description</td>
<td>string</td>
<td>申请项目的描述</td>
</tr>
<tr>
<td>project.is_public</td>
<td>bool</td>
<td>申请项目是否公开</td>
</tr>
<tr>
<td>project.owner.id</td>
<td>bool</td>
<td>申请项目拥有者id</td>
</tr>
<tr>
<td>project.owner.type</td>
<td>string</td>
<td>申请项目拥有者类型</td>
</tr>
<tr>
<td>project.owner.name</td>
<td>string</td>
<td>申请项目拥有者昵称</td>
</tr>
<tr>
<td>project.owner.login</td>
<td>string</td>
<td>申请项目拥有者标识</td>
</tr>
<tr>
<td>project.owner.image_url</td>
<td>string</td>
<td>申请项目拥有者头像</td>
</tr>
<tr>
<td>user.id</td>
<td>int</td>
<td>申请创建者的id</td>
</tr>
<tr>
<td>user.type</td>
<td>string</td>
<td>申请创建者的类型</td>
</tr>
<tr>
<td>user.name</td>
<td>string</td>
<td>申请创建者的名称</td>
</tr>
<tr>
<td>user.login</td>
<td>string</td>
<td>申请创建者的标识</td>
</tr>
<tr>
<td>user.image_url</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">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">74</span><span class="p">,</span><span class="w">
</span><span class="nl">"identifier"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"description"</span><span class="p">:</span><span class="w"> </span><span class="s2">"wwww"</span><span class="p">,</span><span class="w">
</span><span class="nl">"is_public"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nl">"owner"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/T/19_237_174/120.png"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"user"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"何慧"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"images/avatars/User/6?t=1622513134"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w">
</span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"accept"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-06-09 16:41"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"7分钟前"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h2 id='f2ee84ecf7'>用户拒绝申请</h2>
<p>用户拒绝申请</p>
<blockquote>
<p>示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/users/yystopf/applied_projects/2/refuse.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/users/:login/applied_projects/:id/refuse.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-18'>HTTP 请求</h3>
<p><code>GET /api/users/:login/applied_projects/:id/refuse.json</code></p>
<h3 id='aa883f5d52-15'>请求字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>login</td>
<td>string</td>
<td>用户标识</td>
</tr>
<tr>
<td>id</td>
<td>int</td>
<td>申请id</td>
</tr>
</tbody></table>
<h3 id='7447e4874e-15'>返回字段说明:</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>申请id</td>
</tr>
<tr>
<td>status</td>
<td>string</td>
<td>申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝</td>
</tr>
<tr>
<td>time_ago</td>
<td>string</td>
<td>申请创建的时间</td>
</tr>
<tr>
<td>project.id</td>
<td>int</td>
<td>申请项目的id</td>
</tr>
<tr>
<td>project.identifier</td>
<td>string</td>
<td>申请项目的标识</td>
</tr>
<tr>
<td>project.name</td>
<td>string</td>
<td>申请项目的名称</td>
</tr>
<tr>
<td>project.description</td>
<td>string</td>
<td>申请项目的描述</td>
</tr>
<tr>
<td>project.is_public</td>
<td>bool</td>
<td>申请项目是否公开</td>
</tr>
<tr>
<td>project.owner.id</td>
<td>bool</td>
<td>申请项目拥有者id</td>
</tr>
<tr>
<td>project.owner.type</td>
<td>string</td>
<td>申请项目拥有者类型</td>
</tr>
<tr>
<td>project.owner.name</td>
<td>string</td>
<td>申请项目拥有者昵称</td>
</tr>
<tr>
<td>project.owner.login</td>
<td>string</td>
<td>申请项目拥有者标识</td>
</tr>
<tr>
<td>project.owner.image_url</td>
<td>string</td>
<td>申请项目拥有者头像</td>
</tr>
<tr>
<td>user.id</td>
<td>int</td>
<td>申请创建者的id</td>
</tr>
<tr>
<td>user.type</td>
<td>string</td>
<td>申请创建者的类型</td>
</tr>
<tr>
<td>user.name</td>
<td>string</td>
<td>申请创建者的名称</td>
</tr>
<tr>
<td>user.login</td>
<td>string</td>
<td>申请创建者的标识</td>
</tr>
<tr>
<td>user.image_url</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">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">74</span><span class="p">,</span><span class="w">
</span><span class="nl">"identifier"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"description"</span><span class="p">:</span><span class="w"> </span><span class="s2">"wwww"</span><span class="p">,</span><span class="w">
</span><span class="nl">"is_public"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nl">"owner"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/T/19_237_174/120.png"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"user"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"何慧"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"images/avatars/User/6?t=1622513134"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w">
</span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"accept"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-06-09 16:41"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"7分钟前"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h1 id='projects'>Projects</h1><h2 id='ac55469b06'>申请加入项目</h2>
<p>申请加入项目</p>
<blockquote>
<p>示例:</p>
</blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/applied_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">POST /api/appliedr_projects.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http'>HTTP 请求</h3>
<p><code>POST /api/applied_projects.json</code></p>
<h3 id='1f9ac54b15'>请求参数</h3>
<table><thead>
<tr>
<th>参数</th>
<th>必选</th>
<th>默认</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>applied_project.code</td>
<td></td>
<td></td>
<td>string</td>
<td>邀请码</td>
</tr>
<tr>
<td>applied_project.role</td>
<td></td>
<td></td>
<td>string</td>
<td>项目权限reporter: 报告者, developer: 开发者manager管理员</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">"applied_project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"code"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1una34"</span><span class="p">,</span><span class="w">
</span><span class="nl">"role"</span><span class="p">:</span><span class="w"> </span><span class="s2">"developer"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h3 id='b302a98fa6'>返回字段说明</h3>
<table><thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>字段说明</th>
</tr>
</thead><tbody>
<tr>
<td>id</td>
<td>int</td>
<td>申请id</td>
</tr>
<tr>
<td>status</td>
<td>string</td>
<td>申请状态canceled:取消,common:正在申请, accept:已接受,refuse:已拒绝</td>
</tr>
<tr>
<td>time_ago</td>
<td>string</td>
<td>项目申请创建的时间</td>
</tr>
<tr>
<td>project.id</td>
<td>int</td>
<td>申请项目的id</td>
</tr>
<tr>
<td>project.identifier</td>
<td>string</td>
<td>申请项目的标识</td>
</tr>
<tr>
<td>project.name</td>
<td>string</td>
<td>申请项目的名称</td>
</tr>
<tr>
<td>project.description</td>
<td>string</td>
<td>申请项目的描述</td>
</tr>
<tr>
<td>project.is_public</td>
<td>bool</td>
<td>申请项目是否公开</td>
</tr>
<tr>
<td>project.owner.id</td>
<td>bool</td>
<td>申请项目拥有者id</td>
</tr>
<tr>
<td>project.owner.type</td>
<td>string</td>
<td>申请项目拥有者类型</td>
</tr>
<tr>
<td>project.owner.name</td>
<td>string</td>
<td>申请项目拥有者昵称</td>
</tr>
<tr>
<td>project.owner.login</td>
<td>string</td>
<td>申请项目拥有者标识</td>
</tr>
<tr>
<td>project.owner.image_url</td>
<td>string</td>
<td>申请项目拥有者头像</td>
</tr>
<tr>
<td>user.id</td>
<td>int</td>
<td>申请创建者的id</td>
</tr>
<tr>
<td>user.type</td>
<td>string</td>
<td>申请创建者的类型</td>
</tr>
<tr>
<td>user.name</td>
<td>string</td>
<td>申请创建者的名称</td>
</tr>
<tr>
<td>user.login</td>
<td>string</td>
<td>申请创建者的标识</td>
</tr>
<tr>
<td>user.image_url</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">"project"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">74</span><span class="p">,</span><span class="w">
</span><span class="nl">"identifier"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"hehuisssjssjjsjs"</span><span class="p">,</span><span class="w">
</span><span class="nl">"description"</span><span class="p">:</span><span class="w"> </span><span class="s2">"wwww"</span><span class="p">,</span><span class="w">
</span><span class="nl">"is_public"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nl">"owner"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"testforge1"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"system/lets/letter_avatars/2/T/19_237_174/120.png"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"user"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w">
</span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"User"</span><span class="p">,</span><span class="w">
</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"何慧"</span><span class="p">,</span><span class="w">
</span><span class="nl">"login"</span><span class="p">:</span><span class="w"> </span><span class="s2">"yystopf"</span><span class="p">,</span><span class="w">
</span><span class="nl">"image_url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"images/avatars/User/6?t=1622513134"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="nl">"id"</span><span class="p">:</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w">
</span><span class="nl">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"common"</span><span class="p">,</span><span class="w">
</span><span class="nl">"created_at"</span><span class="p">:</span><span class="w"> </span><span class="s2">"2021-06-09 16:41"</span><span class="p">,</span><span class="w">
</span><span class="nl">"time_ago"</span><span class="p">:</span><span class="w"> </span><span class="s2">"1分钟前"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div><h2 id='bfdfb34952'>获取项目列表</h2>
<p>获取项目列表,也可以更加相关条件过滤搜素</p> <p>获取项目列表,也可以更加相关条件过滤搜素</p>
<blockquote> <blockquote>
@ -2710,9 +3417,9 @@ Success — a happy kitten is an authenticated kitten!
<span class="nt">-d</span> <span class="s2">"limit=5"</span> <span class="se">\</span> <span class="nt">-d</span> <span class="s2">"limit=5"</span> <span class="se">\</span>
http://localhost:3000/api/projects | jq http://localhost:3000/api/projects | 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/projects</span><span class="dl">'</span><span class="p">)</span> </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</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http'>HTTP 请求</h3> </code></pre></div><h3 id='http-2'>HTTP 请求</h3>
<p><code>GET api/projects</code></p> <p><code>GET api/projects</code></p>
<h3 id='1f9ac54b15'>请求参数</h3> <h3 id='1f9ac54b15-2'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -2779,7 +3486,7 @@ http://localhost:3000/api/projects | jq
<td>项目类型, 取值为common、mirror; common:开源托管项目, mirror:开源镜像项目</td> <td>项目类型, 取值为common、mirror; common:开源托管项目, mirror:开源镜像项目</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6'>返回字段说明</h3> <h3 id='b302a98fa6-2'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -2931,9 +3638,9 @@ Remember — a happy kitten is an authenticated kitten!
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span> <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/projects/recommend | jq http://localhost:3000/api/projects/recommend | 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/projects/recommend.json</span><span class="dl">'</span><span class="p">)</span> </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/recommend.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-2'>HTTP 请求</h3> </code></pre></div><h3 id='http-3'>HTTP 请求</h3>
<p><code>GET api/projects/recommend</code></p> <p><code>GET api/projects/recommend</code></p>
<h3 id='b302a98fa6-2'>返回字段说明</h3> <h3 id='b302a98fa6-3'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3067,9 +3774,9 @@ Remember — a happy kitten is an authenticated kitten!
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span> <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/yystopf/ceshi/menu_list | jq 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><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> </code></pre></div><h3 id='http-4'>HTTP 请求</h3>
<p><code>GET api/:owner/:repo/menu_list</code></p> <p><code>GET api/:owner/:repo/menu_list</code></p>
<h3 id='1f9ac54b15-2'>请求参数</h3> <h3 id='1f9ac54b15-3'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3094,7 +3801,7 @@ http://localhost:3000/api/yystopf/ceshi/menu_list | jq
<td>项目标识identifier</td> <td>项目标识identifier</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-3'>返回字段说明</h3> <h3 id='b302a98fa6-4'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3135,9 +3842,9 @@ http://localhost:3000/api/yystopf/ceshi/menu_list | jq
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span> <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 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><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> </code></pre></div><h3 id='http-5'>HTTP 请求</h3>
<p><code>GET api/:owner/:repo/about</code></p> <p><code>GET api/:owner/:repo/about</code></p>
<h3 id='1f9ac54b15-3'>请求参数</h3> <h3 id='1f9ac54b15-4'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3162,7 +3869,7 @@ http://localhost:3000/api/jasder/forgeplus/about | jq
<td>项目标识identifier</td> <td>项目标识identifier</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-4'>返回字段说明</h3> <h3 id='b302a98fa6-5'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3208,7 +3915,7 @@ Remember — a happy kitten is an authenticated kitten!
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span> <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/yystopf/ceshi/project_units.json 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">GET /api/yystopf/ceshi/project_units</span><span class="dl">'</span><span class="p">)</span> </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/project_units</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-5'>HTTP 请求</h3> </code></pre></div><h3 id='http-6'>HTTP 请求</h3>
<p><code>GET /api/yystopf/ceshi/project_units</code></p> <p><code>GET /api/yystopf/ceshi/project_units</code></p>
<h3 id='7447e4874e'>返回字段说明:</h3> <h3 id='7447e4874e'>返回字段说明:</h3>
<table><thead> <table><thead>
@ -3251,9 +3958,9 @@ http://localhost:3000/api/yystopf/ceshi/project_units.json
<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> <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 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><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-6'>HTTP 请求</h3> </code></pre></div><h3 id='http-7'>HTTP 请求</h3>
<p><code>POST /api/yystopf/ceshi/project_units</code></p> <p><code>POST /api/yystopf/ceshi/project_units</code></p>
<h3 id='1f9ac54b15-4'>请求参数</h3> <h3 id='1f9ac54b15-5'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3315,9 +4022,9 @@ http://localhost:3000/api/yystopf/ceshi/project_units.json
<span class="nt">-d</span> <span class="s2">"license_id=1"</span> <span class="se">\</span> <span class="nt">-d</span> <span class="s2">"license_id=1"</span> <span class="se">\</span>
http://localhost:3000/api/projects.json 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><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-7'>HTTP 请求</h3> </code></pre></div><h3 id='http-8'>HTTP 请求</h3>
<p><code>POST api/projects</code></p> <p><code>POST api/projects</code></p>
<h3 id='1f9ac54b15-5'>请求参数</h3> <h3 id='1f9ac54b15-6'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3391,7 +4098,7 @@ http://localhost:3000/api/projects.json
<td>项目是否私有, true为私有false: 公开,默认为公开</td> <td>项目是否私有, true为私有false: 公开,默认为公开</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-5'>返回字段说明</h3> <h3 id='b302a98fa6-6'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3433,9 +4140,9 @@ http://localhost:3000/api/projects.json
<span class="nt">-d</span> <span class="s2">"project_language_id=2"</span> <span class="se">\</span> <span class="nt">-d</span> <span class="s2">"project_language_id=2"</span> <span class="se">\</span>
http://localhost:3000/api/projects/migrate.json 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><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-8'>HTTP 请求</h3> </code></pre></div><h3 id='http-9'>HTTP 请求</h3>
<p><code>POST api/projects/migrate.json</code></p> <p><code>POST api/projects/migrate.json</code></p>
<h3 id='1f9ac54b15-6'>请求参数</h3> <h3 id='1f9ac54b15-7'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3523,7 +4230,7 @@ http://localhost:3000/api/projects/migrate.json
<td>项目是否私有, true为私有false: 非私有,默认为公开</td> <td>项目是否私有, true为私有false: 非私有,默认为公开</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-6'>返回字段说明</h3> <h3 id='b302a98fa6-7'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3558,9 +4265,9 @@ http://localhost:3000/api/projects/migrate.json
</blockquote> </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 <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><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-9'>HTTP 请求</h3> </code></pre></div><h3 id='http-10'>HTTP 请求</h3>
<p><code>POST api/repositories/:id/sync_mirror.json</code></p> <p><code>POST api/repositories/:id/sync_mirror.json</code></p>
<h3 id='1f9ac54b15-7'>请求参数</h3> <h3 id='1f9ac54b15-8'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3578,7 +4285,7 @@ http://localhost:3000/api/projects/migrate.json
<td>仓库id</td> <td>仓库id</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-7'>返回字段说明</h3> <h3 id='b302a98fa6-8'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3613,9 +4320,9 @@ http://localhost:3000/api/projects/migrate.json
</blockquote> </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 <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><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-10'>HTTP 请求</h3> </code></pre></div><h3 id='http-11'>HTTP 请求</h3>
<p><code>POST api/:owner/:repo/forks.json</code></p> <p><code>POST api/:owner/:repo/forks.json</code></p>
<h3 id='1f9ac54b15-8'>请求参数</h3> <h3 id='1f9ac54b15-9'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3640,7 +4347,7 @@ http://localhost:3000/api/projects/migrate.json
<td>项目标识identifier</td> <td>项目标识identifier</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-8'>返回字段说明</h3> <h3 id='b302a98fa6-9'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3676,9 +4383,9 @@ http://localhost:3000/api/projects/migrate.json
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> GET <span class="se">\</span> <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/ceshi1/ceshi_repo1/applied_transfer_projects/organizations.json | jq http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizations.json | 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/:owner/:repo/applied_transfer_projects/organizations</span><span class="dl">'</span><span class="p">)</span> </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/:owner/:repo/applied_transfer_projects/organizations</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-11'>HTTP 请求</h3> </code></pre></div><h3 id='http-12'>HTTP 请求</h3>
<p><code>GET api/:owner/:repo/applied_transfer_projects/organizations</code></p> <p><code>GET api/:owner/:repo/applied_transfer_projects/organizations</code></p>
<h3 id='1f9ac54b15-9'>请求参数</h3> <h3 id='1f9ac54b15-10'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3703,7 +4410,7 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
<td>项目标识identifier</td> <td>项目标识identifier</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-9'>返回字段说明</h3> <h3 id='b302a98fa6-10'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3770,9 +4477,9 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
</blockquote> </blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects.json <div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_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">POST /api/:owner/:repo/applied_transfer_projects.json</span><span class="dl">'</span><span class="p">)</span> </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/:owner/:repo/applied_transfer_projects.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-12'>HTTP 请求</h3> </code></pre></div><h3 id='http-13'>HTTP 请求</h3>
<p><code>POST /api/:owner/:repo/applied_transfer_projects.json</code></p> <p><code>POST /api/:owner/:repo/applied_transfer_projects.json</code></p>
<h3 id='1f9ac54b15-10'>请求参数</h3> <h3 id='1f9ac54b15-11'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3804,7 +4511,7 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
<td>迁移对象标识</td> <td>迁移对象标识</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-10'>返回字段说明</h3> <h3 id='b302a98fa6-11'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -3974,9 +4681,9 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
</blockquote> </blockquote>
<div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/cancel.json <div class="highlight"><pre class="highlight shell tab-shell"><code>curl <span class="nt">-X</span> POST http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/cancel.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/:owner/:repo/applied_transfer_projects/cancel.json</span><span class="dl">'</span><span class="p">)</span> </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/:owner/:repo/applied_transfer_projects/cancel.json</span><span class="dl">'</span><span class="p">)</span>
</code></pre></div><h3 id='http-13'>HTTP 请求</h3> </code></pre></div><h3 id='http-14'>HTTP 请求</h3>
<p><code>POST /api/:owner/:repo/applied_transfer_projects/cancel.json</code></p> <p><code>POST /api/:owner/:repo/applied_transfer_projects/cancel.json</code></p>
<h3 id='1f9ac54b15-11'>请求参数</h3> <h3 id='1f9ac54b15-12'>请求参数</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>
@ -4001,7 +4708,7 @@ http://localhost:3000/api/ceshi1/ceshi_repo1/applied_transfer_projects/organizat
<td>项目标识identifier</td> <td>项目标识identifier</td>
</tr> </tr>
</tbody></table> </tbody></table>
<h3 id='b302a98fa6-11'>返回字段说明</h3> <h3 id='b302a98fa6-12'>返回字段说明</h3>
<table><thead> <table><thead>
<tr> <tr>
<th>参数</th> <th>参数</th>