Commit da7dcd0c authored by xuxinpc's avatar xuxinpc

收藏夹相关接口 移除校验

parent 5d86aa5a
......@@ -9,7 +9,6 @@ import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -44,10 +43,10 @@ public class TempController {
* 店铺收藏夹
*/
@GetMapping("/favorites/{shopId}")
public ResultDto getFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId) {
public ResultDto getFavoritesByShopId(@PathVariable("shopId") String shopId) {
ResultDto resultDto = new ResultDto();
try {
List<FavoriteUrl> list = shopService.getFavoritesByShopId(principal.getName(), shopId);
List<FavoriteUrl> list = shopService.getFavoritesByShopId(shopId);
resultDto.setData(list);
resultDto.setStatus(0);
} catch (ClientRequestException e) {
......@@ -60,10 +59,10 @@ public class TempController {
* 店铺收藏夹 删除收藏
*/
@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();
try {
resultDto.setData(shopService.deleteFavoritesByShopId(principal.getName(), shopId, favoriteUrl));
resultDto.setData(shopService.deleteFavoritesByShopId(shopId, favoriteUrl));
resultDto.setStatus(0);
} catch (ClientRequestException e) {
dealClientRequestException(resultDto, e);
......@@ -75,10 +74,10 @@ public class TempController {
* 店铺收藏夹 新增收藏
*/
@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();
try {
resultDto.setData(shopService.saveFavoritesByShopId(principal.getName(), shopId, favoriteUrl));
resultDto.setData(shopService.saveFavoritesByShopId(shopId, favoriteUrl));
resultDto.setStatus(0);
} catch (ClientRequestException e) {
dealClientRequestException(resultDto, e);
......
......@@ -685,31 +685,18 @@ public class ShopServiceImpl implements ShopService {
}
@Override
public List<FavoriteUrl> getFavoritesByShopId(String name, String shopId) {
UserShop userShop = userShopRepository.findByUsernameAndShopId(name, shopId);
if (userShop == null) {
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
}
public List<FavoriteUrl> getFavoritesByShopId(String shopId) {
Shop shop = shopRepository.findById(shopId).orElseThrow(() -> new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST));
return shop.getFavoritesUrls();
}
@Override
public boolean saveFavoritesByShopId(String name, String shopId, FavoriteUrl favoriteUrl) {
UserShop userShop = userShopRepository.findByUsernameAndShopId(name, shopId);
if (userShop == null) {
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
}
public boolean saveFavoritesByShopId(String shopId, FavoriteUrl favoriteUrl) {
return shopRepository.saveFavoritesUrls(shopId, favoriteUrl);
}
@Override
public boolean deleteFavoritesByShopId(String name, String shopId, FavoriteUrl favoriteUrl) {
UserShop userShop = userShopRepository.findByUsernameAndShopId(name, shopId);
if (userShop == null) {
throw new ClientRequestException(BrowserErrorCode.SHOPNOTEXIST);
}
public boolean deleteFavoritesByShopId(String shopId, FavoriteUrl favoriteUrl) {
return shopRepository.deleteFavoritesByShopId(shopId, favoriteUrl);
}
......
......@@ -40,9 +40,9 @@ public interface ShopService {
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