实现图书多条件动态查询
imooc-reader 项目:
webapp\WEB-INF\ftl\
index.ftl 首页模板
<div class="row mt-2">
<div class="col-8 mt-2">
<h4>热评好书推荐</h4>
</div>
<div class="col-8 mt-2">
<!-- 默认的高亮标签是"全部" -->
<span data-category="-1" style="cursor: pointer" class="highlight font-weight-bold category">全部</span>
|
<!-- 遍历所有分类集合 -->
<#list categoryList as category>
<a style="cursor: pointer" data-category="${category.categoryId}" class="text-black-50 font-weight-bold category">${category.categoryName}</a>
<!-- 如果集合中还存在元素时, 才显示"|"线 -->
<#if category_has_next>|</#if>
</#list>
</div>
<div class="col-8 mt-2">
<!-- 默认的高亮标签是"按热度" -->
<span data-order="quantity" style="cursor: pointer" class="order highlight font-weight-bold mr-3">按热度</span>
<span data-order="score" style="cursor: pointer" class="order text-black-50 mr-3 font-weight-bold">按评分</span>
</div>
</div>
</script>
//页面就绪函数
$(function(){
loadMore(true);//请求"第一页"的页面数据
})
$(function(){
// 绑定"点击加载更多"按钮, 请求下一页的页面数据
$("#btnMore").click(function(){
loadMore();//请求下一页的页面数据
})
//给所有"分类"标签绑定单击事件, 设置分类标签样式
$(".category").click(function(){
//移除所有"分类"标签中的"高亮"样式
$(".category").removeClass("highlight");
//设置所有"分类"标签的样式为"灰色"
$(".category").addClass("text-black-50");
//设置当前被点击的元素样式为"高亮"
$(this).addClass("highlight")
})
//给所有"排序"标签绑定单击事件, 设置排序标签样式
$(".order").click(function(){
//移除所有"排序"标签中的"高亮"样式
$(".order").removeClass("highlight");
//设置所有"排序"标签的样式为"灰色"
$(".order").addClass("text-black-50");
//设置当前被点击的元素样式为"高亮"
$(this).addClass("highlight")
})
})
</script>
</head>
.service.
BookService 服务接口
package com.tony.reader.service;
import com.baom