File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
src/main/java/tk/mybatis/springboot Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ public class CountryController {
51
51
@ RequestMapping
52
52
public ModelAndView getAll (Country country ) {
53
53
ModelAndView result = new ModelAndView ("index" );
54
- List <Country > countryList = countryService .getAll (country );
54
+ List <Country > countryList = countryService .getAllByWeekend (country );
55
55
result .addObject ("pageInfo" , new PageInfo <Country >(countryList ));
56
56
result .addObject ("queryParam" , country );
57
57
result .addObject ("page" , country .getPage ());
Original file line number Diff line number Diff line change 28
28
import org .springframework .beans .factory .annotation .Autowired ;
29
29
import org .springframework .stereotype .Service ;
30
30
import tk .mybatis .mapper .entity .Example ;
31
+ import tk .mybatis .mapper .weekend .Weekend ;
32
+ import tk .mybatis .mapper .weekend .WeekendCriteria ;
31
33
import tk .mybatis .springboot .mapper .CountryMapper ;
32
34
import tk .mybatis .springboot .model .Country ;
33
35
@@ -58,6 +60,21 @@ public List<Country> getAll(Country country) {
58
60
return countryMapper .selectByExample (example );
59
61
}
60
62
63
+ public List <Country > getAllByWeekend (Country country ) {
64
+ if (country .getPage () != null && country .getRows () != null ) {
65
+ PageHelper .startPage (country .getPage (), country .getRows ());
66
+ }
67
+ Weekend <Country > weekend = Weekend .of (Country .class );
68
+ WeekendCriteria <Country , Object > criteria = weekend .weekendCriteria ();
69
+ if (country .getCountryname () != null && country .getCountryname ().length () > 0 ) {
70
+ criteria .andLike (Country ::getCountryname , "%" + country .getCountryname () + "%" );
71
+ }
72
+ if (country .getCountrycode () != null && country .getCountrycode ().length () > 0 ) {
73
+ criteria .andLike (Country ::getCountrycode , "%" + country .getCountrycode () + "%" );
74
+ }
75
+ return countryMapper .selectByExample (weekend );
76
+ }
77
+
61
78
public Country getById (Integer id ) {
62
79
return countryMapper .selectByPrimaryKey (id );
63
80
}
You can’t perform that action at this time.
0 commit comments