package com.izouma.dingdong.service;

import com.izouma.dingdong.domain.merchant.Goods;
import com.izouma.dingdong.domain.merchant.GoodsSpecification;
import com.izouma.dingdong.domain.merchant.MerchantClassification;
import com.izouma.dingdong.dto.AppraisalMerDTO;
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.utils.SecurityUtils;
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.util.Comparator;
import java.util.HashMap;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class GoodsServiceTest {

    @Autowired
    private AppraisalService appraisalService;

    @Autowired
    private GoodsRepo goodsRepo;

    @Autowired
    private GoodsSpecificationRepo goodsSpecificationRepo;

    @Test
    public void testApp(){
        System.out.println(appraisalService.goodsAppraisals(214L));
    }

    @Test
    public void showGoods(){
        HashMap<String, Object> map = new HashMap<>();
        Goods goods = goodsRepo.findById(214L).orElseThrow(new BusinessException("无记录"));
        map.put("goods",goods);

        List<AppraisalMerDTO> appraisals = appraisalService.goodsAppraisals(214L);
        map.put("appraisal",appraisals);

        List<GoodsSpecification> specifications = goodsSpecificationRepo.findAllByGoodsId(214L);
        map.put("specification",specifications);

        System.out.println(map);
    }
}
