diff --git a/app/controllers/admins/topic/banners_controller.rb b/app/controllers/admins/topic/banners_controller.rb index 359845806..8d48892bc 100644 --- a/app/controllers/admins/topic/banners_controller.rb +++ b/app/controllers/admins/topic/banners_controller.rb @@ -1,8 +1,9 @@ class Admins::Topic::BannersController < Admins::Topic::BaseController before_action :find_banner, only: [:edit, :update, :destroy] - def index + def index @banners = paginate(::Topic::Banner) + @banners = paginate(::Topic::Banner.where("title like ?", "%#{params[:search]}%")) if params[:search].present? end def new diff --git a/app/controllers/mark_files_controller.rb b/app/controllers/mark_files_controller.rb index 4668471e3..36b5b81f0 100644 --- a/app/controllers/mark_files_controller.rb +++ b/app/controllers/mark_files_controller.rb @@ -9,21 +9,39 @@ class MarkFilesController < ApplicationController end def create - unless @pull_request.mark_files.present? - MarkFile.bulk_insert(*%i[pull_request_id, file_path_sha file_path created_at updated_at]) do |worker| - @files_result['Files'].each do |file| - worker.add(pull_request_id: @pull_request.id, file_path_sha: SecureRandom.uuid.gsub("-", ""), file_path: file['Name']) - end - end - end + # unless @pull_request.mark_files.present? + # MarkFile.bulk_insert(*%i[pull_request_id, file_path_sha file_path created_at updated_at]) do |worker| + # @files_result['Files'].each do |file| + # worker.add(pull_request_id: @pull_request.id, file_path_sha: SecureRandom.uuid.gsub("-", ""), file_path: file['Name']) + # end + # end + # end end def mark_file_as_unread - + tip_exception "参数错误" if params[:file_path_sha].blank? + file_path = Base64.strict_decode64(params[:file_path_sha].to_s) + mark_file = @pull_request.mark_files.find_or_initialize_by(file_path_sha: params[:file_path_sha]) + mark_file.file_path = file_path + mark_file.user_id = current_user.id + mark_file.mark_as_read = false + mark_file.save + render_ok + rescue Exception => e + tip_exception "参数解析错误" end def mark_file_as_read - + tip_exception "参数错误" if params[:file_path_sha].blank? + file_path = Base64.strict_decode64(params[:file_path_sha].to_s) + mark_file = @pull_request.mark_files.find_or_initialize_by(file_path_sha: params[:file_path_sha]) + mark_file.file_path = file_path + mark_file.user_id = current_user.id + mark_file.mark_as_read = true + mark_file.save + render_ok + rescue Exception => e + tip_exception "参数解析错误" end private diff --git a/config/routes.rb b/config/routes.rb index f7483666b..32f7ae3e2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -557,7 +557,11 @@ Rails.application.routes.draw do get :files get :commits resources :reviews, only: [:create] - resources :mark_files, only: [:index, :create] + scope '/diffs' do + resources :mark_files, only: [:index] + put :mark_file_as_unread, to: 'mark_files#mark_file_as_unread', as: 'mark_file_as_unread' + put :mark_file_as_read, to: 'mark_files#mark_file_as_read', as: 'mark_file_as_read' + end end collection do post :check_can_merge