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.
41 lines
1.2 KiB
41 lines
1.2 KiB
<?php
|
|
|
|
|
|
namespace App\Controller\v3;
|
|
use App\Controller\BaseController;
|
|
use App\Request\v3\UserAndStoreRequest;
|
|
use App\Request\v3\UserRequest;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use App\Service\v3\Interfaces\CollectStoreServiceInterface;
|
|
|
|
class CollectStoreController extends BaseController
|
|
{
|
|
|
|
/**
|
|
* @Inject
|
|
* @var CollectStoreServiceInterface
|
|
*/
|
|
protected $collectStoreService;
|
|
|
|
public function update(UserAndStoreRequest $request)
|
|
{
|
|
$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(UserRequest $request)
|
|
{
|
|
$params = $this->request->all();
|
|
$res = $this->collectStoreService->getListByUser($params['user_id']);
|
|
return $this->success($res);
|
|
}
|
|
}
|