Commit 67d41e744e8e1269b87acdb0e804cb2075f731c8
1 parent
d8692b36
开发日志模块的多条件搜索功能
Showing
3 changed files
with
27 additions
and
7 deletions
src/main/java/com/cnlive/shenhe/dto/ShyLogDTO.java
| @@ -15,6 +15,8 @@ public class ShyLogDTO extends ShyLog implements Serializable { | @@ -15,6 +15,8 @@ public class ShyLogDTO extends ShyLog implements Serializable { | ||
| 15 | 15 | ||
| 16 | private Integer pageSize; | 16 | private Integer pageSize; |
| 17 | 17 | ||
| 18 | + private String keyword; | ||
| 19 | + | ||
| 18 | public ShyLogDTO() { | 20 | public ShyLogDTO() { |
| 19 | } | 21 | } |
| 20 | 22 | ||
| @@ -39,11 +41,26 @@ public class ShyLogDTO extends ShyLog implements Serializable { | @@ -39,11 +41,26 @@ public class ShyLogDTO extends ShyLog implements Serializable { | ||
| 39 | this.pageSize = pageSize; | 41 | this.pageSize = pageSize; |
| 40 | } | 42 | } |
| 41 | 43 | ||
| 44 | + public ShyLogDTO(Integer pageNum, Integer pageSize, String keyword) { | ||
| 45 | + this.pageNum = pageNum; | ||
| 46 | + this.pageSize = pageSize; | ||
| 47 | + this.keyword = keyword; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public String getKeyword() { | ||
| 51 | + return keyword; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setKeyword(String keyword) { | ||
| 55 | + this.keyword = keyword; | ||
| 56 | + } | ||
| 57 | + | ||
| 42 | @Override | 58 | @Override |
| 43 | public String toString() { | 59 | public String toString() { |
| 44 | return "ShyLogDTO{" + | 60 | return "ShyLogDTO{" + |
| 45 | "pageNum=" + pageNum + | 61 | "pageNum=" + pageNum + |
| 46 | ", pageSize=" + pageSize + | 62 | ", pageSize=" + pageSize + |
| 63 | + ", keyword='" + keyword + '\'' + | ||
| 47 | "} " + super.toString(); | 64 | "} " + super.toString(); |
| 48 | } | 65 | } |
| 49 | } | 66 | } |
src/main/java/com/cnlive/shenhe/service/serviceImpl/ShyLogServiceImpl.java
| @@ -2,10 +2,10 @@ package com.cnlive.shenhe.service.serviceImpl; | @@ -2,10 +2,10 @@ package com.cnlive.shenhe.service.serviceImpl; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.cnlive.shenhe.dto.ShyLogDTO; | 4 | import com.cnlive.shenhe.dto.ShyLogDTO; |
| 5 | -import com.cnlive.shenhe.entity.ShyActivity; | ||
| 6 | import com.cnlive.shenhe.entity.ShyLog; | 5 | import com.cnlive.shenhe.entity.ShyLog; |
| 7 | import com.cnlive.shenhe.mapper.ShyLogMapper; | 6 | import com.cnlive.shenhe.mapper.ShyLogMapper; |
| 8 | import com.cnlive.shenhe.service.ShyLogService; | 7 | import com.cnlive.shenhe.service.ShyLogService; |
| 8 | +import com.cnlive.shenhe.utils.CommonUtils; | ||
| 9 | import com.github.pagehelper.PageHelper; | 9 | import com.github.pagehelper.PageHelper; |
| 10 | import com.github.pagehelper.PageInfo; | 10 | import com.github.pagehelper.PageInfo; |
| 11 | import org.slf4j.Logger; | 11 | import org.slf4j.Logger; |
| @@ -37,14 +37,17 @@ public class ShyLogServiceImpl implements ShyLogService { | @@ -37,14 +37,17 @@ public class ShyLogServiceImpl implements ShyLogService { | ||
| 37 | @Override | 37 | @Override |
| 38 | public PageInfo<ShyLog> selectByExample(ShyLogDTO shyLogDTO) { | 38 | public PageInfo<ShyLog> selectByExample(ShyLogDTO shyLogDTO) { |
| 39 | logger.info("进入日志查询方法,参数接受对象为,ShyLogDTO:{}", JSON.toJSONString(shyLogDTO)); | 39 | logger.info("进入日志查询方法,参数接受对象为,ShyLogDTO:{}", JSON.toJSONString(shyLogDTO)); |
| 40 | - Example example = new Example(ShyActivity.class); | 40 | + Example example = new Example(ShyLog.class); |
| 41 | //如果为空 按照倒序排序 分页查询所有 | 41 | //如果为空 按照倒序排序 分页查询所有 |
| 42 | //以创建时间为条件进行倒序 | 42 | //以创建时间为条件进行倒序 |
| 43 | - example.setOrderByClause("`operation_time` desc"); | ||
| 44 | Example.Criteria criteria = example.createCriteria(); | 43 | Example.Criteria criteria = example.createCriteria(); |
| 44 | + Example.Criteria criteria2 = example.createCriteria(); | ||
| 45 | + example.setOrderByClause("`operation_time` desc"); | ||
| 45 | // 如果查询条件不为空 按照条件走模糊查询 | 46 | // 如果查询条件不为空 按照条件走模糊查询 |
| 46 | - if (shyLogDTO.getVideoId() != null) { | ||
| 47 | - criteria.andLike("videoId", "%" + shyLogDTO.getVideoId() + "%"); | 47 | + if (CommonUtils.isNotEmpty(shyLogDTO.getKeyword())) { |
| 48 | + criteria.andLike("videoId", "%" + shyLogDTO.getKeyword() + "%"); | ||
| 49 | + criteria2.andLike("operator", "%" + shyLogDTO.getKeyword() + "%"); | ||
| 50 | + example.or(criteria2); | ||
| 48 | } | 51 | } |
| 49 | PageHelper.startPage(shyLogDTO.getPageNum(), shyLogDTO.getPageSize()); | 52 | PageHelper.startPage(shyLogDTO.getPageNum(), shyLogDTO.getPageSize()); |
| 50 | List<ShyLog> shyLogs = shyLogMapper.selectByExample(example); | 53 | List<ShyLog> shyLogs = shyLogMapper.selectByExample(example); |
src/main/resources/templates/page/log.html
| @@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
| 36 | </div> | 36 | </div> |
| 37 | </div> | 37 | </div> |
| 38 | <div class="columns columns-right btn-group pull-right"> | 38 | <div class="columns columns-right btn-group pull-right"> |
| 39 | - <button class="btn btn-default" type="button" name="refresh" title="搜索" id="log_query">刷新</button> | 39 | + <button class="btn btn-default" type="button" name="refresh" title="搜索" id="log_query">搜索</button> |
| 40 | <ul class="dropdown-menu" role="menu"> | 40 | <ul class="dropdown-menu" role="menu"> |
| 41 | <li><label><input type="checkbox" data-field="sp_id" value="0" | 41 | <li><label><input type="checkbox" data-field="sp_id" value="0" |
| 42 | checked="checked"> 视频ID</label></li> | 42 | checked="checked"> 视频ID</label></li> |
| @@ -55,7 +55,7 @@ | @@ -55,7 +55,7 @@ | ||
| 55 | </div> | 55 | </div> |
| 56 | <div class="pull-right search"> | 56 | <div class="pull-right search"> |
| 57 | <!-- <form id="searchForm">--> | 57 | <!-- <form id="searchForm">--> |
| 58 | - <input class="form-control" type="text" placeholder="刷新" id="keyword" name="keyword" th:value="${param.keyword}"> | 58 | + <input class="form-control" type="text" placeholder="搜索" id="keyword" name="keyword" th:value="${param.keyword}"> |
| 59 | <!-- </form>--> | 59 | <!-- </form>--> |
| 60 | </div> | 60 | </div> |
| 61 | </div> | 61 | </div> |