package com.izouma.zhirongip.service;

import com.izouma.zhirongip.ApplicationTests;
import com.izouma.zhirongip.domain.demand.CopyrightDemand;
import com.izouma.zhirongip.domain.demand.LogoDemand;
import com.izouma.zhirongip.domain.demand.PatentDemand;
import com.izouma.zhirongip.domain.demand.TechProductDemand;
import com.izouma.zhirongip.domain.supply.Copyright;
import com.izouma.zhirongip.domain.supply.Logo;
import com.izouma.zhirongip.domain.supply.Patent;
import com.izouma.zhirongip.domain.supply.TechnologyProduct;
import com.izouma.zhirongip.dto.SearchDTO;
import com.izouma.zhirongip.repo.demand.CopyrightDemandRepo;
import com.izouma.zhirongip.repo.demand.LogoDemandRepo;
import com.izouma.zhirongip.repo.demand.PatentDemandRepo;
import com.izouma.zhirongip.repo.demand.TechProductDemandRepo;
import com.izouma.zhirongip.repo.supply.CopyrightRepo;
import com.izouma.zhirongip.repo.supply.LogoRepo;
import com.izouma.zhirongip.repo.supply.PatentRepo;
import com.izouma.zhirongip.repo.supply.TechnologyProductRepo;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import java.util.List;


public class AllServiceTest extends ApplicationTests {

    @Autowired
    private AllService         allService;
    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private PatentDemandRepo patentDemandRepo;
    @Autowired
    private LogoDemandRepo logoDemandRepo;
    @Autowired
    private CopyrightDemandRepo copyrightDemandRepo;
    @Autowired
    private TechProductDemandRepo techProductDemandRepo;

    @Test
    public void search() {
        List<SearchDTO> search = allService.search("1");
        search.forEach(System.out::println);
    }

    @Test
    public void test() {
//        System.out.println(applicationContext.getBean("patentRepo"));
        PatentRepo patentRepo = applicationContext.getBean(PatentRepo.class);
        patentRepo.addView(237L);
    }

//    @Test
//    public void test2() {
//       List<PatentDemand> patents= patentDemandRepo.findAll();
//        patents.forEach(item ->{
//            Boolean flag=true;
//            if(item.getPatentType()!=null){
//                item.setPatentTypeId(item.getPatentType().getId());
//                flag=true;
//            }
//            if(item.getPatentStatus()!=null){
//                item.setPatentStatusId(item.getPatentStatus().getId());
//                flag=true;
//            }
//           if(flag){
//               patentDemandRepo.save(item);
//           }
//       });
//
//    }


}