Просмотр исходного кода

新增 :通过CmpId删除器件关注记录

wangdy 8 лет назад
Родитель
Сommit
8b81cdb3cd

+ 13 - 0
src/main/java/com/uas/platform/b2c/trade/presale/controller/CollectionController.java

@@ -109,6 +109,19 @@ public class CollectionController {
 		return "success";
 	}
 
+	/**
+	 * 批量删除指定的收藏信息 通过器件id
+	 *
+	 * @param ids 删除的ids
+	 * @return String
+	 */
+	@RequestMapping(value = "/delete/cmpId", method = RequestMethod.POST)
+	@ApiOperation(value = "批量删除指定的收藏信息", httpMethod = "POST")
+	public String deleteByCmpIds(@ApiParam(required = true, value = "id集合") @RequestBody List<Long> ids) {
+		collectionService.deleteByCmpIds(ids);
+		return "success";
+	}
+
 	/**
 	 * 清空收藏的信息
 	 *

+ 7 - 0
src/main/java/com/uas/platform/b2c/trade/presale/service/CollectionService.java

@@ -29,6 +29,13 @@ public interface CollectionService {
 	 */
 	String deleteByIds(List<Long> ids);
 
+	/**
+	 * 批量删除收藏信息 通过器件id
+	 * @param ids 删除的收藏ids
+	 * @return String 返回success
+	 */
+	String deleteByCmpIds(List<Long> ids);
+
 	/**
 	 * 2016年3月23日 下午3:29:14
 	 * 清空类型 清空收藏夹

+ 17 - 0
src/main/java/com/uas/platform/b2c/trade/presale/service/impl/CollectionServiceImpl.java

@@ -54,6 +54,23 @@ public class CollectionServiceImpl implements CollectionService {
 		return "success";
 	}
 
+	@Override
+	public String deleteByCmpIds(List<Long> ids) {
+		Iterator<Long> it = ids.iterator();
+		int count = 0;
+		while (it.hasNext()) {
+			Long id = (Long) it.next();
+			List<Collection> c = collectionDao.findStoreByUseruuAndEnuuAndKindAndComponentid(SystemSession.getUser().getUserUU(),
+					SystemSession.getUser().getEnterprise().getUu(),2,id);
+			if (c.size()>0){
+				collectionDao.delete(c.get(0).getId());
+				count++;
+			}
+		}
+		System.out.println("删除的条数" + count);
+		return "success";
+	}
+
 	@Override
 	public String clear(int kind) {
 		int count = collectionDao.deleteByuseruuAndKindAndEnuu(SystemSession.getUser().getUserUU(), kind,