Class: EricWeixin::Cms::Weixin::PublicAccountsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_menuObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb', line 10

def create_menu
  begin
    @public_account = ::EricWeixin::PublicAccount.find(params[:id])
    @public_account.create_menu params[:menu_json]
  rescue Exception => e
    dispose_exception e
    flash[:alert] = '创建菜单失败,原因:' + get_notice_str
  end

  redirect_to :action => :show
end

#exportObject



30
31
32
33
34
# File 'app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb', line 30

def export
  @public_account = ::EricWeixin::PublicAccount.find(params[:id])
  @csv = EricWeixin::WeixinUser.export_users_to_csv(@public_account.id)
  send_data @csv
end

#indexObject



2
3
4
# File 'app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb', line 2

def index
  @public_accounts = ::EricWeixin::PublicAccount.all.paginate(page:params[:page], per_page: 5)
end

#rebuild_weixin_usersObject



22
23
24
25
26
27
28
# File 'app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb', line 22

def rebuild_weixin_users
  @public_account = ::EricWeixin::PublicAccount.find(params[:id])
  @public_account.rebuild_users
  # set_notice("重建成功")
  flash[:success] = "更新用户列表成功。"
  redirect_to :action => :index
end

#showObject



5
6
7
8
# File 'app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb', line 5

def show
  @public_account = ::EricWeixin::PublicAccount.find(params[:id])
  @weixin_menus = @public_account.weixin_menus.to_json
end