Browse Source

日志模块,查询

zhongwei
段飞宇 2 years ago
parent
commit
a50f83c4b8
  1. 26
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java
  2. 1
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java
  3. 7
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java
  4. 40
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java
  5. 11
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java
  6. 28
      hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java

26
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/controller/SysLogController.java

@ -115,5 +115,31 @@ public class SysLogController {
return R.data(sysLog); return R.data(sysLog);
} }
// /**
// * 根据Id获取日志数据
// * @return
// */
// @ApiResponses({
// @ApiResponse(code = 200,message = "OK",response = SysLog.class),
// })
// @OperationAnnotation(moduleName = "操作日志",
// operatorType = OperatorType.MANAGE,
// businessType = BusinessType.INSERT
// ,title = "系统日志",action = "根据操作模块查询信息")
// @ApiOperation("根据操作模块查询信息")
// @GetMapping("/selectPageByModuleName/{page}/{size}")
// public R selectPageByModuleName(
// @PathVariable Long page,
// @PathVariable Long size,
// SysLogVo sysLogVo) {
// Page<SysLog> objectPage = new Page<>(page,size);
// IPage<SysLog> sysLog = sysLogService.selectPageByModuleName(objectPage,sysLogVo);
// return R.data(sysLog);
// }
} }

1
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/SysLogService.java

@ -33,4 +33,5 @@ public interface SysLogService extends IService<SysLog> {
* @return * @return
*/ */
IPage<SysLog> selectPage(Page<SysLog> page1, SysLogVo sysLog); IPage<SysLog> selectPage(Page<SysLog> page1, SysLogVo sysLog);
} }

7
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/StatisticsServiceImpl.java

@ -11,6 +11,7 @@ import com.hnac.hzims.middle.systemlog.service.SysLogService;
import com.hnac.hzims.middle.systemlog.vo.StatisticsVo; import com.hnac.hzims.middle.systemlog.vo.StatisticsVo;
import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo; import com.hnac.hzims.middle.systemlog.vo.SysLogStatisticsVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -99,6 +100,12 @@ public class StatisticsServiceImpl extends ServiceImpl<StatisticsMapper, Statist
@Override @Override
public IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics) { public IPage<Statistics> selectPage(Page<Statistics> page1, StatisticsVo statistics) {
QueryWrapper<Statistics> queryWrapper = new QueryWrapper<>(); QueryWrapper<Statistics> queryWrapper = new QueryWrapper<>();
//开始时间
queryWrapper.lambda().eq(StringUtils.isNotEmpty(statistics.getCreateTime()),Statistics::getDateCalculated,
statistics.getCreateTime());
//结束时间
queryWrapper.lambda().eq(StringUtils.isNotEmpty(statistics.getEndTime()),Statistics::getDateCalculated,
statistics.getEndTime());
IPage<Statistics> statisticsPage = baseMapper.selectPage(page1, queryWrapper); IPage<Statistics> statisticsPage = baseMapper.selectPage(page1, queryWrapper);
return statisticsPage; return statisticsPage;
} }

40
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/service/impl/SysLogServiceImpl.java

