|
|
@ -374,10 +374,10 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
def update
|
|
|
|
# 镜像方面
|
|
|
|
# 镜像方面
|
|
|
|
mirror_ids = MirrorRepository.where(id: params[:main_type]).or(id: params[:small_type]).pluck(:id)
|
|
|
|
mirror_ids = MirrorRepository.where(id: params[:main_type]).or( MirrorRepository.where(id: params[:small_type])).pluck(:id)
|
|
|
|
old_mirror_ids = @shixun.shixun_mirror_repositories
|
|
|
|
old_mirror_ids = @shixun.shixun_mirror_repositories
|
|
|
|
.where(mirror_repository_id: params[:main_type])
|
|
|
|
.where(mirror_repository_id: params[:main_type])
|
|
|
|
.or(mirror_repository_id: params[:small_type]).pluck(:mirror_repository_id)
|
|
|
|
.or(@shixun.shixun_mirror_repositories.where(mirror_repository_id: params[:small_type])).pluck(:mirror_repository_id)
|
|
|
|
new_mirror_id = (mirror_ids - old_mirror_ids).map{|id| {mirror_repository_id: id}} # 转换成数组hash方便操作
|
|
|
|
new_mirror_id = (mirror_ids - old_mirror_ids).map{|id| {mirror_repository_id: id}} # 转换成数组hash方便操作
|
|
|
|
# 服务配置方面
|
|
|
|
# 服务配置方面
|
|
|
|
service_params = service_config_params[:shixun_service_configs]
|
|
|
|
service_params = service_config_params[:shixun_service_configs]
|
|
|
@ -393,6 +393,19 @@ class ShixunsController < ApplicationController
|
|
|
|
# 镜像变动要更换服务配置
|
|
|
|
# 镜像变动要更换服务配置
|
|
|
|
@shixun.shixun_service_configs.not(mirror_repository_id: old_mirror_ids).destroy_all
|
|
|
|
@shixun.shixun_service_configs.not(mirror_repository_id: old_mirror_ids).destroy_all
|
|
|
|
@shixun.shixun_mirror_repositories.create!(service_params)
|
|
|
|
@shixun.shixun_mirror_repositories.create!(service_params)
|
|
|
|
|
|
|
|
# 添加第二仓库(管理员权限)
|
|
|
|
|
|
|
|
if current_user.admin_or_business?
|
|
|
|
|
|
|
|
if params[:is_secret_repository]
|
|
|
|
|
|
|
|
add_secret_repository if @shixun.shixun_secret_repository.blank?
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# 如果有仓库,就要删
|
|
|
|
|
|
|
|
if @shixun.shixun_secret_repository&.repo_name
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.lock!
|
|
|
|
|
|
|
|
GitService.delete_repository(repo_path: @shixun.shixun_secret_repository.repo_path)
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue => e
|
|
|
|
rescue => e
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
uid_logger_error(e.message)
|
|
|
@ -423,19 +436,6 @@ class ShixunsController < ApplicationController
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
@shixun.update_attributes!(shixun_params)
|
|
|
|
@shixun.update_attributes!(shixun_params)
|
|
|
|
# 添加第二仓库(管理员权限)
|
|
|
|
|
|
|
|
if current_user.admin_or_business?
|
|
|
|
|
|
|
|
if params[:is_secret_repository]
|
|
|
|
|
|
|
|
add_secret_repository if @shixun.shixun_secret_repository.blank?
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# 如果有仓库,就要删
|
|
|
|
|
|
|
|
if @shixun.shixun_secret_repository&.repo_name
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.lock!
|
|
|
|
|
|
|
|
GitService.delete_repository(repo_path: @shixun.shixun_secret_repository.repo_path)
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue => e
|
|
|
|
rescue => e
|
|
|
|
uid_logger_error("实训学习页面设置失败--------#{e.message}")
|
|
|
|
uid_logger_error("实训学习页面设置失败--------#{e.message}")
|
|
|
|