commit | author | age
|
9bcb19
|
1 |
/* |
I |
2 |
Copyright [2020] [https://www.xiaonuo.vip] |
|
3 |
|
|
4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
you may not use this file except in compliance with the License. |
|
6 |
You may obtain a copy of the License at |
|
7 |
|
|
8 |
http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
|
|
10 |
Unless required by applicable law or agreed to in writing, software |
|
11 |
distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
See the License for the specific language governing permissions and |
|
14 |
limitations under the License. |
|
15 |
|
|
16 |
Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
|
17 |
|
|
18 |
1.请不要删除和修改根目录下的LICENSE文件。 |
|
19 |
2.请不要删除和修改Snowy源码头部的版权声明。 |
|
20 |
3.请保留源码和相关描述文件的项目出处,作者声明等。 |
|
21 |
4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy |
|
22 |
5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy |
|
23 |
6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip |
|
24 |
*/ |
|
25 |
package vip.xiaonuo.sys.modular.log.service.impl; |
|
26 |
|
|
27 |
import cn.hutool.core.util.ObjectUtil; |
|
28 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
29 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
30 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
31 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
32 |
import org.springframework.stereotype.Service; |
|
33 |
import vip.xiaonuo.core.factory.PageFactory; |
|
34 |
import vip.xiaonuo.core.pojo.page.PageResult; |
|
35 |
import vip.xiaonuo.core.util.PoiUtil; |
|
36 |
import vip.xiaonuo.sys.modular.log.entity.SysOpLog; |
|
37 |
import vip.xiaonuo.sys.modular.log.mapper.SysOpLogMapper; |
|
38 |
import vip.xiaonuo.sys.modular.log.param.SysOpLogParam; |
|
39 |
import vip.xiaonuo.sys.modular.log.service.SysOpLogService; |
|
40 |
|
|
41 |
import java.util.List; |
|
42 |
|
|
43 |
/** |
|
44 |
* 系统操作日志service接口实现类 |
|
45 |
* |
|
46 |
* @author xuyuxiang |
|
47 |
* @date 2020/3/12 14:22 |
|
48 |
*/ |
|
49 |
@Service |
|
50 |
public class SysOpLogServiceImpl extends ServiceImpl<SysOpLogMapper, SysOpLog> implements SysOpLogService { |
|
51 |
|
|
52 |
@Override |
|
53 |
public PageResult<SysOpLog> page(SysOpLogParam sysOpLogParam) { |
|
54 |
LambdaQueryWrapper<SysOpLog> queryWrapper = new LambdaQueryWrapper<>(); |
|
55 |
if (ObjectUtil.isNotNull(sysOpLogParam)) { |
|
56 |
//根据名称模糊查询 |
|
57 |
if (ObjectUtil.isNotEmpty(sysOpLogParam.getName())) { |
|
58 |
queryWrapper.like(SysOpLog::getName, sysOpLogParam.getName()); |
|
59 |
} |
|
60 |
//根据操作类型查询 |
|
61 |
if (ObjectUtil.isNotEmpty(sysOpLogParam.getOpType())) { |
|
62 |
queryWrapper.eq(SysOpLog::getOpType, sysOpLogParam.getOpType()); |
|
63 |
} |
|
64 |
//根据是否成功查询 |
|
65 |
if (ObjectUtil.isNotEmpty(sysOpLogParam.getSuccess())) { |
|
66 |
queryWrapper.eq(SysOpLog::getSuccess, sysOpLogParam.getSuccess()); |
|
67 |
} |
|
68 |
// 根据时间范围查询 |
|
69 |
if (ObjectUtil.isAllNotEmpty(sysOpLogParam.getSearchBeginTime(), sysOpLogParam.getSearchEndTime())) { |
|
70 |
queryWrapper.apply("date_format (op_time,'%Y-%m-%d') >= date_format('" + sysOpLogParam.getSearchBeginTime() + "','%Y-%m-%d')") |
|
71 |
.apply("date_format (op_time,'%Y-%m-%d') <= date_format('" + sysOpLogParam.getSearchEndTime() + "','%Y-%m-%d')"); |
|
72 |
} |
|
73 |
} |
|
74 |
//根据操作时间倒序排列 |
|
75 |
queryWrapper.orderByDesc(SysOpLog::getOpTime); |
|
76 |
Page<SysOpLog> page = this.page(PageFactory.defaultPage(), queryWrapper); |
|
77 |
return new PageResult<>(page); |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public void delete() { |
|
82 |
this.remove(new QueryWrapper<>()); |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public void export(SysOpLogParam sysOpLogParam) { |
|
87 |
List<SysOpLog> list = this.list(); |
|
88 |
PoiUtil.exportExcelWithStream("SysOpLog.xls", SysOpLog.class, list); |
|
89 |
} |
|
90 |
} |