增加系统日志查询功能
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package cn.iocoder.mall.system.biz.bo.systemlog;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author:mac
|
||||
* @descriptio
|
||||
* @create: 2020-5-12 20:43:00
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogBO implements Serializable {
|
||||
|
||||
private String traceId;
|
||||
|
||||
private Integer accountId;
|
||||
|
||||
private String applicationName;
|
||||
|
||||
private String uri;
|
||||
|
||||
private String queryString;
|
||||
|
||||
private String method;
|
||||
|
||||
private String userAgent;
|
||||
|
||||
private String ip;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Integer responseTime;
|
||||
|
||||
private Integer errorCode;
|
||||
|
||||
private String errorMessage;
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
package cn.iocoder.mall.system.biz.convert.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO;
|
||||
import cn.iocoder.mall.system.biz.dataobject.systemlog.AccessLogDO;
|
||||
import cn.iocoder.mall.system.biz.dataobject.systemlog.ExceptionLogDO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
@@ -16,4 +20,8 @@ public interface SystemLogConvert {
|
||||
|
||||
ExceptionLogDO convert(ExceptionLogAddDTO bean);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<AccessLogBO> convertPage(IPage<AccessLogDO> page);
|
||||
|
||||
AccessLogBO convert(AccessLogDO bean);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
package cn.iocoder.mall.system.biz.dao.system;
|
||||
|
||||
import cn.iocoder.mall.mybatis.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.system.biz.dataobject.systemlog.AccessLogDO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 访问日志
|
||||
* @author:mac
|
||||
* @descriptio
|
||||
* @create: 2020-5-12 20:43:00
|
||||
*/
|
||||
@Repository
|
||||
public interface AccessLogMapper extends BaseMapper<AccessLogDO> {
|
||||
|
||||
// default IPage<AccessLogDO> selectPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
// return selectPage(new Page<>(accessLogPageDTO.getPageNo(), accessLogPageDTO.getPageSize()),
|
||||
// new QueryWrapperX<AccessLogDO>().eqIfPresent("user_id", accessLogPageDTO.getUserId()));
|
||||
// }
|
||||
default IPage<AccessLogDO> selectPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
return selectPage(new Page<>(accessLogPageDTO.getPageNo(), accessLogPageDTO.getPageSize()),
|
||||
new QueryWrapperX<AccessLogDO>().eqIfPresent("account_id", accessLogPageDTO.getAccountId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.system.biz.dto.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 访问日志添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogPageDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 账号编号
|
||||
*/
|
||||
private Integer accountId;
|
||||
|
||||
/**
|
||||
* 页码,从 1 开始
|
||||
*/
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package cn.iocoder.mall.system.biz.service.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO;
|
||||
|
||||
public interface SystemLogService {
|
||||
@@ -9,4 +12,6 @@ public interface SystemLogService {
|
||||
|
||||
void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO);
|
||||
|
||||
PageResult<AccessLogBO> getAccessLogPage(AccessLogPageDTO accessLogPageDTO);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package cn.iocoder.mall.system.biz.service.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO;
|
||||
import cn.iocoder.mall.system.biz.convert.systemlog.SystemLogConvert;
|
||||
import cn.iocoder.mall.system.biz.dao.system.AccessLogMapper;
|
||||
import cn.iocoder.mall.system.biz.dao.system.ExceptionLogMapper;
|
||||
import cn.iocoder.mall.system.biz.dataobject.systemlog.AccessLogDO;
|
||||
import cn.iocoder.mall.system.biz.dataobject.systemlog.ExceptionLogDO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -40,4 +43,12 @@ public class SystemLogServiceImpl implements SystemLogService {
|
||||
exceptionLogMapper.insert(logDO);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("Duplicates")
|
||||
public PageResult<AccessLogBO> getAccessLogPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
PageResult<AccessLogBO> accessLogPageBOPageResult = SystemLogConvert.INSTANCE.convertPage(
|
||||
accessLogMapper.selectPage(accessLogPageDTO));
|
||||
return accessLogPageBOPageResult;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user