Commit da7dcd0c authored by xuxinpc's avatar xuxinpc

收藏夹相关接口 移除校验

parent 5d86aa5a
...@@ -9,7 +9,6 @@ import com.edgec.browserbackend.common.commons.error.ClientRequestException; ...@@ -9,7 +9,6 @@ import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -44,10 +43,10 @@ public class TempController { ...@@ -44,10 +43,10 @@ public class TempController {
* 店铺收藏夹 * 店铺收藏夹
*/ */
@GetMapping("/favorites/{shopId}") @GetMapping("/favorites/{shopId}")
public ResultDto getFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId) { public ResultDto getFavoritesByShopId(@PathVariable("shopId") String shopId) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
List<FavoriteUrl> list = shopService.getFavoritesByShopId(principal.getName(), shopId); List<FavoriteUrl> list = shopService.getFavoritesByShopId(shopId);
resultDto.setData(list); resultDto.setData(list);
resultDto.setStatus(0); resultDto.setStatus(0);
} catch (ClientRequestException e) { } catch (ClientRequestException e) {
...@@ -60,10 +59,10 @@ public class TempController { ...@@ -60,10 +59,10 @@ public class TempController {
* 店铺收藏夹 删除收藏 * 店铺收藏夹 删除收藏
*/ */
@DeleteMapping("/favorites/{shopId}") @DeleteMapping("/favorites/{shopId}")
public ResultDto deleteFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId, @RequestBody FavoriteUrl favoriteUrl) { public ResultDto deleteFavoritesByShopId(@PathVariable("shopId") String shopId, @RequestBody FavoriteUrl favoriteUrl) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
resultDto.setData(shopService.deleteFavoritesByShopId(principal.getName(), shopId, favoriteUrl)); resultDto.setData(shopService.deleteFavoritesByShopId(shopId, favoriteUrl));
resultDto.setStatus(0); resultDto.setStatus(0);
} catch (ClientRequestException e) { } catch (ClientRequestException e) {
dealClientRequestException(resultDto, e); dealClientRequestException(resultDto, e);
...@@ -75,10 +74,10 @@ public class TempController { ...@@ -75,10 +74,10 @@ public class TempController {
* 店铺收藏夹 新增收藏 * 店铺收藏夹 新增收藏
*/ */
@PostMapping("/favorites/{shopId}") @PostMapping("/favorites/{shopId}")
public ResultDto saveFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId, @RequestBody FavoriteUrl favoriteUrl) { public ResultDto saveFavoritesByShopId(@PathVariable("shopId") String shopId, @RequestBody FavoriteUrl favoriteUrl) {
ResultDto resultDto = new ResultDto(); ResultDto resultDto = new ResultDto();
try { try {
resultDto.setData(shopService.saveFavoritesByShopId(principal.getName(), shopId, favoriteUrl)); resultDto.setData(shopService.saveFavoritesByShopId(shopId, favoriteUrl));
resultDto.setStatus(0); resultDto.setStatus(0);
} catch (ClientRequestException e) { } catch (ClientRequestException e) {
dealClientRequestException(resultDto, e); dealClientRequestException(resultDto, e);
......
...@@ -685,31 +685,18 @@ public class ShopServiceImpl implements ShopService { ...@@ -685,31 +685,18 @@ public class ShopServiceImpl implements ShopService {
} }
@Override @Override
public List<FavoriteUrl> getFavoritesByShopId(String name, String shopId) { public List<FavoriteUrl> getFavoritesByShopId(String shopId) {
UserShop userShop = userShopRepository.findByUsernameAndShopId(name, shopId);
if (userShop == null) {
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
}
Shop shop = shopRepository.findById(shopId).orElseThrow(() -> new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST)); Shop shop = shopRepository.findById(shopId).orElseThrow(() -> new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST));
return shop.getFavoritesUrls(); return shop.getFavoritesUrls();
} }
@Override @Override
public boolean saveFavoritesByShopId(String name, String shopId, FavoriteUrl favoriteUrl) { public boolean saveFavoritesByShopId(String shopId, FavoriteUrl favoriteUrl) {
UserShop userShop = userShopRepository.findByUsernameAndShopId(name, shopId);
if (userShop == null) {
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
}
return shopRepository.saveFavoritesUrls(shopId, favoriteUrl); return shopRepository.saveFavoritesUrls(shopId, favoriteUrl);
} }
@Override @Override
public boolean deleteFavoritesByShopId(String name, String shopId, FavoriteUrl favoriteUrl) { public boolean deleteFavoritesByShopId(String shopId, FavoriteUrl favoriteUrl) {
UserShop userShop = userShopRepository.findByUsernameAndShopId(name, shopId);
if (userShop == null) {
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
}
return shopRepository.deleteFavoritesByShopId(shopId, favoriteUrl); return shopRepository.deleteFavoritesByShopId(shopId, favoriteUrl);
} }
......
...@@ -40,9 +40,9 @@ public interface ShopService { ...@@ -40,9 +40,9 @@ public interface ShopService {
Integer deleteShopCookieById(String id); Integer deleteShopCookieById(String id);
boolean saveFavoritesByShopId(String name, String shopId, FavoriteUrl favoriteUrl); boolean saveFavoritesByShopId(String shopId, FavoriteUrl favoriteUrl);
boolean deleteFavoritesByShopId(String name, String shopId, FavoriteUrl favoriteUrl); boolean deleteFavoritesByShopId(String shopId, FavoriteUrl favoriteUrl);
List<FavoriteUrl> getFavoritesByShopId(String name, String shopId); List<FavoriteUrl> getFavoritesByShopId(String shopId);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment