Class: Admin::AppsController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::AppsController
- Defined in:
- app/controllers/wechat/admin/apps_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit_cert ⇒ Object
- #index ⇒ Object
- #info ⇒ Object
- #new ⇒ Object
- #update_cert ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/wechat/admin/apps_controller.rb', line 17 def create @app = App.find_or_initialize_by(appid: app_params[:appid]) if @app.organ @app.errors.add :base, '该账号已在其他组织添加,请联系客服' end @app.assign_attributes app_params unless @app.save render :new, locals: { model: @app }, status: :unprocessable_entity end end |
#edit_cert ⇒ Object
32 33 |
# File 'app/controllers/wechat/admin/apps_controller.rb', line 32 def edit_cert end |
#index ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/controllers/wechat/admin/apps_controller.rb', line 5 def index q_params = {} q_params.merge! default_params q_params.merge! params.permit(:id, :type) @apps = App.default_where(q_params).order(id: :asc).page(params[:page]) end |
#info ⇒ Object
29 30 |
# File 'app/controllers/wechat/admin/apps_controller.rb', line 29 def info end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/wechat/admin/apps_controller.rb', line 13 def new @app = App.new end |
#update_cert ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/controllers/wechat/admin/apps_controller.rb', line 35 def update_cert pkcs12 = WxPay::Utils.set_apiclient_by_pkcs12(params[:cert].read, @app.mch_id) @app.apiclient_cert = pkcs12.certificate @app.apiclient_key = pkcs12.key @app.save end |