Notice.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\notice;
  12. use app\dict\sys\SmsDict;
  13. use app\service\admin\notice\NoticeService;
  14. use app\service\admin\notice\SmsService;
  15. use core\base\BaseAdminController;
  16. use core\exception\AdminException;
  17. use think\Response;
  18. class Notice extends BaseAdminController
  19. {
  20. /**
  21. * 消息列表
  22. * @return Response
  23. */
  24. public function lists()
  25. {
  26. $res = (new NoticeService())->getList();
  27. return success($res);
  28. }
  29. public function info($key)
  30. {
  31. $res = (new NoticeService())->getInfo($key);
  32. return success($res);
  33. }
  34. /**
  35. * 消息启动与关闭
  36. * @return Response
  37. */
  38. public function editStatus()
  39. {
  40. $data = $this->request->params([
  41. ['key', ''],
  42. ['type', ''],
  43. ['status', 0],
  44. ]);
  45. (new NoticeService())->editMessageStatus($data['key'], $data['type'], $data['status']);
  46. return success();
  47. }
  48. /**
  49. * 短信配置列表
  50. */
  51. public function smsList()
  52. {
  53. $res = (new SmsService())->getList();
  54. return success($res);
  55. }
  56. /**
  57. * 短信配置详情
  58. * @param $sms_type
  59. * @return Response
  60. */
  61. public function smsConfig($sms_type)
  62. {
  63. $res = (new SmsService())->getConfig($sms_type);
  64. return success($res);
  65. }
  66. /**
  67. * 短信配置修改
  68. * @return Response
  69. */
  70. public function editSms($sms_type)
  71. {
  72. //参数获取
  73. $sms_type_list = SmsDict::getType();
  74. if (!array_key_exists($sms_type, $sms_type_list)) throw new AdminException('SMS_TYPE_NOT_EXIST');
  75. //数据验证
  76. $data = [
  77. ['is_use', 0]
  78. ];
  79. foreach ($sms_type_list[$sms_type]['params'] as $k_param => $v_param) {
  80. $data[] = [$k_param, ''];
  81. }
  82. $request_data = $this->request->params($data);
  83. (new SmsService())->setConfig($sms_type, $request_data);
  84. return success();
  85. }
  86. /**
  87. * 消息修改
  88. * @return Response
  89. */
  90. public function edit()
  91. {
  92. $data = $this->request->params([
  93. ['key', ''],
  94. ['type', ''],
  95. ['status', ''],
  96. ['sms_id', ''],
  97. ['wechat_first', ''],
  98. ['wechat_remark', ''],
  99. ]);
  100. (new NoticeService())->edit($data['key'], $data['type'], $data);
  101. return success();
  102. }
  103. }