|
|
@ -855,7 +855,7 @@ public class IndexApiServiceImpl implements IndexApiService { |
|
|
|
return Result.OK("我的收藏列表", pageList); |
|
|
|
} |
|
|
|
|
|
|
|
//新增收藏 |
|
|
|
//新增/取消收藏 |
|
|
|
public Result<?> addCollection(String token, TravelCollection travelCollection) { |
|
|
|
HanHaiMember hanHaiMember = shiroRealm.checkUserTokenIsEffectHanHaiOpenId(token); |
|
|
|
travelCollection.setUserId(hanHaiMember.getId()); |
|
|
@ -865,13 +865,21 @@ public class IndexApiServiceImpl implements IndexApiService { |
|
|
|
.eq(TravelCollection::getUserId, hanHaiMember.getId()) |
|
|
|
.list(); |
|
|
|
|
|
|
|
//如果收藏已存在,再次点击则取消收藏 |
|
|
|
String itemId = travelCollection.getItemId(); |
|
|
|
for (TravelCollection collection : list) { |
|
|
|
if(itemId.equals(collection.getItemId())){ |
|
|
|
return Result.OK("该收藏已存在"); |
|
|
|
Boolean flag = travelCollectionService.removeById(collection.getId()); |
|
|
|
if(flag){ |
|
|
|
return Result.OK("取消收藏成功!"); |
|
|
|
}else { |
|
|
|
return Result.OK("取消收藏失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean flag = travelCollectionService.save(travelCollection); |
|
|
|
if(flag){ |
|
|
|
return Result.OK("收藏成功!"); |
|
|
@ -1390,7 +1398,7 @@ public class IndexApiServiceImpl implements IndexApiService { |
|
|
|
int listCount = shopcarApiBeanList.size(); |
|
|
|
if(listCount < 1){ |
|
|
|
//没有数据 |
|
|
|
Result.OK("购物车列表没有数据,请先去添加购物车!", pageList); |
|
|
|
return Result.OK("购物车列表没有数据,请先去添加购物车!", pageList); |
|
|
|
} |
|
|
|
//总页数 |
|
|
|
int pageCount = listCount%pageSize==0?listCount/pageSize:listCount/pageSize+1; |
|
|
|