You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
class Admins::SalesmanChannelsController < Admins::BaseController
|
|
|
|
before_action :set_salesman
|
|
|
|
|
|
|
|
def index
|
|
|
|
@channels = SalesmanChannel.all
|
|
|
|
@start_time = params[:start_time]
|
|
|
|
@end_time = params[:end_time] || Time.now
|
|
|
|
@keyword = params[:keyword]
|
|
|
|
end
|
|
|
|
|
|
|
|
def batch_add
|
|
|
|
channel_ids = @salesman.salesman_channels.pluck(:school_id)
|
|
|
|
school_ids = params[:school_ids] - channel_ids
|
|
|
|
school_ids.each do |school_id|
|
|
|
|
school = School.find_by(id: school_id)
|
|
|
|
next if school.blank?
|
|
|
|
@salesman.salesman_channels.create!(school_id: school.id)
|
|
|
|
end
|
|
|
|
render_ok
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@salesman.salesman_channels.find_by!(id: params[:id]).destroy
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_salesman
|
|
|
|
@salesman = Salesman.find params[:salesman_id]
|
|
|
|
end
|
|
|
|
end
|