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

增加产品收藏和店铺关注获取总计数量的接口

yujia 7 лет назад
Родитель
Сommit
14419952ef

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

@@ -7,6 +7,7 @@ import com.uas.platform.b2c.prod.product.component.modal.ComponentInfo;
 import com.uas.platform.b2c.trade.presale.model.Collection;
 import com.uas.platform.b2c.trade.presale.model.CollectionInfo;
 import com.uas.platform.b2c.trade.presale.service.CollectionService;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.uas.platform.core.model.Type;
@@ -84,6 +85,17 @@ public class CollectionController {
 		return collectionService.getPageStore(info);
 	}
 
+	/**
+	 * 2016年3月24日 上午11:22:22 获取个人收藏器件个数
+	 *
+	 * @return  ResultMap 返回收藏数量
+	 */
+	@RequestMapping(value = "/count", method = RequestMethod.GET, params = "type=component")
+	@ApiOperation(value = "器件收藏数量", httpMethod = "GET")
+	public ResultMap getStoreCountByuseruuAndComponent() {
+		return collectionService.getStoreCountByuseruuAndComponent(Collection.kindType.COMPONENT.getCode());
+	}
+
 	/**
 	 * 删除指定的搜藏信息
 	 *

+ 12 - 0
src/main/java/com/uas/platform/b2c/trade/presale/controller/StoreFocusController.java

@@ -3,6 +3,7 @@ package com.uas.platform.b2c.trade.presale.controller;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.trade.presale.model.StoreFocus;
 import com.uas.platform.b2c.trade.presale.service.StoreFocusService;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.PageParams;
 import com.wordnik.swagger.annotations.ApiOperation;
@@ -50,6 +51,17 @@ public class StoreFocusController {
 		return storeFocusService.getByUseruuAndEnuu();
 	}
 
+	/**
+	 * 查询指定uu号下的店铺关注统计信息
+	 *
+	 * @return ResultMap
+	 */
+	@RequestMapping(value = "/count", method = RequestMethod.GET)
+	@ApiOperation(value = "查询指定uu号下的所有店铺关注记录", httpMethod = "GET")
+	public ResultMap getStoreFocusCountByUseruuAndEnuu() {
+		return storeFocusService.getStoreFocusCountByUseruuAndEnuu();
+	}
+
 	/**
 	 * 单个/批量删除店铺关注记录
 	 * 

+ 21 - 0
src/main/java/com/uas/platform/b2c/trade/presale/dao/CollectionDao.java

@@ -96,4 +96,25 @@ public interface CollectionDao extends JpaRepository<Collection, Long>, JpaSpeci
 	 * @return
 	 */
 	List<Collection> findStoreByUseruuAndDissociativeAndKindAndComponentid(Long useruu, Integer dissociative, int kind, Long componentid);
+
+	/**
+	 * 根据useruu,enuu, 获取指定类型的总计数量
+	 * @param useruu 个人uu
+	 * @param enuu 企业uu
+	 * @param kind 类型
+	 * @return
+	 */
+	@Query(value = "select count(*) from Collection c where c.useruu =:useruu and c.enuu =:enuu and c.kind =:kind")
+	Integer findStoreCountByUseruuAndEnuuAndKind(@Param("useruu") Long useruu, @Param("enuu") Long enuu, @Param("kind") int kind);
+
+
+	/**
+	 * 根据useruu,enuu, 获取指定类型的总计数量
+	 * @param useruu 个人uu
+	 * @param dissociative 企业uu
+	 * @param kind 类型
+	 * @return
+	 */
+	@Query(value = "select count(*) from Collection c where c.useruu =:useruu and c.dissociative =:dissociative and c.kind =:kind")
+	Integer findStoreCountByUseruuAndDissociativeAndKind(@Param("useruu") Long useruu, @Param("dissociative") Integer dissociative, @Param("kind") int kind);
 }

+ 41 - 1
src/main/java/com/uas/platform/b2c/trade/presale/dao/StoreFocusDao.java

@@ -3,7 +3,7 @@ package com.uas.platform.b2c.trade.presale.dao;
 import com.uas.platform.b2c.trade.presale.model.StoreFocus;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.mongodb.repository.Query;
+import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
@@ -25,6 +25,46 @@ public interface StoreFocusDao extends JpaSpecificationExecutor<StoreFocus>, Jpa
 	 */
 	List<StoreFocus> findStoreFocusByUseruuAndEnuu(Long useruu, Long enuu);
 
