package cn.cslg.report.mapper;

import cn.cslg.report.common.model.vo.AvoidFeaturesVO;
import cn.cslg.report.entity.AvoidDesignLittleDirection;
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;
import java.util.List;

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

    @Autowired
    private AvoidDesignLittleDirectionMapper avoidDesignLittleDirectionMapper;

    @Test
    void insertBatch() {
        ArrayList<AvoidDesignLittleDirection> avoidDesignLittleDirections = new ArrayList<>();
        log.info("批量插入前数据为：");
        for (int i = 0; i < 5; i++) {
            AvoidDesignLittleDirection avoidDesignLittleDirection = new AvoidDesignLittleDirection()
                    .setReportId(330)
                    .setFeatureId(i + 1)
                    .setLittleDirection("回避设计方向" + (i + 1));
            log.info("{}", avoidDesignLittleDirection);
            avoidDesignLittleDirections.add(avoidDesignLittleDirection);
        }
        int rows = avoidDesignLittleDirectionMapper.insertBatch(avoidDesignLittleDirections);
        log.info("批量插入数据完成，受影响的行数为：{}", rows);
        log.info("批量插入前数据为：");
        for (AvoidDesignLittleDirection avoidDesignLittleDirection : avoidDesignLittleDirections) {
            log.info("{}", avoidDesignLittleDirection);
        }
    }

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

    @Test
    void selectSignPatentNoByReportId() {
        Integer reportId = 572;
        String signPatentNo = avoidDesignLittleDirectionMapper.selectSignPatentNoByReportId(reportId);
        log.info("根据报告id查询专利号完成，查询到的数据为：{}", signPatentNo);
    }

    @Test
    void selectWholeByRightId() {
        Integer rightId = 1;
        Integer reportId = 543;
        List<AvoidFeaturesVO> queryResults = avoidDesignLittleDirectionMapper.selectWholeByRightIdAndReportId(rightId, reportId);
        log.info("查询数据完成，数据信息为：{}", queryResults);
    }

}
