package cn.cslg.pas.mapper; import cn.cslg.pas.common.model.vo.StructureVO; import cn.cslg.pas.domain.Structure; 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.List; /** * 架构表的Mapper层接口测试类 * * @Author chenyu * @Date 2023/3/10 */ @Slf4j @SpringBootTest public class StructureMapperTests { @Autowired private StructureMapper structureMapper; @Test void insert() { Structure structure = new Structure() .setParentId(1) .setPath("0,1,3") .setStructureName("手机背板") .setRemark("手机的二级架构") .setProductId(2); int rows = structureMapper.insert(structure); log.info("插入数据完成,受影响的行数为:{}", rows); } @Test void delete() { int rows = structureMapper.deleteById(0); log.info("根据id删除数据完成,受影响的行数为:{}", rows); } @Test void update() { Structure structure = new Structure() .setParentId(0) .setPath("0,1") .setStructureName("手机") .setRemark("手机的一级架构呀") .setProductId(2); int rows = structureMapper.update(structure); log.info("修改数据完成,受影响的行数为:{}", rows); } @Test void countByparentIdAndStructureName() { int count = structureMapper.countByparentIdAndStructureName(0, "手机后壳"); log.info("根据名称统计数量完成,数量为:{}", count); } @Test void getStandardById() { Structure structure = structureMapper.getStandardById(3); log.info("根据id查询数据完成,数据信息为:{}", structure); } @Test void selectByParentId() { List structureVOs = structureMapper.selectByParentId(3); log.info("根据父级id查询子级架构完成,数据信息为:"); for (StructureVO structureVO : structureVOs) { log.info("{}", structureVO); } } @Test void selectByProductId() { List structureVOs = structureMapper.selectByProductId(22); log.info("根据产品id查询数据完成,数据信息为:"); for (StructureVO structureVO : structureVOs) { log.info("{}", structureVO); } } }