package cn.cslg.report.mapper;

import cn.cslg.report.entity.AssoAvoidDesignWholeLittleDirection;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;

/**
 * 回避设计总体方向和方向关联表的Mapper层接口测试类
 *
 * @Author chenyu
 * @Data 2023/2/2
 */
@Slf4j
@SpringBootTest
public class AssoAvoidDesignWholeLittleDirectionMapperTests {

    @Autowired
    private AssoAvoidDesignWholeLittleDirectionMapper assoAvoidDesignWholeLittleDirectionMapper;

    @Test
    void insertBatch() {
        ArrayList<AssoAvoidDesignWholeLittleDirection> assoAvoidDesignWholeLittleDirections = new ArrayList<>();
        log.info("批量插入前数据为：");
        for (int i = 0; i < 3; i++) {
            AssoAvoidDesignWholeLittleDirection assoAvoidDesignWholeLittleDirection = new AssoAvoidDesignWholeLittleDirection()
                    .setReportId(330)
                    .setAvoidDesignWholeDirectionId(1)
                    .setAvoidDesignLittleDirectionId(i + 1);
            log.info("{}", assoAvoidDesignWholeLittleDirection);
            assoAvoidDesignWholeLittleDirections.add(assoAvoidDesignWholeLittleDirection);
        }
        int rows = assoAvoidDesignWholeLittleDirectionMapper.insertBatch(assoAvoidDesignWholeLittleDirections);
        log.info("批量插入数据完成，受影响的行数为：{}", rows);
        log.info("批量插入后数据为：");
        for (AssoAvoidDesignWholeLittleDirection assoAvoidDesignWholeLittleDirection : assoAvoidDesignWholeLittleDirections) {
            log.info("{}", assoAvoidDesignWholeLittleDirection);
        }
    }

    @Test
    void deleteByReportId() {
        Integer reportId = 517;
        int rows = assoAvoidDesignWholeLittleDirectionMapper.deleteByReportId(reportId);
        log.info("根据报告id删除数据完成，受影响的行数为：{}", rows);
    }

}
