package com.izouma.nineth.service;

import com.izouma.nineth.ApplicationTests;
import com.izouma.nineth.domain.ShowCollection;
import com.izouma.nineth.domain.Showroom;
import com.izouma.nineth.dto.PageQuery;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public class ShowroomServiceTest extends ApplicationTests {

    @Autowired
    private ShowroomService showroomService;

    @Test
    public void save() {
        ShowCollection collection = ShowCollection.builder()
                .sort(1)
                .collectionId(207013L)
                .build();
        ShowCollection collection1 = ShowCollection.builder()
                .sort(1)
                .collectionId(206067L)
                .build();
        ShowCollection collection2 = ShowCollection.builder()
                .sort(1)
                .collectionId(207014L)
                .build();
        ShowCollection collection3 = ShowCollection.builder()
                .sort(1)
                .collectionId(207015L)
                .build();
        ShowCollection collection4 = ShowCollection.builder()
                .sort(1)
                .collectionId(207016L)
                .build();
        ShowCollection collection5 = ShowCollection.builder()
                .sort(1)
                .collectionId(207017L)
                .build();
        ShowCollection collection6 = ShowCollection.builder()
                .sort(1)
                .collectionId(207018L)
                .build();
        ShowCollection collection7 = ShowCollection.builder()
                .sort(1)
                .collectionId(207019L)
                .build();
        ShowCollection collection8 = ShowCollection.builder()
                .sort(1)
                .collectionId(207020L)
                .build();
        ShowCollection collection9 = ShowCollection.builder()
                .sort(1)
                .collectionId(207021L)
                .build();
        ShowCollection collection10 = ShowCollection.builder()
                .sort(1)
                .collectionId(207022L)
                .build();
        ShowCollection collection11 = ShowCollection.builder()
                .sort(1)
                .collectionId(207023L)
                .build();
        List<ShowCollection> collections = new ArrayList<>();
        collections.add(collection);
        collections.add(collection1);
        collections.add(collection2);
        collections.add(collection3);
        collections.add(collection4);
        collections.add(collection5);
        collections.add(collection6);
        collections.add(collection7);
        collections.add(collection8);
        collections.add(collection9);
//        collections.add(collection10);
//        collections.add(collection11);

        Showroom showroom = Showroom.builder()
                .assetId(207029L)
                .pic("https://cdn.raex.vip/image/2022-03-16-11-19-11fAEkRVkS.jpg")
                .collections(collections)
                .build();
        showroomService.save(9972L, showroom);
    }

    @Test
    public void update() {
        ShowCollection collection2 = ShowCollection.builder()
                .sort(1)
                .collectionId(207014L)
                .showroomId(207035L)
                .build();
        collection2.setId(207038L);

        ShowCollection collection3 = ShowCollection.builder()
                .sort(2)
                .collectionId(207015L)
                .build();
        collection3.setId(207039L);

        ShowCollection collection4 = ShowCollection.builder()
                .sort(3)
                .collectionId(207016L)
                .build();
        collection4.setId(207040L);

        ShowCollection collection5 = ShowCollection.builder()
                .sort(4)
                .collectionId(207017L)
                .build();
        collection5.setId(207041L);

        ShowCollection collection6 = ShowCollection.builder()
                .sort(5)
                .collectionId(207018L)
                .build();
        collection6.setId(207042L);

        ShowCollection collection7 = ShowCollection.builder()
                .sort(6)
                .collectionId(207019L)
                .build();
        collection7.setId(207043L);

        ShowCollection collection8 = ShowCollection.builder()
                .sort(7)
                .collectionId(207020L)
                .build();
        collection8.setId(207044L);

        ShowCollection collection9 = ShowCollection.builder()
                .sort(8)
                .collectionId(207021L)
                .build();
        collection9.setId(207045L);

        ShowCollection collection10 = ShowCollection.builder()
                .sort(9)
                .collectionId(207022L)
                .build();

        ShowCollection collection11 = ShowCollection.builder()
                .sort(10)
                .collectionId(206067L)
                .build();

        List<ShowCollection> collections = new ArrayList<>();
//        collections.add(collection2);
//        collections.add(collection3);
//        collections.add(collection4);
//        collections.add(collection5);
//        collections.add(collection6);
//        collections.add(collection7);
//        collections.add(collection8);
//        collections.add(collection9);
//        collections.add(collection10);
//        collections.add(collection11);

        Showroom showroom = Showroom.builder()
                .assetId(207029L)
                .pic("https://cdn.raex.vip/image/2022-03-16-11-19-11fAEkRVkS.jpg")
                .collections(collections)
                .introduction("这个一个展厅测试")
                .build();
        showroom.setId(207035L);
        showroomService.update(9972L, showroom);

    }

    @Test
    public void test() {
        PageQuery pageQuery = new PageQuery();
        Map<String, Object> query = pageQuery.getQuery();
        query.put("status", "SUCCESS");
        query.put("type", "COMPANY,COMPANY_BOX");
        query.put("publish", true);
        query.put("del", false);
        showroomService.show(pageQuery);
    }

    
}