Class: EducodeSales::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- EducodeSales::ApplicationController
show all
- Defined in:
- app/controllers/educode_sales/application_controller.rb
Direct Known Subclasses
ActivitiesController, AssessmentsController, BusinessesController, CommonsController, ContractsController, CustomerExtensionsController, CustomerFollowsController, CustomersController, FollowUpsController, HomeController, IdeaRecyclesController, IdeasController, ImportTeachersController, KeyPersonController, LogsController, MoneyPlanRecordsController, MoneyPlansController, OperationPlansController, OperationReportsController, OperationsController, PlacesController, PlansController, ProjectChartsController, ProjectsController, RecyclesController, ResultsController, RolesController, SaleReportsController, SaleTrendsController, SalesController, SalesDetailsController, SessionsController, StaffsController, TeacherFollowsController, TeachersController, UploadFilesController, UserBehaviorsController
Instance Method Summary
collapse
Instance Method Details
#authenticate_admin ⇒ Object
26
27
28
29
30
|
# File 'app/controllers/educode_sales/application_controller.rb', line 26
def authenticate_admin
unless current_user&.is_admin
redirect_to no_permission_path
end
end
|
#authenticate_request ⇒ Object
18
19
20
21
22
23
24
|
# File 'app/controllers/educode_sales/application_controller.rb', line 18
def authenticate_request
if current_user
current_user.check_login_status(request)
else
redirect_to login_path
end
end
|
#current_user ⇒ Object
14
15
16
|
# File 'app/controllers/educode_sales/application_controller.rb', line 14
def current_user
@current_admin ||= Staff.find_by_id(session[:admin_id])
end
|
#filter ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/educode_sales/application_controller.rb', line 32
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
|
#render_failure(msg) ⇒ Object
10
11
12
|
# File 'app/controllers/educode_sales/application_controller.rb', line 10
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
6
7
8
|
# File 'app/controllers/educode_sales/application_controller.rb', line 6
def render_success
render json: { success: true }
end
|