SystemNotification.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\setting;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\message\SystemNotificationServices;
  14. use crmeb\services\CacheService;
  15. use think\facade\App;
  16. /**
  17. * Class SystemRole
  18. * @package app\adminapi\controller\v1\setting
  19. */
  20. class SystemNotification extends AuthController
  21. {
  22. /**
  23. * SystemRole constructor.
  24. * @param App $app
  25. * @param SystemNotificationServices $services
  26. */
  27. public function __construct(App $app, SystemNotificationServices $services)
  28. {
  29. parent::__construct($app);
  30. $this->services = $services;
  31. }
  32. /**
  33. * 显示资源列表
  34. *
  35. * @return \think\Response
  36. */
  37. public function index()
  38. {
  39. $where = $this->request->getMore([
  40. ['type', ''],
  41. ]);
  42. return app('json')->success($this->services->getNotList($where));
  43. }
  44. /**
  45. * 显示编辑
  46. *
  47. * @return \think\Response
  48. */
  49. public function info()
  50. {
  51. $where = $this->request->getMore([
  52. ['type', ''],
  53. ['id', 0]
  54. ]);
  55. if (!$where['id']) return app('json')->fail(100100);
  56. return app('json')->success($this->services->getNotInfo($where));
  57. }
  58. /**
  59. * 保存新建的资源
  60. *
  61. * @return \think\Response
  62. */
  63. public function save()
  64. {
  65. $data = $this->request->postMore([
  66. ['id', 0],
  67. ['type', ''],
  68. ['name', ''],
  69. ['title', ''],
  70. ['is_system', 0],
  71. ['is_app', 0],
  72. ['is_wechat', 0],
  73. ['is_routine', 0],
  74. ['is_sms', 0],
  75. ['is_ent_wechat', 0],
  76. ['system_title', ''],
  77. ['system_text', ''],
  78. ['tempid', ''],
  79. ['ent_wechat_text', ''],
  80. ['url', ''],
  81. ['wechat_id', ''],
  82. ['routine_id', ''],
  83. ['mark', ''],
  84. ['sms_id', ''],
  85. ]);
  86. if (!$data['id']) return app('json')->fail(100100);
  87. if ($this->services->saveData($data)) {
  88. CacheService::delete('NOTCE_'. $data['mark']);
  89. return app('json')->success(100001);
  90. } else {
  91. return app('json')->fail(100007);
  92. }
  93. }
  94. /**
  95. * 修改消息状态
  96. *
  97. * @return array
  98. */
  99. public function set_status($type, $status, $id)
  100. {
  101. if ($type == '' || $status == '' || $id == 0) return app('json')->fail(100100);
  102. $this->services->update($id, [$type => $status]);
  103. $res = $this->services->getOneNotce(['id'=>$id]);
  104. CacheService::delete('NOTCE_'.$res->mark);
  105. return app('json')->success(100014);
  106. }
  107. }