StoreProductReply.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\merchant\store;
  12. use app\common\repositories\store\product\ProductReplyRepository;
  13. use crmeb\basic\BaseController;
  14. use think\App;
  15. /**
  16. * StoreProductReply控制器
  17. * Class StoreProductReply
  18. * @package app\controller\store
  19. */
  20. class StoreProductReply extends BaseController
  21. {
  22. protected $repository;
  23. /**
  24. * 构造函数
  25. *
  26. * @param App $app 应用实例
  27. * @param ProductReplyRepository $replyRepository 商品回复仓库实例
  28. */
  29. public function __construct(App $app, ProductReplyRepository $replyRepository)
  30. {
  31. // 调用父类构造函数
  32. parent::__construct($app);
  33. // 设置商品回复仓库实例
  34. $this->repository = $replyRepository;
  35. }
  36. /**
  37. * 修改商品回复排序
  38. *
  39. * @param int $id 商品回复ID
  40. * @return mixed
  41. */
  42. public function changeSort($id)
  43. {
  44. // 获取商家ID
  45. $merId = $this->request->merId();
  46. // 判断商品回复是否存在
  47. if (!$this->repository->merExists($merId, $id))
  48. return app('json')->fail('数据不存在');
  49. // 获取排序值
  50. $sort = (int)$this->request->param('sort');
  51. // 更新商品回复排序
  52. $this->repository->update($id, compact('sort'));
  53. // 返回操作结果
  54. return app('json')->success('修改成功');
  55. }
  56. }