|
|
@@ -8,6 +8,7 @@ import com.izouma.dingdong.exception.BusinessException;
|
|
|
import com.izouma.dingdong.repo.merchant.GoodsRepo;
|
|
|
import com.izouma.dingdong.repo.merchant.GoodsSpecificationRepo;
|
|
|
import com.izouma.dingdong.service.merchant.GoodsService;
|
|
|
+import com.izouma.dingdong.service.merchant.GoodsSpecificationService;
|
|
|
import com.izouma.dingdong.utils.SecurityUtils;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
@@ -15,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -32,6 +35,9 @@ public class GoodsServiceTest {
|
|
|
@Autowired
|
|
|
private GoodsSpecificationRepo goodsSpecificationRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GoodsSpecificationService goodsSpecificationService;
|
|
|
+
|
|
|
@Test
|
|
|
public void testApp(){
|
|
|
System.out.println(appraisalService.goodsAppraisals(214L));
|
|
|
@@ -51,4 +57,68 @@ public class GoodsServiceTest {
|
|
|
|
|
|
System.out.println(map);
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void goodsSpec(){
|
|
|
+/* GoodsSpecification spec1 = GoodsSpecification.builder()
|
|
|
+ .multiple(false)
|
|
|
+ .name("冰量")
|
|
|
+ .goodsId(121L)
|
|
|
+ .build();
|
|
|
+ spec1.setId(-1L);*/
|
|
|
+ GoodsSpecification spec2 = GoodsSpecification.builder()
|
|
|
+ .amount(BigDecimal.ZERO)
|
|
|
+ .name("正常冰")
|
|
|
+ .goodsId(121L)
|
|
|
+ .parent(1082L)
|
|
|
+ .build();
|
|
|
+ spec2.setId(-2L);
|
|
|
+/* GoodsSpecification spec3 = GoodsSpecification.builder()
|
|
|
+ .amount(BigDecimal.ZERO)
|
|
|
+ .name("少冰")
|
|
|
+ .goodsId(121L)
|
|
|
+ .parent(-1L)
|
|
|
+ .build();
|
|
|
+ spec3.setId(-3L);*/
|
|
|
+
|
|
|
+/* GoodsSpecification spec4 = GoodsSpecification.builder()
|
|
|
+ .multiple(false)
|
|
|
+ .name("酸度")
|
|
|
+ .goodsId(121L)
|
|
|
+ .build();
|
|
|
+ spec4.setId(-4L);*/
|
|
|
+ GoodsSpecification spec5 = GoodsSpecification.builder()
|
|
|
+ .amount(BigDecimal.ZERO)
|
|
|
+ .name("微酸")
|
|
|
+ .goodsId(121L)
|
|
|
+ .parent(1089L)
|
|
|
+ .build();
|
|
|
+ spec5.setId(-5L);
|
|
|
+/* GoodsSpecification spec6 = GoodsSpecification.builder()
|
|
|
+ .amount(BigDecimal.ZERO)
|
|
|
+ .name("半糖")
|
|
|
+ .goodsId(121L)
|
|
|
+ .parent(-4L)
|
|
|
+ .build();
|
|
|
+ spec6.setId(-6L);
|
|
|
+ GoodsSpecification spec7 = GoodsSpecification.builder()
|
|
|
+ .amount(BigDecimal.ZERO)
|
|
|
+ .name("全糖")
|
|
|
+ .goodsId(121L)
|
|
|
+ .parent(-4L)
|
|
|
+ .build();
|
|
|
+ spec7.setId(-7L);*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<GoodsSpecification> specifications = new ArrayList<>(2);
|
|
|
+// specifications.add(spec1);
|
|
|
+ specifications.add(spec2);
|
|
|
+// specifications.add(spec3);
|
|
|
+// specifications.add(spec4);
|
|
|
+ specifications.add(spec5);
|
|
|
+// specifications.add(spec6);
|
|
|
+// specifications.add(spec7);
|
|
|
+ goodsSpecificationService.saveAll(specifications);
|
|
|
+ }
|
|
|
}
|