Setting.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 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 think\response\Json;
  14. use app\store\controller\Controller;
  15. use app\store\model\h5\Setting as SettingModel;
  16. /**
  17. * H5端基本设置
  18. * Class Setting
  19. * @package app\store\controller\client\h5
  20. */
  21. class Setting extends Controller
  22. {
  23. /**
  24. * 获取H5端设置 (指定)
  25. * @param string $key
  26. * @return Json
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\DbException
  29. * @throws \think\db\exception\ModelNotFoundException
  30. */
  31. public function detail(string $key): Json
  32. {
  33. $detail = SettingModel::getItem($key);
  34. return $this->renderSuccess(compact('detail'));
  35. }
  36. /**
  37. * 更新设置项
  38. * @param string $key
  39. * @return Json
  40. */
  41. public function update(string $key): Json
  42. {
  43. $model = new SettingModel;
  44. if ($model->edit($key, $this->postForm())) {
  45. return $this->renderSuccess('更新成功');
  46. }
  47. return $this->renderError($model->getError() ?: '更新失败');
  48. }
  49. }