ShyLogServiceImpl.java
2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.cnlive.shenhe.service.serviceImpl;
import com.alibaba.fastjson.JSON;
import com.cnlive.shenhe.dto.ShyLogDTO;
import com.cnlive.shenhe.entity.ShyLog;
import com.cnlive.shenhe.mapper.ShyLogMapper;
import com.cnlive.shenhe.service.ShyLogService;
import com.cnlive.shenhe.utils.CommonUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* @author 王言钊
* @author shkstart
* @create 2022-05-16 11:09
*/
@Service
public class ShyLogServiceImpl implements ShyLogService {
private static Logger logger = LoggerFactory.getLogger(ShyLogServiceImpl.class);
@Autowired
private ShyLogMapper shyLogMapper;
/**
* 查询所有的日志
*
* @return
*/
@Override
public PageInfo<ShyLog> selectByExample(ShyLogDTO shyLogDTO) {
logger.info("进入日志查询方法,参数接受对象为,ShyLogDTO:{}", JSON.toJSONString(shyLogDTO));
Example example = new Example(ShyLog.class);
//如果为空 按照倒序排序 分页查询所有
//以创建时间为条件进行倒序
Example.Criteria criteria = example.createCriteria();
Example.Criteria criteria2 = example.createCriteria();
example.setOrderByClause("`operation_time` desc");
// 如果查询条件不为空 按照条件走模糊查询
if (CommonUtils.isNotEmpty(shyLogDTO.getKeyword())) {
criteria.andLike("videoId", "%" + shyLogDTO.getKeyword() + "%");
criteria2.andLike("operator", "%" + shyLogDTO.getKeyword() + "%");
example.or(criteria2);
}
PageHelper.startPage(shyLogDTO.getPageNum(), shyLogDTO.getPageSize());
List<ShyLog> shyLogs = shyLogMapper.selectByExample(example);
PageInfo<ShyLog> shyLogPageInfo = new PageInfo<>(shyLogs);
return shyLogPageInfo;
}
/**
* 添加日志记录
*
* @param shyLog
* @return
*/
@Override
public Boolean addShyLog(ShyLog shyLog) {
logger.info("进入日志添加方法 接受日志对象为,ShyLog:{}", JSON.toJSONString(shyLog));
int result = shyLogMapper.insertSelective(shyLog);
return result > 0;
}
}