@RestController@RequestMapping("/person")publicclassPersonController{
@Autowiredprivate PersonService personService;@GetMapping("/getPersonInfo")public String getPersonInfo( Long tel ){
Person person = personService.getPersonInfo(tel);return person.toString();}}
Person
publicclassPerson{
private Integer id;private String name;private Long tel;private Integer age;public Integer getId(){
return id;}publicvoidsetId( Integer id ){
this.id = id;}public String getName(){
return name;}publicvoidsetName( String name ){
this.name = name;}public Long getTel(){
return tel;}publicvoidsetTel( Long tel ){
this.tel = tel;}public Integer getAge(){
return age;}publicvoidsetAge( Integer age ){
this.age = age;}@Overridepublic String toString(){
return"Person{"+"id="+ id +", name='"+ name +'\''+", tel="+ tel +", age="+ age +'}';}}
PersonMapper
@ComponentpublicinterfacePersonMapper{
@Select("select * from person where tel = #{tel}")
Person getPersonInfo( Long tel );}
PersonServiceImpl
@ServicepublicclassPersonServiceImplimplementsPersonService{
@Autowiredprivate PersonMapper personMapper;public Person getPersonInfo( Long tel ){
Person person = personMapper.getPersonInfo(tel);return person;}}
PersonService
publicinterfacePersonService{
Person getPersonInfo( Long tel );}