SystemNotification.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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\message;
  12. use app\controller\admin\AuthController;
  13. use app\services\message\SystemNotificationServices;
  14. use think\facade\App;
  15. /**
  16. * Class SystemNotification
  17. * @package app\adminapi\controller\v1\message
  18. */
  19. class SystemNotification extends AuthController
  20. {
  21. /**
  22. * SystemRole constructor.
  23. * @param App $app
  24. * @param SystemNotificationServices $services
  25. */
  26. public function __construct(App $app, SystemNotificationServices $services)
  27. {
  28. parent::__construct($app);
  29. $this->services = $services;
  30. }
  31. /**
  32. * 显示资源列表
  33. *
  34. * @return \think\Response
  35. */
  36. public function index()
  37. {
  38. $where = $this->request->getMore([
  39. ['type', ''],
  40. ]);
  41. return app('json')->success($this->services->getNotList($where));
  42. }
  43. /**
  44. * 显示编辑
  45. *
  46. * @return \think\Response
  47. */
  48. public function info()
  49. {
  50. $where = $this->request->getMore([
  51. ['type', ''],
  52. ['id', 0]
  53. ]);
  54. if (!$where['id']) return app('json')->fail('参数错误');
  55. return app('json')->success($this->services->getNotInfo($where));
  56. }
  57. /**
  58. * 保存新建的资源
  59. *
  60. * @return \think\Response
  61. */
  62. public function save()
  63. {
  64. $data = $this->request->postMore([
  65. ['id', 0],
  66. ['type', ''],
  67. ['name', ''],
  68. ['title', ''],
  69. ['is_system', 0],
  70. ['is_app', 0],
  71. ['is_wechat', 0],
  72. ['is_routine', 0],
  73. ['is_sms', 0],
  74. ['is_ent_wechat', 0],
  75. ['system_title', ''],
  76. ['system_text', ''],
  77. ['tempid', ''],
  78. ['ent_wechat_text', ''],
  79. ['url', ''],
  80. ['wechat_id', ''],
  81. ['routine_id', '']
  82. ]);
  83. if (!$data['id']) return app('json')->fail('参数错误');
  84. if ($this->services->saveData($data)) {
  85. $this->services->clearTemplateCache();
  86. return app('json')->success('修改成功!');
  87. } else {
  88. return app('json')->fail('修改失败,请稍候再试!');
  89. }
  90. }
  91. /**
  92. * 修改消息状态
  93. *
  94. * @return array
  95. */
  96. public function set_status($type, $status, $id)
  97. {
  98. if ($type == '' || $status == '' || $id == 0) return $this->fail('参数错误');
  99. $this->services->update($id, [$type => $status]);
  100. $this->services->clearTemplateCache();
  101. return $this->success($status == 1 ? '开启成功' : '关闭成功');
  102. }
  103. }