Setting.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\controller\client\h5;
  13. use app\store\controller\Controller;
  14. use app\store\model\h5\Setting as SettingModel;
  15. /**
  16. * H5端基本设置
  17. * Class Setting
  18. * @package app\store\controller\apps\wxapp
  19. */
  20. class Setting extends Controller
  21. {
  22. /**
  23. * 获取H5端设置 (指定)
  24. * @param string $key
  25. * @return \think\response\Json
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. */
  30. public function detail(string $key): \think\response\Json
  31. {
  32. $detail = SettingModel::getItem($key);
  33. return $this->renderSuccess(compact('detail'));
  34. }
  35. /**
  36. * 更新设置项
  37. * @param string $key
  38. * @return \think\response\Json
  39. */
  40. public function update(string $key): \think\response\Json
  41. {
  42. $model = new SettingModel;
  43. if ($model->edit($key, $this->postForm())) {
  44. return $this->renderSuccess('更新成功');
  45. }
  46. return $this->renderError($model->getError() ?: '更新失败');
  47. }
  48. }