Introducing new features. 日志功能新增时间过滤条件 https://gitee.com/log4j/pig/issues/I1XPCP

This commit is contained in:
kapai 2020-10-09 22:26:37 +08:00
parent 5a657057e0
commit 44a5b98356
7 changed files with 68 additions and 6 deletions

View File

@ -0,0 +1,31 @@
package com.pig4cloud.pig.admin.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author lengleng
* @date 2020/10/9
* <p>
* 日志查询传输对象
*/
@Data
@ApiModel(value = "日志查询对象")
public class SysLogDTO {
/**
* 查询日志类型
*/
@ApiModelProperty(value = "日志类型")
private String type;
/**
* 创建时间区间 [开始时间结束时间]
*/
@ApiModelProperty(value = "创建时间区间")
private LocalDateTime[] createTime;
}

View File

@ -20,7 +20,7 @@
* @ Apache-2.0 * @ Apache-2.0
*/ */
package com.pig4cloud.pig.admin.api.vo; package com.pig4cloud.pig.admin.api.util;
import com.pig4cloud.pig.admin.api.dto.MenuTree; import com.pig4cloud.pig.admin.api.dto.MenuTree;
import com.pig4cloud.pig.admin.api.dto.TreeNode; import com.pig4cloud.pig.admin.api.dto.TreeNode;

View File

@ -15,8 +15,8 @@
*/ */
package com.pig4cloud.pig.admin.controller; package com.pig4cloud.pig.admin.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.admin.api.dto.SysLogDTO;
import com.pig4cloud.pig.admin.api.entity.SysLog; import com.pig4cloud.pig.admin.api.entity.SysLog;
import com.pig4cloud.pig.admin.service.SysLogService; import com.pig4cloud.pig.admin.service.SysLogService;
import com.pig4cloud.pig.common.core.util.R; import com.pig4cloud.pig.common.core.util.R;
@ -51,8 +51,8 @@ public class LogController {
* @return * @return
*/ */
@GetMapping("/page") @GetMapping("/page")
public R getLogPage(Page page, SysLog sysLog) { public R getLogPage(Page page, SysLogDTO sysLog) {
return R.ok(sysLogService.page(page, Wrappers.query(sysLog))); return R.ok(sysLogService.getLogByPage(page, sysLog));
} }
/** /**

View File

@ -16,7 +16,9 @@
package com.pig4cloud.pig.admin.service; package com.pig4cloud.pig.admin.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pig.admin.api.dto.SysLogDTO;
import com.pig4cloud.pig.admin.api.entity.SysLog; import com.pig4cloud.pig.admin.api.entity.SysLog;
/** /**
@ -29,4 +31,12 @@ import com.pig4cloud.pig.admin.api.entity.SysLog;
*/ */
public interface SysLogService extends IService<SysLog> { public interface SysLogService extends IService<SysLog> {
/**
* 分页查询日志
* @param page
* @param sysLog
* @return
*/
Page getLogByPage(Page page, SysLogDTO sysLog);
} }

View File

@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.admin.api.dto.DeptTree; import com.pig4cloud.pig.admin.api.dto.DeptTree;
import com.pig4cloud.pig.admin.api.entity.SysDept; import com.pig4cloud.pig.admin.api.entity.SysDept;
import com.pig4cloud.pig.admin.api.entity.SysDeptRelation; import com.pig4cloud.pig.admin.api.entity.SysDeptRelation;
import com.pig4cloud.pig.admin.api.vo.TreeUtil; import com.pig4cloud.pig.admin.api.util.TreeUtil;
import com.pig4cloud.pig.admin.mapper.SysDeptMapper; import com.pig4cloud.pig.admin.mapper.SysDeptMapper;
import com.pig4cloud.pig.admin.service.SysDeptRelationService; import com.pig4cloud.pig.admin.service.SysDeptRelationService;
import com.pig4cloud.pig.admin.service.SysDeptService; import com.pig4cloud.pig.admin.service.SysDeptService;

View File

@ -16,7 +16,13 @@
package com.pig4cloud.pig.admin.service.impl; package com.pig4cloud.pig.admin.service.impl;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.admin.api.dto.SysLogDTO;
import com.pig4cloud.pig.admin.api.entity.SysLog; import com.pig4cloud.pig.admin.api.entity.SysLog;
import com.pig4cloud.pig.admin.mapper.SysLogMapper; import com.pig4cloud.pig.admin.mapper.SysLogMapper;
import com.pig4cloud.pig.admin.service.SysLogService; import com.pig4cloud.pig.admin.service.SysLogService;
@ -33,4 +39,19 @@ import org.springframework.stereotype.Service;
@Service @Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService { public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {
@Override
public Page getLogByPage(Page page, SysLogDTO sysLog) {
LambdaQueryWrapper<SysLog> wrapper = Wrappers.lambdaQuery();
if (StrUtil.isNotBlank(sysLog.getType())) {
wrapper.eq(SysLog::getType, sysLog.getType());
}
if (ArrayUtil.isNotEmpty(sysLog.getCreateTime())) {
wrapper.ge(SysLog::getCreateTime, sysLog.getCreateTime()[0]).le(SysLog::getCreateTime,
sysLog.getCreateTime()[1]);
}
return baseMapper.selectPage(page, wrapper);
}
} }

View File

@ -22,8 +22,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.admin.api.dto.MenuTree; import com.pig4cloud.pig.admin.api.dto.MenuTree;
import com.pig4cloud.pig.admin.api.entity.SysMenu; import com.pig4cloud.pig.admin.api.entity.SysMenu;
import com.pig4cloud.pig.admin.api.entity.SysRoleMenu; import com.pig4cloud.pig.admin.api.entity.SysRoleMenu;
import com.pig4cloud.pig.admin.api.util.TreeUtil;
import com.pig4cloud.pig.admin.api.vo.MenuVO; import com.pig4cloud.pig.admin.api.vo.MenuVO;
import com.pig4cloud.pig.admin.api.vo.TreeUtil;
import com.pig4cloud.pig.admin.mapper.SysMenuMapper; import com.pig4cloud.pig.admin.mapper.SysMenuMapper;
import com.pig4cloud.pig.admin.mapper.SysRoleMenuMapper; import com.pig4cloud.pig.admin.mapper.SysRoleMenuMapper;
import com.pig4cloud.pig.admin.service.SysMenuService; import com.pig4cloud.pig.admin.service.SysMenuService;