File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ dependencies {
1919 compile ' org.mybatis:mybatis-spring:2.0.0'
2020 compile ' org.springframework:spring-jdbc:5.1.5.RELEASE'
2121 compile ' mysql:mysql-connector-java:6.0.5'
22+ annotationProcessor " org.projectlombok:lombok:1.16.8"
2223}
Original file line number Diff line number Diff line change 33import cn .iwuliao .ds .service .HeloService ;
44import org .springframework .web .bind .annotation .PathVariable ;
55import org .springframework .web .bind .annotation .RequestMapping ;
6+ import org .springframework .web .bind .annotation .RequestParam ;
67import org .springframework .web .bind .annotation .RestController ;
78
9+ import java .util .List ;
10+
811/**
912 * @author tangyu
1013 * @since 2019-04-22 20:30
@@ -48,4 +51,10 @@ public String tx(@PathVariable("commit") String commit) {
4851 return "i am tx " ;
4952 }
5053
54+
55+ @ RequestMapping ("/like" )
56+ public List <String > like (@ RequestParam (name = "name" ) String name ) {
57+ return heloService .likeQry (name );
58+ }
59+
5160}
Original file line number Diff line number Diff line change 44import org .apache .ibatis .annotations .Param ;
55import org .apache .ibatis .annotations .Select ;
66
7+ import java .util .List ;
8+
79/**
810 * @author tangyu
911 * @since 2019-04-22 22:25
@@ -19,4 +21,7 @@ public interface AMapper {
1921 Integer insert (@ Param ("id" ) int id );
2022
2123
24+ List <String > likeQry (@ Param ("name" ) String name );
25+
26+
2227}
Original file line number Diff line number Diff line change 33import cn .iwuliao .ds .core .DsScannerConfigurer ;
44import org .springframework .transaction .annotation .Transactional ;
55
6+ import java .util .List ;
7+
68/**
79 * @author tangyu
810 * @since 2019-04-23 00:55
@@ -18,4 +20,6 @@ public interface HeloService {
1820 Integer rollback ();
1921
2022 Integer hib ();
23+
24+ List <String > likeQry (String name );
2125}
Original file line number Diff line number Diff line change 77import org .springframework .stereotype .Service ;
88import org .springframework .transaction .annotation .Transactional ;
99
10+ import java .util .List ;
11+
1012/**
1113 * @author tangyu
1214 * @since 2019-04-23 00:56
@@ -48,4 +50,9 @@ public Integer hib() {
4850 return id ;
4951 }
5052
53+ @ Override
54+ public List <String > likeQry (String name ) {
55+ return aMapper .likeQry (name );
56+ }
57+
5158}
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
33<mapper namespace =" cn.iwuliao.ds.mapper.dba.AMapper" >
4+
5+ <select id =" likeQry" resultType =" string" >
6+ SELECT name from a where name like
7+ <bind name =" pattern" value =" '%' + _parameter.name + '%'" />
8+ #{pattern}
9+ </select >
410</mapper >
You can’t perform that action at this time.
0 commit comments