drop table if exists `student`; create table `student` ( `sno` int(11) not null auto_increment comment '学号', `sname` varchar(50) character set utf8 collate utf8_general_ci not null comment '姓名', `ssex` varchar(2) character set utf8 collate utf8_general_ci not null comment '性别', primary key (`sno`) using btree ) engine = innodb auto_increment = 1 character set = utf8 collate = utf8_general_ci row_format = dynamic;
insert into `student` values (1, 'KangKang', 'M'); insert into `student` values (2, 'Mike', 'M'); insert into `student` values (3, 'Jane', 'F');
@RestController public class TestController { @Autowired private StudentService studentService;
@RequestMapping( value = "/querystudent", method = RequestMethod.GET) public Student queryStudentBySno(int sno) { return this.studentService.queryStudentBySno(sno); }
@RequestMapping( value = "/addstudent", method = RequestMethod.GET) public int addstudent(Student student) { return this.studentService.add(student); }
@RequestMapping( value = "/queryallstudent", method = RequestMethod.GET) public List<Map<String, Object>> queryallstudent() { return this.studentService.queryStudentsListMap(); }
@RequestMapping( value = "/deletestudent", method = RequestMethod.GET) public int deletestudent(int sno) { return this.studentService.deleteBysno(sno); }