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 | 15 | |
| 16 | 16 | private Integer pageSize; |
| 17 | 17 | |
| 18 | + private String keyword; | |
| 19 | + | |
| 18 | 20 | public ShyLogDTO() { |
| 19 | 21 | } |
| 20 | 22 | |
| ... | ... | @@ -39,11 +41,26 @@ public class ShyLogDTO extends ShyLog implements Serializable { |
| 39 | 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 | 58 | @Override |
| 43 | 59 | public String toString() { |
| 44 | 60 | return "ShyLogDTO{" + |
| 45 | 61 | "pageNum=" + pageNum + |
| 46 | 62 | ", pageSize=" + pageSize + |
| 63 | + ", keyword='" + keyword + '\'' + | |
| 47 | 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 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.cnlive.shenhe.dto.ShyLogDTO; |
| 5 | -import com.cnlive.shenhe.entity.ShyActivity; | |
| 6 | 5 | import com.cnlive.shenhe.entity.ShyLog; |
| 7 | 6 | import com.cnlive.shenhe.mapper.ShyLogMapper; |
| 8 | 7 | import com.cnlive.shenhe.service.ShyLogService; |
| 8 | +import com.cnlive.shenhe.utils.CommonUtils; | |
| 9 | 9 | import com.github.pagehelper.PageHelper; |
| 10 | 10 | import com.github.pagehelper.PageInfo; |
| 11 | 11 | import org.slf4j.Logger; |
| ... | ... | @@ -37,14 +37,17 @@ public class ShyLogServiceImpl implements ShyLogService { |
| 37 | 37 | @Override |
| 38 | 38 | public PageInfo<ShyLog> selectByExample(ShyLogDTO shyLogDTO) { |
| 39 | 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 | 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 | 52 | PageHelper.startPage(shyLogDTO.getPageNum(), shyLogDTO.getPageSize()); |
| 50 | 53 | List<ShyLog> shyLogs = shyLogMapper.selectByExample(example); | ... | ... |
src/main/resources/templates/page/log.html
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | </div> |
| 37 | 37 | </div> |
| 38 | 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 | 40 | <ul class="dropdown-menu" role="menu"> |
| 41 | 41 | <li><label><input type="checkbox" data-field="sp_id" value="0" |
| 42 | 42 | checked="checked"> 视频ID</label></li> |
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | </div> |
| 56 | 56 | <div class="pull-right search"> |
| 57 | 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 | 59 | <!-- </form>--> |
| 60 | 60 | </div> |
| 61 | 61 | </div> | ... | ... |