modify win bidding apig

dev_cs_new
p31729568 6 years ago
parent 0f8a31e1b2
commit 58451911fa

@ -9,8 +9,7 @@ class BiddingUsersController < ApplicationController
end
def win
package = current_user.project_packages.find(params[:project_package_id])
ProjectPackages::WinBiddingService.call(package, params)
ProjectPackages::WinBiddingService.call(current_package, current_user, params)
render_ok
rescue ProjectPackages::WinBiddingService::Error => ex
render_error(ex.message)

@ -1,14 +1,16 @@
class ProjectPackages::WinBiddingService < ApplicationService
Error = Class.new(StandardError)
attr_reader :package, :params
attr_reader :package, :user, :params
def initialize(package, params)
def initialize(package, user, params)
@package = package
@user = user
@params = params
end
def call
raise Error, '没有权限' unless package.creator_id == user.id || user.admin_or_business?
raise Error, '竞标报名还未结束' unless package.bidding_end?
raise Error, '该状态下不能选择中标者' unless package.may_finish_bidding?

Loading…
Cancel
Save