Menus.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\wechat;
  12. use app\controller\admin\AuthController;
  13. use app\services\wechat\WechatMenuServices;
  14. use think\facade\App;
  15. /**
  16. * 微信菜单 控制器
  17. * Class Menus
  18. * @package app\controller\admin\v1\application\wechat
  19. */
  20. class Menus extends AuthController
  21. {
  22. /**
  23. * 构造方法
  24. * Menus constructor.
  25. * @param App $app
  26. * @param WechatMenuServices $services
  27. */
  28. public function __construct(App $app, WechatMenuServices $services)
  29. {
  30. parent::__construct($app);
  31. $this->services = $services;
  32. }
  33. /**
  34. * 获取菜单
  35. * @return mixed
  36. */
  37. public function index()
  38. {
  39. $menus = $this->services->getWechatMenu();
  40. return $this->success(compact('menus'));
  41. }
  42. /**
  43. * 保存菜单
  44. * @return mixed
  45. */
  46. public function save()
  47. {
  48. $buttons = request()->post('button/a', []);
  49. if (!count($buttons)) return $this->fail('请添加至少一个按钮');
  50. $this->services->saveMenu($buttons);
  51. return $this->success('修改成功!');
  52. }
  53. }