You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0 KiB

5 years ago
  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Controller\BaseController;
  4. use Hyperf\Di\Annotation\Inject;
  5. use App\Service\v3\Interfaces\CollectStoreServiceInterface;
  6. class CollectStoreController extends BaseController
  7. {
  8. /**
  9. * @Inject
  10. * @var CollectStoreServiceInterface
  11. */
  12. protected $collectStoreService;
  13. public function update()
  14. {
  15. $params = $this->request->all();
  16. //判断是否已收藏店铺
  17. $exists = $this->collectStoreService->check($params['user_id'],$params['store_id']);
  18. //如果已收藏则删除
  19. if($exists){
  20. $res = $this->collectStoreService->undo($params['user_id'],$params['store_id']);
  21. }else{
  22. $res = $this->collectStoreService->do($params['user_id'],$params['store_id']);
  23. }
  24. return $this->success($res);
  25. }
  26. public function getListByUser()
  27. {
  28. $params = $this->request->all();
  29. $res = $this->collectStoreService->getListByUser($params['user_id']);
  30. return $this->success($res);
  31. }
  32. }