@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@ -47,9 +48,24 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
*/ */
@Override @Override
public IPage<SysLog> selectPage(Page<SysLog> page1, SysLogVo sysLog) { public IPage<SysLog> selectPage(Page<SysLog> page1, SysLogVo sysLog) {
QueryWrapper<SysLog> queryWrapper = getSysLogQueryWrapper(sysLog);
IPage<SysLog> statisticsPage = baseMapper.selectPage(page1, queryWrapper);
return statisticsPage;
}
/**
* 日志查询接口
* @param sysLog
* @return
*/
private static QueryWrapper<SysLog> getSysLogQueryWrapper(SysLogVo sysLog) {
String keyword = sysLog.getKeyword(); String keyword = sysLog.getKeyword();
LocalDate createTime = sysLog.getCreateTime(); LocalDateTime createTime = sysLog.getCreateTime();
LocalDate endTime = sysLog.getEndTime(); LocalDateTime endTime = sysLog.getEndTime();
String dateCalculated = sysLog.getDateCalculated();
String moduleName = sysLog.getModuleName();
String path = sysLog.getPath();
QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysLog> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotEmpty(sysLog.getKeyword())) { if (StringUtils.isNotEmpty(sysLog.getKeyword())) {
@ -58,16 +74,28 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
queryWrapper.lambda().or().like(SysLog::getAction, keyword); queryWrapper.lambda().or().like(SysLog::getAction, keyword);
} }
//请求地址
if (StringUtils.isNotEmpty(path)) {
queryWrapper.lambda().eq(SysLog::getPath, path);
}
if (ObjectUtils.isNotEmpty(createTime)){ //开始时间
queryWrapper.lambda().ge(SysLog::getOperationTime,createTime); if (ObjectUtils.isNotEmpty(createTime)) {
queryWrapper.lambda().ge(SysLog::getOperationTime, createTime);
} }
//结束时间
if (ObjectUtils.isNotEmpty(endTime)){ if (ObjectUtils.isNotEmpty(endTime)){
queryWrapper.lambda().le(SysLog::getOperationTime,endTime); queryWrapper.lambda().le(SysLog::getOperationTime,endTime);
} }
IPage<SysLog> statisticsPage = baseMapper.selectPage(page1, queryWrapper); //根据操作时间和功能模块查询
return statisticsPage; if (StringUtils.isNotEmpty(dateCalculated) && StringUtils.isNotEmpty(moduleName)){
queryWrapper.lambda().eq(SysLog::getModuleName,moduleName);
queryWrapper.eq("date_format(operation_time,'%Y-%m')",dateCalculated);
} }
return queryWrapper;
}
} }

11
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/StatisticsVo.java

@ -2,6 +2,7 @@ package com.hnac.hzims.middle.systemlog.vo;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -25,14 +26,16 @@ public class StatisticsVo {
/** /**
* 开始时间 * 开始时间
*/ */
@JsonFormat(pattern="yyyy-MM-dd ",timezone = "GMT+8",shape = JsonFormat.Shape.STRING) //@JsonFormat(pattern="yyyy-MM-dd",shape = JsonFormat.Shape.STRING)
private LocalDate createTime; //@DateTimeFormat(pattern = "yyyy-MM-dd")
private String createTime;
/** /**
* 结束时间 * 结束时间
* *
*/ */
@JsonFormat(pattern="yyyy-MM-dd ",timezone = "GMT+8",shape = JsonFormat.Shape.STRING) //@JsonFormat(pattern="yyyy-MM-dd",shape = JsonFormat.Shape.STRING)
private LocalDate endTime; //@DateTimeFormat(pattern = "yyyy-MM-dd")
private String endTime;
} }

28
hzims-service/hzims-middle/src/main/java/com/hnac/hzims/middle/systemlog/vo/SysLogVo.java

@ -1,8 +1,11 @@
package com.hnac.hzims.middle.systemlog.vo; package com.hnac.hzims.middle.systemlog.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
/** /**
* @Author WL * @Author WL
@ -14,20 +17,39 @@ import java.time.LocalDate;
public class SysLogVo { public class SysLogVo {
@ApiModelProperty("功能模块")
private String moduleName;
/** /**
* key * 功能模块操作方法方法描述 模糊查询
*/ */
@ApiModelProperty("功能模块,操作方法,方法描述 模糊查询")
public String keyword; public String keyword;
/** /**
* 开始时间 * 开始时间
*/ */
private LocalDate createTime; @ApiModelProperty("开始时间")
private LocalDateTime createTime;
/** /**
* 结束时间 * 结束时间
*/ */
private LocalDate endTime; @ApiModelProperty("结束时间")
private LocalDateTime endTime;
@ApiModelProperty("操作时间")
private String dateCalculated;
@ApiModelProperty("请求地址")
private String path;
} }

Loading…
Cancel
Save