package com.izouma.dingdong.contorller;

import com.izouma.dingdong.domain.OrderGoodsSpec;
import com.izouma.dingdong.domain.merchant.GoodsSpecification;
import com.izouma.dingdong.repo.OrderGoodsSpecRepo;
import com.izouma.dingdong.repo.merchant.GoodsSpecificationRepo;
import com.izouma.dingdong.service.OrderGoodsSpecService;
import com.izouma.dingdong.web.merchant.GoodsSpecificationController;
import org.junit.Test;
import org.junit.runner.RunWith;
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;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SpecControllerTest {
    @Autowired
    private GoodsSpecificationController controller;

    @Autowired
    private GoodsSpecificationRepo repo;

    @Autowired
    private OrderGoodsSpecService orderGoodsSpecService;

//    @Autowired
//    private OrderGoodsSpecRepo orderGoodsSpecRepo;

    @Test
    public void test(){
        GoodsSpecification build = GoodsSpecification.builder()
                .goodsId(698L)
                .name("全糖")
                .parent(703L)
                //.amount(BigDecimal.valueOf(12))
                //.multiple(false)
                .build();
        System.out.println(controller.save(build));
    }

    @Test
    public void testMy(){
        System.out.println(repo.findAllByGoodsIdAndParentIsNull(698L));
    }

    @Test
    public void testOrder(){
        //System.out.println(orderGoodsSpecRepo.findById(716L).orElse(null));
         System.out.println(orderGoodsSpecService.add(698L, "701,705", 1));
    }

}
