Store.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2025 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 think\response\Json;
  14. use app\store\model\Store as StoreModel;
  15. /**
  16. * 商家中心控制器
  17. * Class Store
  18. * @package app\store\controller
  19. */
  20. class Store extends Controller
  21. {
  22. /**
  23. * 获取当前登录的商城信息
  24. * @return Json
  25. * @throws \think\db\exception\DataNotFoundException
  26. * @throws \think\db\exception\DbException
  27. * @throws \think\db\exception\ModelNotFoundException
  28. */
  29. public function info(): Json
  30. {
  31. // 商城详情
  32. $model = StoreModel::detail($this->storeId);
  33. return $this->renderSuccess(['storeInfo' => $model]);
  34. }
  35. /**
  36. * 更新商城信息
  37. * @return Json
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function update(): Json
  43. {
  44. // 商城详情
  45. $model = StoreModel::detail($this->storeId);
  46. // 更新记录
  47. if (!$model->edit($this->postForm())) {
  48. return $this->renderError($model->getError() ?: '更新失败');
  49. }
  50. return $this->renderSuccess('更新成功');
  51. }
  52. }