Class: EducodeSales::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- EducodeSales::ApplicationController
show all
- Includes:
- ApplicationHelper
- Defined in:
- app/controllers/educode_sales/application_controller.rb
Direct Known Subclasses
ActivitiesController, AssessmentsController, BusinessCoursesController, BusinessesController, CommonsController, ContractsController, CustomerExtensionsController, CustomerFollowsController, CustomersController, FollowUpsController, HomeController, IdeaFollowsController, IdeaRecyclesController, IdeasController, ImportTeachersController, InvoicesController, KeyPersonController, LogsController, MoneyPlanRecordsController, MoneyPlansController, OperationPlansController, OperationReportsController, OperationsController, PlacesController, PlansController, ProjectChartsController, ProjectsController, RecyclesController, ResultsController, RolesController, SaleReportsController, SaleTrendsController, SalesController, SalesDetailsController, SessionsController, ShixunDectectsController, ShixunsController, StaffsController, SubjectTrendsController, SubjectsController, TeacherFollowsController, TeachersController, UploadFilesController, UserBehaviorsController
Instance Method Summary
collapse
#add_businesses_score, #base_url, #collection_amount_score, #completion_rate, #current?, #disk_filename, #get_businesses_chart, #handled_data, #handled_time_data, #handled_time_data_accurate, #relative_path, #signed_amount_score, #storage_path, #url_to_avatar, #visits_score
Instance Method Details
#authenticate_admin ⇒ Object
56
57
58
59
60
|
# File 'app/controllers/educode_sales/application_controller.rb', line 56
def authenticate_admin
unless current_user&.is_admin
redirect_to no_permission_path
end
end
|
#authenticate_request ⇒ Object
48
49
50
51
52
53
54
|
# File 'app/controllers/educode_sales/application_controller.rb', line 48
def authenticate_request
if current_user
current_user.check_login_status(request)
else
redirect_to login_path
end
end
|
#current_user ⇒ Object
44
45
46
|
# File 'app/controllers/educode_sales/application_controller.rb', line 44
def current_user
@current_admin ||= Staff.find_by_id(session[:admin_id])
end
|
#filter ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/educode_sales/application_controller.rb', line 62
def filter
params[:check] = params[:check] == "true" ? 0:1
begin
filter = Filter.find_or_create_by!(staff_id: @current_admin.id, clazz: params[:type])
filter.["#{params[:name]}"] = params[:check]
filter.save!
render json: {success: true ,hidden: params[:check]}
rescue => e
render_failure("操作失败")
end
end
|
#is_commissioner_above?(clazz_type = "business") ⇒ Boolean
#paginate(relation) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'app/controllers/educode_sales/application_controller.rb', line 74
def paginate(relation)
limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 100) ? 20 : limit.to_i
page = params[:page].to_i.zero? ? 1 : params[:page].to_i
offset = (page - 1) * limit
if relation.is_a?(Array)
relation[offset, limit]
else
relation.limit(limit).offset(offset)
end
end
|
#render_failure(msg) ⇒ Object
40
41
42
|
# File 'app/controllers/educode_sales/application_controller.rb', line 40
def render_failure(msg)
render json: { success: false, msg: msg.is_a?(String) ? msg : msg.errors.full_messages.join(",") }, status: 403
end
|
#render_success ⇒ Object
36
37
38
|
# File 'app/controllers/educode_sales/application_controller.rb', line 36
def render_success
render json: { success: true }
end
|
#subject_members ⇒ Object
21
22
23
24
|
# File 'app/controllers/educode_sales/application_controller.rb', line 21
def subject_members
common = Common.find_by(clazz: 'staff_type', name: '课程')
@manages = Staff.joins(:user).where(job_type: common.id.to_i).where.not(role_id: 11).map { |d| {name: d.user.real_name, value: d.id}}
end
|
#subject_staffs ⇒ Object
26
27
28
29
|
# File 'app/controllers/educode_sales/application_controller.rb', line 26
def subject_staffs
common = Common.find_by(clazz: 'staff_type', name: '销售')
@staffs = Staff.joins(:user).where(job_type: common.id).where.not(role_id: 11).map { |d| { value: d.id, name: d.name } }
end
|
#subject_url ⇒ Object
31
32
33
34
|
# File 'app/controllers/educode_sales/application_controller.rb', line 31
def subject_url
@url = "https://data.educoder.net"
@admins_url = "https://data.educoder.net"
end
|