mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
29
app/controllers/admins/salesmans_controller.rb
Normal file
29
app/controllers/admins/salesmans_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
class Admins::SalesmansController < Admins::BaseController
|
||||
before_action :set_salesman, except: [:index, :batch_add]
|
||||
|
||||
def index
|
||||
@salesmans = Salesman.all
|
||||
end
|
||||
|
||||
def destroy
|
||||
@salesman.destroy!
|
||||
end
|
||||
|
||||
# 批量增加销售人员
|
||||
def batch_add
|
||||
salesman_user_ids = Salesman.where(id: params[:user_ids]).pluck(:user_id)
|
||||
user_ids = params[:user_ids] - salesman_user_ids
|
||||
user_ids.each do |user_id|
|
||||
user = User.find_by(id: user_id)
|
||||
next if user.blank?
|
||||
Salesman.create!(user_id: user.id, name: user.real_name)
|
||||
end
|
||||
render_ok
|
||||
end
|
||||
|
||||
private
|
||||
def set_salesman
|
||||
@salesman = Salesman.find params[:id]
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user