package com.benyun.core.service;

import com.benyun.core.entity.WdCount;
import com.benyun.core.entity.WdCountBody;
import com.benyun.core.entity.WdInfo;
import com.benyun.core.utils.HashUtil;
import com.github.pagehelper.PageInfo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;
import java.util.List;

@SpringBootTest
public class ChannelMapServiceImplTest {
    @Autowired
    ChannelMapService channelMapService;

    @Test
    public void areaProvinceTest() {
        List<String> channel = Arrays.asList("1", "2", "3", "4", "5", "0");
        String rankType = "province";
        String searchText = "";
        String[] addrCode = new String[]{"110000000000", "120000000000", "130000000000", "140000000000", "150000000000", "210000000000", "220000000000", "230000000000", "310000000000", "320000000000", "330000000000", "340000000000", "350000000000", "360000000000", "370000000000", "410000000000", "420000000000", "430000000000", "440000000000", "450000000000", "460000000000", "500000000000", "510000000000", "520000000000", "530000000000", "540000000000", "610000000000", "620000000000", "630000000000", "640000000000", "650000000000"};
        WdCount area = channelMapService.area(channel, rankType, searchText, addrCode);
        for (WdCountBody wdCountBody : area.getWdCountBodyList()) {
            System.out.println(wdCountBody);
        }
        System.out.println(area.getTotal());
    }

    //市
    @Test
    public void areaCityest() {
        List<String> channel = Arrays.asList("1", "2", "3", "4", "5", "0");
        String rankType = "city";
        String searchText = "蜜";
        String[] addrCode =  new String[]{"450000000000"}; //省码
        WdCount area = channelMapService.area(channel, rankType, searchText, addrCode);
        for (WdCountBody wdCountBody : area.getWdCountBodyList()) {
            System.out.println(wdCountBody);
        }
        System.out.println(area.getTotal());
    }

    //区
    @Test
    public void areaZoneTest() {
        List<String> channel = Arrays.asList("1", "2", "3", "4", "5", "0");
        String rankType = "zone";
        String searchText = "蜜";
        String[] addrCode = new String[]{"500000000000"}; //市码
        WdCount area = channelMapService.area(channel, rankType, searchText, addrCode);
        for (WdCountBody wdCountBody : area.getWdCountBodyList()) {
            System.out.println(wdCountBody);
        }
        System.out.println(area.getTotal());
    }

    @Test
    public void listProvinceTest(){
        String orderby = "collect_time";
        int pageNum = 1;
        int pageSize = 10;
        String[] channel = new String[]{"1", "2", "3", "4", "5", "0"};
        String[] addrCode = new String[]{"450000000000"};
        String rankType = "province";
        String searchText = "蜜";
        PageInfo<WdInfo> list = channelMapService.list(channel, rankType, searchText, orderby, addrCode, pageNum, pageSize);
        for (WdInfo originWdInfo : list.getList()) {
            System.out.println("originWdInfo = " + originWdInfo);
        }
    }

    @Test
    public void pointTest(){
        int pageNum = 1;
        int pageSize = 10;
        String[] channel = new String[]{"1", "2", "3", "4", "5", "0"};
        String[] addrCode = new String[]{"450202000000"}; //区码
        String searchText = "";
        PageInfo<WdInfo> list = channelMapService.point(channel, searchText,  addrCode, pageNum, pageSize);
        for (WdInfo originWdInfo : list.getList()) {
            System.out.println("originWdInfo = " + originWdInfo);
        }
    }

}
