Sms.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\controller\system;
  10. use app\admin\controller\Auth;
  11. use mall\response\Response;
  12. use think\facade\Request;
  13. use think\facade\View;
  14. use app\common\models\Setting as SettingModel;
  15. use app\admin\service\system\Sms as SmsService;
  16. class Sms extends Auth {
  17. /**
  18. * 短信设置
  19. * @return string|\think\response\Json
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\DbException
  22. * @throws \think\db\exception\ModelNotFoundException
  23. */
  24. public function setting(){
  25. if(Request::isAjax()){
  26. SettingModel::saveData("sms",Request::post());
  27. return Response::returnArray("操作成功!");
  28. }
  29. return View::fetch("",[ "data"=>SettingModel::getArrayData("sms") ]);
  30. }
  31. /**
  32. * 短信模板
  33. * @return string|\think\response\Json
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. */
  38. public function template(){
  39. if(Request::isAjax()){
  40. $list = SmsService::getList(Request::param());
  41. return Response::returnArray("ok",0,$list['data'],$list['count']);
  42. }
  43. return View::fetch();
  44. }
  45. /**
  46. * 编辑模板
  47. * @return string|\think\response\Json
  48. */
  49. public function template_editor(){
  50. try{
  51. if(Request::isAjax()){
  52. SmsService::save(Request::param());
  53. return Response::returnArray("操作成功!");
  54. }
  55. return View::fetch("",SmsService::detail(Request::param("id",0,"intval")));
  56. }catch (\Exception $ex){
  57. }
  58. }
  59. /**
  60. * 更新字段
  61. * @return \think\response\Json
  62. */
  63. public function field(){
  64. try {
  65. SmsService::setFields();
  66. return Response::returnArray("操作成功");
  67. }catch (\Exception $ex){
  68. return Response::returnArray($ex->getMessage(),0);
  69. }
  70. }
  71. }