本文主要是介绍Javaweb第五次作业,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
poet数据库sql语言
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,'北宋','文学家,书画家,诗神','清新豪健的诗风和独特的艺术表现力')
poet.java
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Poet {private Integer id;private String name;private Short gender;private String dynasty;private String title;private String style;
}
poetMapper
@SpringBootTest
class SpringbootMybatisCrudApplicationTests {//@Autowiredprivate EmpMapper empMapper;//@Testpublic void testDelete(){empMapper.delete(16);/* int delete=empMapper.delete(16);System.out.println(delete);*/}//@Testpublic 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()));}@Testpublic 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);}@Testpublic void testgetById(){Emp emp=empMapper.getById(18);System.out.println(emp);}@Testpublic void testList(){List<Emp> empList=empMapper.list("张",(short)1,LocalDate.of(2010,1,1),LocalDate.of(2020,1,1));System.out.println(empList);}@Autowiredprivate poetMapper poetmapper;@Testpublic void testInsert1(){Poet poet=new Poet();poet.setName("许");poet.setGender((short)2);poet.setDynasty("现代");poet.setTitle("学生");poet.setStyle("无");poetmapper.insert(poet);}@Testpublic void testdelete1(){poetmapper.delete(7);}@Testpublic void testupdate(){//String name,Short gender,String dynasty,String title,String stylePoet poet=new Poet();poet.setId(8);poet.setName("许111");poet.setGender((short)2);poet.setDynasty("现代1");poet.setTitle("学生");poet.setStyle("无");poetmapper.update(poet);}@Testpublic void test(){Poet poet= poetmapper.getById(1);System.out.println(poet);}
}
test
@Autowiredprivate poetMapper poetmapper;@Testpublic void testInsert1(){Poet poet=new Poet();poet.setName("许");poet.setGender((short)2);poet.setDynasty("现代");poet.setTitle("学生");poet.setStyle("无");poetmapper.insert(poet);}@Testpublic void testdelete1(){poetmapper.delete(7);}@Testpublic void testupdate(){//String name,Short gender,String dynasty,String title,String stylePoet poet=new Poet();poet.setId(8);poet.setName("许111");poet.setGender((short)2);poet.setDynasty("现代1");poet.setTitle("学生");poet.setStyle("无");poetmapper.update(poet);}@Testpublic void test(){Poet poet= poetmapper.getById(1);System.out.println(poet);}
这篇关于Javaweb第五次作业的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!