package com.ningdatech.pmapi.region;

import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.sys.model.entity.Region;
import com.ningdatech.pmapi.sys.service.IRegionService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Classname RegionTest
 * @Description
 * @Date 2023/6/8 14:44
 * @Author PoffyZhang
 */
public class RegionTest extends AppTests {

    @Autowired
    private IRegionService regionService;

    @Test
    public void test(){
        Set<Region> set = regionService.list().stream().collect(Collectors.toSet());

        Set<Long> ids = set.stream().map(Region::getId).collect(Collectors.toSet());

        regionService.removeByIds(ids);

        regionService.saveBatch(set);
    }

}
