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.
 
 

39 lines
1.1 KiB

<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\CollectStoreServiceInterface;
class CollectStoreController extends BaseController
{
/**
* @Inject
* @var CollectStoreServiceInterface
*/
protected $collectStoreService;
public function update()
{
$params = $this->request->all();
//判断是否已收藏店铺
$exists = $this->collectStoreService->check($params['user_id'],$params['store_id']);
//如果已收藏则删除
if($exists){
$this->collectStoreService->undo($params['user_id'],$params['store_id']);
}else{
$this->collectStoreService->do($params['user_id'],$params['store_id']);
}
$res = (bool) $this->collectStoreService->check($params['user_id'],$params['store_id']);
return $this->success(['is_collect' => $res]);
}
public function getListByUser()
{
$params = $this->request->all();
$res = $this->collectStoreService->getListByUser($params['user_id']);
return $this->success($res);
}
}