forgeplus/app/controllers/admins/identity_verifications_cont...

39 lines
1.4 KiB
Ruby

class Admins::IdentityVerificationsController < Admins::BaseController
before_action :require_business
before_action :finder_identity_verification, except: [:index]
def index
params[:sort_by] = params[:sort_by].presence || 'created_at'
params[:sort_direction] = params[:sort_direction].presence || 'desc'
identity_verifications = Admins::IdentityVerificationQuery.call(params)
@identity_verifications = paginate identity_verifications.preload(:user)
end
def show
render 'edit'
end
def edit
end
def update
if update_params[:state] == "已拒绝" && update_params[:description].blank?
flash[:danger] = '拒绝理由不能为空'
render 'edit'
else
UserAction.create(action_id: @identity_verification.id, action_type: "UpdateIdentityVerifications", user_id: current_user.id, :ip => request.remote_ip, data_bank: @identity_verification.attributes.to_json)
@identity_verification.update(update_params)
redirect_to admins_identity_verifications_path
flash[:success] = "更新成功"
end
end
private
def finder_identity_verification
@identity_verification = IdentityVerification.find(params[:id])
@user = @identity_verification.user
end
def update_params
params.require(:identity_verification).permit(:state, :description)
end
end