SysOpLogDaoImpl.java
3.16 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.zteits.sys.dao.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.clouds.common.utils.ListCopyUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.sys.param.SysOpLogQueryRequest;
import com.zteits.clouds.api.dto.sys.param.SysOpLogRequest;
import com.zteits.sys.dao.SysOpLogDao;
import com.zteits.sys.domain.SysOpLogExample;
import com.zteits.sys.domain.SysOpLogExample.Criteria;
import com.zteits.sys.domain.SysOpLogWithBLOBs;
import com.zteits.sys.mapper.SysOpLogMapper;
@Component
public class SysOpLogDaoImpl implements SysOpLogDao{
@Autowired
private SysOpLogMapper sysOpLogMapper;
@Override
public Integer saveSysOpLog(SysOpLogRequest req) {
SysOpLogWithBLOBs sysOpLog = new SysOpLogWithBLOBs();
if (req == null) {
throw new BizException(ErrorType.PARAMM_NULL, "入参为空!");
}
BeanUtils.copyProperties(req, sysOpLog);
int insertCount = sysOpLogMapper.insertSelective(sysOpLog);
return insertCount;
}
@Override
public Integer batchSaveSysOpLog(List<SysOpLogRequest> saveList) {
List<SysOpLogWithBLOBs> sysOpLogs = new ArrayList<SysOpLogWithBLOBs>();
if (CollectionUtils.isEmpty(saveList)) {
throw new BizException(ErrorType.PARAMM_NULL, "入参为空!");
}
ListCopyUtil.listCopyProperties(saveList, sysOpLogs,SysOpLogWithBLOBs.class);
saveList.parallelStream().forEach(e->{
SysOpLogWithBLOBs s = new SysOpLogWithBLOBs();
BeanUtils.copyProperties(e, s);
sysOpLogMapper.insertSelective(s);
});
return saveList.size();
}
@Override
public PageInfo<SysOpLogWithBLOBs> querySysOpLogForPage(SysOpLogQueryRequest request) {
PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
SysOpLogExample example = new SysOpLogExample();
Criteria sql = example.createCriteria();
if(StringUtils.isNotEmpty(request.getOpCode())){
sql.andOpCodeLike("%"+request.getOpCode()+"%");
}
if(StringUtils.isNotEmpty(request.getOpName())){
sql.andOpNameLike("%"+request.getOpName()+"%");
}
if(StringUtils.isNotEmpty(request.getMethodDesc())){
sql.andMethodDescLike("%"+request.getMethodDesc()+"%");
}
if(request.getBeginTime() != null){
sql.andCreateTimeGreaterThanOrEqualTo(request.getBeginTime());
}
if(request.getEndTime() != null){
sql.andCreateTimeLessThanOrEqualTo(request.getEndTime());
}
if(request.getOrgId() != null){
sql.andOrgIdEqualTo(request.getOrgId());
}
example.setOrderByClause("id desc");
List<SysOpLogWithBLOBs> list = sysOpLogMapper.selectByExampleWithBLOBs(example);
return new PageInfo<>(list);
}
}