ExploreSet.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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;
  13. use app\store\model\ExploreSet as SettingModel;
  14. /**
  15. * 探索/体验
  16. * Class Setting
  17. * @package app\store\controller
  18. */
  19. class ExploreSet extends Controller
  20. {
  21. /**
  22. * 探索、体验详情
  23. * @param string $key
  24. * @return array
  25. * @throws \think\db\exception\DataNotFoundException
  26. * @throws \think\db\exception\DbException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. */
  29. public function detail(string $type)
  30. {
  31. $values = SettingModel::getItem($type);
  32. return $this->renderSuccess(compact('values'));
  33. }
  34. /**
  35. * 更新设置
  36. * @param string $key
  37. * @return array
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function update(string $type)
  43. {
  44. // 保存商城设置
  45. $model = new SettingModel;
  46. if ($model->edit($type, $this->postForm())) {
  47. return $this->renderSuccess('操作成功');
  48. }
  49. return $this->renderError($model->getError() ?: '操作失败');
  50. }
  51. }