create table poet(
id int unsigned primary key auto_increment comment 'ID',
name varchar(10) not null comment '姓名',
gender tinyint unsigned not null comment '性别, 说明: 1 男, 2 女',
dynasty varchar(10) not null comment'朝代',
title varchar(20) not null comment'头衔',
style varchar(50) not null comment'风格'
)comment'诗人';
insert into poet(id,name,gender,dynasty,title,style) values
(1,'陶渊明',1,'东晋末至南朝宋初期','诗人和辞赋家','古今隐逸诗人之宗'),
(2,'王维',1,'唐代','诗佛','空灵,寂静'),
(3,'李白',1,'唐代','诗仙','豪放飘逸的诗风和丰富的想象力'),
(4,'李商隐',2,'唐代','试坛鬼才','无'),
(5,'李清照',2,'宋代','女词人','婉约风格'),
(6,'杜甫',1,'唐代','诗圣','反映社会现实和人民疾苦'),
(7,'苏轼',1,'北宋','文学家,书画家,诗神','清新豪健的诗风和独特的艺术表现力')
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Poet {
private Integer id;
private String name;
private Short gender;
private String dynasty;
private String title;
private String style;
}
@SpringBootTest
class SpringbootMybatisCrudApplicationTests {
//@Autowired
private EmpMapper empMapper;
//@Test
public void testDelete(){
empMapper.delete(16);
/* int delete=empMapper.delete(16);
System.out.println(delete);*/
}
//@Test
public void testInsert(){
Emp emp=new Emp();
emp.setUsername("Tbom1");
emp.setName("汤姆");
emp.setImage("1.jpg");
emp.setGender((short)1);
emp.setJob((short)1);
emp.setEntrydate(LocalDate.of(2005,1,1));
emp.setCreateTime(LocalDateTime.now());
emp.setUpdateTime(LocalDateTime.now());
emp.setId(1);
empMapper.insert(emp);
System.out.println((emp.getId()));
}
@Test
public void testUpdate(){
Emp emp=new Emp();
emp.setId(18);
emp.setUsername("Tommmm");
emp.setName("汤");
emp.setImage("1.jpg");
emp.setGender((short)1);
emp.setJob((short)1);
emp.setEntrydate(LocalDate.of(2005,1,1));
emp.setCreateTime(LocalDateTime.now());
emp.setUpdateTime(LocalDateTime.now());
emp.setDeptId(1);
empMapper.update(emp);
}
@Test
public void testgetById(){
Emp emp=empMapper.getById(18);
System.out.println(emp);
}
@Test
public void testList(){
List<Emp> empList=empMapper.list("张",(short)1,LocalDate.of(2010,1,1),LocalDate.of(2020,1,1));
System.out.println(empList);
}
@Autowired
private poetMapper poetmapper;
@Test
public void testInsert1(){
Poet poet=new Poet();
poet.setName("许");
poet.setGender((short)2);
poet.setDynasty("现代");
poet.setTitle("学生");
poet.setStyle("无");
poetmapper.insert(poet);
}
@Test
public void testdelete1(){
poetmapper.delete(7);
}
@Test
public void testupdate(){
//String name,Short gender,String dynasty,String title,String style
Poet poet=new Poet();
poet.setId(8);
poet.setName("许111");
poet.setGender((short)2);
poet.setDynasty("现代1");
poet.setTitle("学生");
poet.setStyle("无");
poetmapper.update(poet);
}
@Test
public void test(){
Poet poet= poetmapper.getById(1);
System.out.println(poet);
}
}
@Autowired
private poetMapper poetmapper;
@Test
public void testInsert1(){
Poet poet=new Poet();
poet.setName("许");
poet.setGender((short)2);
poet.setDynasty("现代");
poet.setTitle("学生");
poet.setStyle("无");
poetmapper.insert(poet);
}
@Test
public void testdelete1(){
poetmapper.delete(7);
}
@Test
public void testupdate(){
//String name,Short gender,String dynasty,String title,String style
Poet poet=new Poet();
poet.setId(8);
poet.setName("许111");
poet.setGender((short)2);
poet.setDynasty("现代1");
poet.setTitle("学生");
poet.setStyle("无");
poetmapper.update(poet);
}
@Test
public void test(){
Poet poet= poetmapper.getById(1);
System.out.println(poet);
}