更改:组织缓存信息方式改在控制器里面

This commit is contained in:
yystopf 2022-09-15 09:38:28 +08:00
parent 4bd77a870b
commit 383660c778
2 changed files with 6 additions and 4 deletions

View File

@ -31,6 +31,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
Organizations::CreateForm.new(organization_params.merge(original_name: "")).validate!
@organization = Organizations::CreateService.call(current_user, organization_params)
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
Cache::V2::OwnerCommonService.new(@organization.id).reset
end
rescue Exception => e
uid_logger_error(e.message)
@ -48,6 +49,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
Gitea::Organization::UpdateService.call(current_user.gitea_token, login, @organization.reload)
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
Cache::V2::OwnerCommonService.new(@organization.id).reset
end
rescue Exception => e
uid_logger_error(e.message)

View File

@ -81,15 +81,15 @@ class Organization < Owner
scope :with_visibility, ->(visibility) { joins(:organization_extension).where(organization_extensions: {visibility: visibility}) if visibility.present? }
after_save :reset_cache_data
# after_save :reset_cache_data
def gitea_token
team_users.joins(:team).where(teams: {authorize: "owner"}).take&.user&.gitea_token
end
def reset_cache_data
Cache::V2::OwnerCommonService.new(self.id).reset
end
# def reset_cache_data
# Cache::V2::OwnerCommonService.new(self.id).reset
# end
def self.build(name, nickname, gitea_token=nil)
self.create!(login: name, nickname: nickname, gitea_token: gitea_token)