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.

38 lines
1.1 KiB

5 years ago
5 years ago
5 years ago
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. $this->collectStoreService->undo($params['user_id'],$params['store_id']);
  21. }else{
  22. $this->collectStoreService->do($params['user_id'],$params['store_id']);
  23. }
  24. $res = $this->collectStoreService->check($params['user_id'],$params['store_id']);
  25. return $this->success($res);
  26. }
  27. public function getListByUser()
  28. {
  29. $params = $this->request->all();
  30. $res = $this->collectStoreService->getListByUser($params['user_id']);
  31. return $this->success($res);
  32. }
  33. }