From 57b80e02ce56e3cacff75ba789fc633ab46b911a Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 04 十二月 2018 15:22:25 +0800
Subject: [PATCH] 去除老版本收藏

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java
index ddf93c9..1baa5dd 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CollectionGoodsV2ServiceImpl.java
@@ -62,7 +62,27 @@
 		collectionGoodsV2Mapper.insertSelective(collectionGoodsV2);
 	}
 
-	
+	@Override
+	public void addCollection(CollectionGoodsV2 goods) throws CollectionGoodsException {
+		if (goods.getUserInfo() == null || goods.getCommonGoods() == null)
+			throw new CollectionGoodsException(1, "鏁版嵁涓嶅畬鏁�");
+		try {
+			CommonGoods commonGoods = commonGoodsService.addOrUpdateCommonGoods(goods.getCommonGoods());
+			goods.setCommonGoods(commonGoods);
+		} catch (CommonGoodsException e) {
+			goods.setCommonGoods(null);
+		}
+
+		if (goods.getCommonGoods() == null)
+			throw new CollectionGoodsException(3, "鍟嗗搧淇℃伅娣诲姞澶辫触");
+
+		CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Mapper
+				.selectByUidAndCommonGoodsId(goods.getUserInfo().getId(), goods.getCommonGoods().getId());
+		if (collectionGoodsV2 != null)
+			throw new CollectionGoodsException(4, "鍟嗗搧宸茶鏀惰棌");
+		collectionGoodsV2Mapper.insertSelective(goods);
+	}
+
 	@Transactional
 	@Override
 	public void cancelCollection(Long uid, Long id) throws CollectionGoodsException {
@@ -82,12 +102,33 @@
 
 	@Override
 	public List<CollectionGoodsV2> getCollectionGoodsList(Long uid, int page, int pageSize) {
-		return null;
+		return collectionGoodsV2Mapper.selectByUidOrderByCreateTimeDesc(uid, (page - 1) * pageSize, pageSize);
 	}
 
 	@Override
 	public long getCollectionGoodsCount(Long uid) {
-		return 0;
+		return collectionGoodsV2Mapper.selectCountByUid(uid);
+	}
+
+	@Override
+	public void cancelCollectionByAuctionId(Long uid, Long auctionId) throws CollectionGoodsException {
+		CollectionGoodsV2 goodsV2 = collectionGoodsV2Mapper.selectByUidAndGoodsTypeAndGoodsId(uid,
+				CommonGoods.GOODS_TYPE_TB, auctionId);
+		if (goodsV2 == null)
+			throw new CollectionGoodsException(1, "鏃犳敹钘�");
+		collectionGoodsV2Mapper.deleteByPrimaryKey(goodsV2.getId());
+	}
+
+	@Override
+	public void cancelCollectionByUid(Long uid) throws CollectionGoodsException {
+		collectionGoodsV2Mapper.deleteByUid(uid);
+	}
+
+	@Override
+	public CollectionGoodsV2 findByUidAndAuctionId(Long uid, Long actionId) {
+		CollectionGoodsV2 v2 = collectionGoodsV2Mapper.selectByUidAndGoodsTypeAndGoodsId(uid, CommonGoods.GOODS_TYPE_TB,
+				actionId);
+		return v2;
 	}
 
 }

--
Gitblit v1.8.0