File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/main/java/tk/mybatis/springboot/service Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 27
27
import com .github .pagehelper .PageHelper ;
28
28
import org .springframework .beans .factory .annotation .Autowired ;
29
29
import org .springframework .stereotype .Service ;
30
+ import tk .mybatis .mapper .entity .Example ;
30
31
import tk .mybatis .springboot .mapper .CountryMapper ;
31
32
import tk .mybatis .springboot .model .Country ;
32
33
@@ -46,7 +47,15 @@ public List<Country> getAll(Country country) {
46
47
if (country .getPage () != null && country .getRows () != null ) {
47
48
PageHelper .startPage (country .getPage (), country .getRows ());
48
49
}
49
- return countryMapper .selectAll ();
50
+ Example example = new Example (Country .class );
51
+ Example .Criteria criteria = example .createCriteria ();
52
+ if (country .getCountryname () != null && country .getCountryname ().length () > 0 ) {
53
+ criteria .andLike ("countryname" , "%" + country .getCountryname () + "%" );
54
+ }
55
+ if (country .getCountrycode () != null && country .getCountrycode ().length () > 0 ) {
56
+ criteria .andLike ("countrycode" , "%" + country .getCountrycode () + "%" );
57
+ }
58
+ return countryMapper .selectByExample (example );
50
59
}
51
60
52
61
public Country getById (Integer id ) {
You can’t perform that action at this time.
0 commit comments