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;
|
||||
|
||||
@@ -31,6 +31,19 @@
|
||||
<div class="layui-inline">
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="add()">添加模块</button>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label" style="width: 70px;">关键字</label>
|
||||
<div class="layui-input-inline" style="width: 150px;">
|
||||
<input type="text" name="keyword" value="${keyword}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<button type="button" class="layui-btn layui-btn-sm" onclick="search()">搜索</button>
|
||||
</div>
|
||||
|
||||
|
||||
<input type="hidden" name="pageNum" value="${page.pageNum}">
|
||||
<input type="hidden" name="pageSize" value="${page.pageSize}">
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user