+	/**
+	 * 根据个人的uu号和enuu号查找所有记录
+	 *
+	 * @param useruu 个人uu
+	 * @param enuu 企业enuu
+	 * @return List<StoreFocus> 返回店铺关注列表
+	 */
+	@Query(value = "select s from StoreFocus s where s.useruu =:useruu and s.enuu =:enuu and s.dissociative =:dissociative")
+	List<StoreFocus> findStoreFocusByUseruuAndEnuuAndDissociative(@Param("useruu") Long useruu, @Param("enuu")Long enuu, @Param("dissociative")Integer dissociative);
+
+	/**
+	 * 根据个人的uu号和是否是游离类型查找所有记录
+	 *
+	 * @param useruu 个人uu
+	 *
+	 * @return List<StoreFocus> 返回店铺关注列表
+	 */
+	@Query(value = "select s from StoreFocus s where s.useruu =:useruu and s.dissociative =:dissociative")
+	List<StoreFocus> findStoreFocusByUseruuAndDissociative(@Param("useruu")Long useruu, @Param("dissociative")Integer dissociative);
+
+	/**
+	 * 根据个人的uu号和enuu号查找所有记录
+	 *
+	 * @param useruu 个人uu
+	 * @param dissociative dissociative 游离的信息
+	 * @return List<StoreFocus> 返回店铺关注列表
+	 */
+	@Query(value = "select count(s) from StoreFocus s where s.useruu =:useruu and s.dissociative =:dissociative")
+	Integer findStoreFocusCountByUseruuAndDissociative(@Param("useruu")Long useruu, @Param("dissociative")Integer dissociative);
+
+	/**
+	 * 根据个人的uu号和enuu号查找所有记录
+	 *
+	 * @param useruu 个人uu
+	 * @param enuu 企业enuu
+	 * @return List<StoreFocus> 返回店铺关注列表
+	 */
+	@Query(value = "select count(s) from StoreFocus s where s.useruu =:useruu and s.dissociative =:dissociative and s.enuu =:enuu")
+	Integer findStoreFocusCountByUseruuAndEnuuAndDissociative(@Param("useruu") Long useruu, @Param("enuu") Long enuu, @Param("dissociative") Integer dissociative);
+
 	/**
 	 * 根据个人的uu号、enuu号、storeid查找记录
 	 *

+ 36 - 0
src/main/java/com/uas/platform/b2c/trade/presale/model/Collection.java

@@ -81,6 +81,42 @@ public class Collection implements Serializable {
 	@Column(name = "store_dissociative")
 	private Integer dissociative;
 
+	/**
+	 * 收藏类型
+	 */
+	public enum  kindType {
+
+		BRAND(1, "品牌"),
+
+		COMPONENT(2, "器件");
+
+		private int code;
+		private String phrase;
+
+		kindType(int code, String phrase) {
+			this.code = code;
+			this.phrase = phrase;
+		}
+
+		public int getCode() {
+			return code;
+		}
+
+		public kindType setCode(int code) {
+			this.code = code;
+			return this;
+		}
+
+		public String getPhrase() {
+			return phrase;
+		}
+
+		public kindType setPhrase(String phrase) {
+			this.phrase = phrase;
+			return this;
+		}
+	}
+
 	public Long getId() {
 		return id;
 	}

+ 12 - 4
src/main/java/com/uas/platform/b2c/trade/presale/service/CollectionService.java

@@ -1,12 +1,12 @@
 package com.uas.platform.b2c.trade.presale.service;
 
-import java.util.List;
-
-import org.springframework.data.domain.Page;
-
 import com.uas.platform.b2c.trade.presale.model.Collection;
 import com.uas.platform.b2c.trade.presale.model.CollectionInfo;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
 
 /**
  * @author yujia
@@ -89,4 +89,12 @@ public interface CollectionService {
 	 * @return Page<Collection> 返回collection的分页对象
 	 */
 	Page<Collection> getPageStore(PageInfo info);
+
+	/**
+	 * 2016年3月24日 上午11:22:22 获取个人收藏器件个数
+	 *
+	 * @param kind  收藏的类型  1 代表品牌  2 代表器件
+	 * @return  ResultMap 返回收藏数量
+	 */
+	ResultMap getStoreCountByuseruuAndComponent(int kind);
 }

+ 11 - 4
src/main/java/com/uas/platform/b2c/trade/presale/service/StoreFocusService.java

@@ -1,11 +1,11 @@
 package com.uas.platform.b2c.trade.presale.service;
 
-import java.util.List;
-
-import org.springframework.data.domain.Page;
-
 import com.uas.platform.b2c.trade.presale.model.StoreFocus;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
