Browse Source

调整收藏的接口,增加规格保存

yujia 7 years ago
parent
commit
d83f4ffb43

+ 16 - 1
src/main/java/com/uas/platform/b2c/trade/presale/model/Collection.java

@@ -84,9 +84,15 @@ public class Collection implements Serializable {
 	/**
 	/**
 	 * 规格信息
 	 * 规格信息
 	 */
 	 */
-	@Column(name = "store_spec")
+	@Column(name = "store_spec", columnDefinition = "TEXT")
 	private String spec;
 	private String spec;
 
 
+	/**
+	 * 器件的uuid
+	 */
+	@Column(name = "store_cmpuuid", length = 100)
+	private String cmpuuid;
+
 	/**
 	/**
 	 * 收藏类型
 	 * 收藏类型
 	 */
 	 */
@@ -211,4 +217,13 @@ public class Collection implements Serializable {
 		this.spec = spec;
 		this.spec = spec;
 		return this;
 		return this;
 	}
 	}
+
+	public String getCmpuuid() {
+		return cmpuuid;
+	}
+
+	public Collection setCmpuuid(String cmpuuid) {
+		this.cmpuuid = cmpuuid;
+		return this;
+	}
 }
 }

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

@@ -89,10 +89,18 @@ public class CollectionServiceImpl implements CollectionService {
 
 
 	@Override
 	@Override
 	public String save(Collection store, String cmpuuid) {
 	public String save(Collection store, String cmpuuid) {
-		if (!StringUtils.isEmpty(cmpuuid)) {
-			Component component = componentDao.findByUuid(cmpuuid);
+		if ((!StringUtils.isEmpty(cmpuuid)) || (store.getComponentid() != null)) {
+			Component component = null;
+			if(!StringUtils.isEmpty(cmpuuid)) {
+				component = componentDao.findByUuid(cmpuuid);
+			} else if (store.getComponentid() != null) {
+				component = componentDao.findOne(store.getComponentid());
+			}
+
 			if (component != null) {
 			if (component != null) {
 				store.setComponentid(component.getId());
 				store.setComponentid(component.getId());
+				store.setCmpuuid(cmpuuid);
+				store.setSpec(component.getDescription());
 			}
 			}
 		}
 		}
 		List<Collection> storeList = new ArrayList<Collection>();
 		List<Collection> storeList = new ArrayList<Collection>();