Explorar o código

根据List<id>获取类目信息

zengchao %!s(int64=8) %!d(string=hai) anos
pai
achega
e363aa27eb

+ 10 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/api/KindController.java

@@ -195,4 +195,14 @@ public class KindController {
 		name = URLDecoder.decode(name, "utf-8");
 		name = URLDecoder.decode(name, "utf-8");
 		return  kindService.getKindInfoByName(name);
 		return  kindService.getKindInfoByName(name);
 	}
 	}
+
+	/**
+	 * 根据批次号获取类目信息
+	 * @param batchIds
+	 * @return 类目信息
+	 */
+	@RequestMapping(value = "/batchId", method = RequestMethod.POST, produces = "application/json")
+	public List<Kind> getBatchBrands(@RequestBody List<Long> batchIds) {
+		return kindService.getBatchKinds(batchIds);
+	}
 }
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/dao/KindDao.java

@@ -54,4 +54,12 @@ public interface KindDao extends JpaSpecificationExecutor<Kind>, JpaRepository<K
 	 * @return
 	 * @return
 	 */
 	 */
 	public List<Kind> findByNameCn(String nameCn);
 	public List<Kind> findByNameCn(String nameCn);
+
+	/**
+	* 根据批次号获取类目信息
+	* @param batchIds id批次号
+	* @return
+	*/
+	@Query(nativeQuery = true, value = "select * from product$kind where ki_id in :batchIds")
+	public List<Kind> findByBatchIds(@Param("batchIds") List<Long> batchIds);
 }
 }

+ 7 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/service/KindService.java

@@ -308,4 +308,11 @@ public interface KindService {
 	 * @return 类目信息
 	 * @return 类目信息
 	 */
 	 */
 	Kind getFirstKind(Long kindId);
 	Kind getFirstKind(Long kindId);
+
+	/**
+	 * 根据批次号获取类目信息
+	 * @param batchIds
+	 * @return 类目信息
+	 */
+	List<Kind> getBatchKinds(List<Long> batchIds);
 }
 }

+ 8 - 0
src/main/java/com/uas/platform/b2c/prod/product/kind/service/impl/KindServiceImpl.java

@@ -1201,4 +1201,12 @@ public class KindServiceImpl implements KindService {
 	Kind getParentByChildId(Kind child) {
 	Kind getParentByChildId(Kind child) {
 		return kindDao.findOne(child.getParentid());
 		return kindDao.findOne(child.getParentid());
 	}
 	}
+
+
+	public List<Kind> getBatchKinds(List<Long> batchIds) {
+		if (batchIds.size() == 0) {
+			return kindDao.findAll();
+		}
+		return kindDao.findByBatchIds(batchIds);
+	}
 }
 }