+import org.springframework.data.domain.Page;
+
+import java.util.List;
 
 /**
  * @version 2017年8月3日09:08:12 hulh 添加注释
@@ -27,6 +27,13 @@ public interface StoreFocusService {
 	 */
 	List<StoreFocus> getByUseruuAndEnuu();
 
+	/**
+	 * 查询指定uu号下的店铺关注统计信息
+	 *
+	 * @return ResultMap
+	 */
+	ResultMap getStoreFocusCountByUseruuAndEnuu();
+
 	/**
 	 * 单个/批量删除店铺关注记录
 	 * 

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

@@ -1,11 +1,13 @@
 package com.uas.platform.b2c.trade.presale.service.impl;
 
+import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.trade.presale.dao.CollectionDao;
 import com.uas.platform.b2c.trade.presale.dao.CollectionInfoDao;
 import com.uas.platform.b2c.trade.presale.model.Collection;
 import com.uas.platform.b2c.trade.presale.model.CollectionInfo;
 import com.uas.platform.b2c.trade.presale.service.CollectionService;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.Type;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -170,4 +172,20 @@ public class CollectionServiceImpl implements CollectionService {
 		return collectionDao.findStoreByUseruuAndKind(useruu, kind);
 	}
 
+	/**
+	 * 2016年3月24日 上午11:22:22 获取个人收藏器件个数
+	 * @param kind 收藏的类型  1 代表品牌  2 代表器件
+	 * @return ResultMap 返回收藏数量
+	 */
+	@Override
+	public ResultMap getStoreCountByuseruuAndComponent(int kind) {
+		Integer count = 0;
+		User user = SystemSession.getUser();
+		if (SystemSession.getUser().getEnterprise() != null) {
+			count = collectionDao.findStoreCountByUseruuAndEnuuAndKind(user.getUserUU(), user.getEnterprise().getUu(), kind);
+		} else {
+			count = collectionDao.findStoreCountByUseruuAndDissociativeAndKind(user.getUserUU(), Type.PERSONAL.value(), kind);
+		}
+		return ResultMap.success(count);
+	}
 }

+ 27 - 3
src/main/java/com/uas/platform/b2c/trade/presale/service/impl/StoreFocusServiceImpl.java

@@ -1,9 +1,11 @@
 package com.uas.platform.b2c.trade.presale.service.impl;
 
+import com.uas.platform.b2c.common.account.model.User;
 import com.uas.platform.b2c.core.support.SystemSession;
 import com.uas.platform.b2c.trade.presale.dao.StoreFocusDao;
 import com.uas.platform.b2c.trade.presale.model.StoreFocus;
 import com.uas.platform.b2c.trade.presale.service.StoreFocusService;
+import com.uas.platform.b2c.trade.support.ResultMap;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.model.Type;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,9 +49,31 @@ public class StoreFocusServiceImpl implements StoreFocusService {
 
 	@Override
 	public List<StoreFocus> getByUseruuAndEnuu() {
-		List<StoreFocus> list = storeFocusDao.findStoreFocusByUseruuAndEnuu(SystemSession.getUser().getUserUU(),
-				SystemSession.getUser().getEnterprise().getUu());
-		return list;
+		List<StoreFocus> storeFocuses = null;
+		User user = SystemSession.getUser();
+		if (user.getEnterprise().getUu() != null) {
+			storeFocuses = storeFocusDao.findStoreFocusByUseruuAndEnuuAndDissociative(user.getUserUU(), user.getEnterprise().getUu(), Type.ENTERPRISING.value());
+		} else {
+			storeFocuses = storeFocusDao.findStoreFocusByUseruuAndDissociative(user.getUserUU(), Type.PERSONAL.value());
+		}
+		return storeFocuses;
+	}
+
+	/**
+	 * 查询指定uu号下的店铺关注统计信息
+	 *
+	 * @return ResultMap
+	 */
+	@Override
+	public ResultMap getStoreFocusCountByUseruuAndEnuu() {
+		Integer count = null;
+		User user = SystemSession.getUser();
+		if (user.getEnterprise() != null) {
+			count = storeFocusDao.findStoreFocusCountByUseruuAndEnuuAndDissociative(user.getUserUU(), user.getEnterprise().getUu(), Type.ENTERPRISING.value());
+		} else {
+			count = storeFocusDao.findStoreFocusCountByUseruuAndDissociative(user.getUserUU(), Type.PERSONAL.value());
+		}
+		return ResultMap.success(count);
 	}
 
 	@Override