1
This commit is contained in:
@@ -29,8 +29,8 @@ public class ExampleController extends BaseController {
|
||||
ExampleService exampleService;
|
||||
|
||||
@RequestMapping("")
|
||||
public ModelAndView index(ModelAndView modelAndView, Page page) {
|
||||
page = exampleService.search(page);
|
||||
public ModelAndView index(ModelAndView modelAndView, Page page, String keyword) {
|
||||
page = exampleService.search(page, keyword);
|
||||
|
||||
List<ExampleExt> exts = new ArrayList<ExampleExt>();
|
||||
for (Example example : (List<Example>) page.getList()) {
|
||||
@@ -46,6 +46,7 @@ public class ExampleController extends BaseController {
|
||||
|
||||
modelAndView.addObject("adminList", jpaHelper.findAll(Admin.class));
|
||||
modelAndView.addObject("page", page);
|
||||
modelAndView.addObject("keyword", keyword);
|
||||
modelAndView.setViewName("/example/index");
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,22 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cym.bean.Page;
|
||||
import com.cym.model.Example;
|
||||
import com.cym.utils.ConditionAndWrapper;
|
||||
import com.cym.utils.JpaHelper;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
@Service
|
||||
public class ExampleService {
|
||||
@Autowired
|
||||
JpaHelper jpaHelper;
|
||||
|
||||
public Page search(Page page) {
|
||||
public Page search(Page page, String keyword) {
|
||||
ConditionAndWrapper conditionAndWrapper = new ConditionAndWrapper();
|
||||
if (StrUtil.isNotEmpty(keyword)) {
|
||||
conditionAndWrapper.like(Example::getName, keyword);
|
||||
}
|
||||
|
||||
page = jpaHelper.findPageByQuery(page, Example.class);
|
||||
|
||||
return page;
|
||||
|
||||
Reference in New Issue
Block a user