Commit 6c09e200 authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

Staging

See merge request !178
parents a575b78a d3b6e6d7
......@@ -63,7 +63,7 @@ public class TempController {
public ResultDto deleteFavoritesByShopId(@RequestBody FavoriteUrlDto favoriteUrlDto) {
ResultDto resultDto = new ResultDto();
try {
FavoriteUrl favoriteUrl = new FavoriteUrl(favoriteUrlDto.getTitle(),favoriteUrlDto.getUrl());
FavoriteUrl favoriteUrl = new FavoriteUrl("",favoriteUrlDto.getUrl());
resultDto.setData(shopService.deleteFavoritesByShopId(favoriteUrlDto.getShopId(), favoriteUrl));
resultDto.setStatus(0);
} catch (ClientRequestException e) {
......
......@@ -7,6 +7,8 @@ import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import static org.springframework.data.mongodb.core.query.Criteria.where;
......@@ -33,7 +35,7 @@ public class ShopRepositoryCustomImpl implements ShopRepositoryCustom {
BasicQuery basicQuery = new BasicQuery(doc);
basicQuery.addCriteria(where("_id").is(shopId));
Update update = new Update();
update.pull("favoritesUrls", favoriteUrl);
update.pull("favoritesUrls", Query.query(Criteria.where("url").is(favoriteUrl.getUrl())));
UpdateResult result = mongoTemplate.updateFirst(basicQuery, update, Shop.class);
return result.getModifiedCount() >= 1;
}
......
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