最近项目用到TkMybatis,故将学习笔记记录
在Test层使用
@RunWith(SpringRunner.class)
@SpringBootTest
@MapperScan(basePackages = "com.onigiri.demo.mapper")
public class AdvertiseServiceTest {
@Autowired
private AdvertiseMapper advertiseMapper;
@Autowired
private AdvertiseService advertiseService;
@Test
public void test()throws Exception{
Example example = new Example(Advertise.class);
example.createCriteria()
// .andCondition("id=",1)
.andEqualTo("categoryId",1);
List<Advertise> adv= advertiseMapper.selectByExample(example);
System.out.println(adv.get(0).getUrl());
}
@Test
public void testService(){
Condition condition = new Condition(OrderGroup.class);
condition.createCriteria().andEqualTo("categoryId",1)
List<Advertise> adv= advertiseService.selectByCondition (condition);
System.out.println(adv.get(0).getUrl());
}
}