访问日志的管理功能的迁移
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package cn.iocoder.mall.systemservice.convert.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogCreateBO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemAccessLogConvert {
|
||||
|
||||
SystemAccessLogConvert INSTANCE = Mappers.getMapper(SystemAccessLogConvert.class);
|
||||
|
||||
SystemAccessLogDO convert(SystemAccessLogCreateBO bean);
|
||||
|
||||
SystemAccessLogCreateBO convert(SystemAccessLogCreateDTO bean);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<SystemAccessLogBO> convertPage(IPage<SystemAccessLogDO> page);
|
||||
|
||||
SystemAccessLogPageBO convert(SystemAccessLogPageDTO bean);
|
||||
|
||||
PageResult<SystemAccessLogVO> convertPage(PageResult<SystemAccessLogBO> page);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.iocoder.mall.systemservice.convert.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogCreateBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemExceptionLogConvert {
|
||||
|
||||
SystemExceptionLogConvert INSTANCE = Mappers.getMapper(SystemExceptionLogConvert.class);
|
||||
|
||||
SystemExceptionLogDO convert(SystemExceptionLogCreateBO bean);
|
||||
|
||||
SystemExceptionLogCreateBO convert(SystemExceptionLogCreateDTO bean);
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package cn.iocoder.mall.systemservice.convert.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.AccessLogDO;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.AccessLogAddBO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.ExceptionLogAddBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SystemLogConvert {
|
||||
|
||||
SystemLogConvert INSTANCE = Mappers.getMapper(SystemLogConvert.class);
|
||||
|
||||
AccessLogDO convert(AccessLogAddBO bean);
|
||||
|
||||
ExceptionLogDO convert(ExceptionLogAddBO bean);
|
||||
|
||||
AccessLogAddBO convert(AccessLogAddDTO bean);
|
||||
|
||||
ExceptionLogAddBO convert(ExceptionLogAddDTO bean);
|
||||
|
||||
// AccessLogDO convert(AccessLogAddDTO bean);
|
||||
//
|
||||
// ExceptionLogDO convert(ExceptionLogAddDTO bean);
|
||||
//
|
||||
// @Mapping(source = "records", target = "list")
|
||||
// PageResult<AccessLogBO> convertPage(IPage<AccessLogDO> page);
|
||||
//
|
||||
// AccessLogBO convert(AccessLogDO bean);
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import lombok.experimental.Accessors;
|
||||
* value:1 男
|
||||
* value:2 女
|
||||
*/
|
||||
@TableName("data_dict")
|
||||
@TableName("system_data_dict")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class DataDictDO extends DeletableDO {
|
||||
|
||||
@@ -11,13 +11,17 @@ import lombok.experimental.Accessors;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 访问日志 DO
|
||||
* 系统访问日志 DO
|
||||
*
|
||||
* 记录用户、管理员对 API 接口的调用
|
||||
*
|
||||
* TODO 优化点:考虑到架构简单,暂时记录到 MySQL。因为访问日志容易比较大,所以建议未来存储到 ES 中,同时能够提供更丰富的检索能力
|
||||
*/
|
||||
@TableName("system_access_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogDO extends BaseDO {
|
||||
public class SystemAccessLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
@@ -10,13 +10,13 @@ import lombok.experimental.Accessors;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 异常日志 DO
|
||||
* 系统异常日志 DO
|
||||
*/
|
||||
@TableName("system_exception_log")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ExceptionLogDO extends BaseDO {
|
||||
public class SystemExceptionLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
@@ -13,16 +13,16 @@ public interface DataDictMapper extends BaseMapper<DataDictDO> {
|
||||
|
||||
default DataDictDO selectByEnumValueAndValue(String enumValue, String value) {
|
||||
return selectOne(new QueryWrapper<DataDictDO>()
|
||||
.eq("enumValue", enumValue).eq("value", value));
|
||||
.eq("enum_value", enumValue).eq("value", value));
|
||||
}
|
||||
|
||||
default List<DataDictDO> selectByEnumValueAndValues(String enumValue, Collection<String> values) {
|
||||
return selectList(new QueryWrapper<DataDictDO>()
|
||||
.eq("enumValue", enumValue).in("value", values));
|
||||
.eq("enum_value", enumValue).in("value", values));
|
||||
}
|
||||
|
||||
default List<DataDictDO> selectByEnumValue(String enumValue) {
|
||||
return selectList(new QueryWrapper<DataDictDO>().eq("enumValue", enumValue));
|
||||
return selectList(new QueryWrapper<DataDictDO>().eq("enum_value", enumValue));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.AccessLogDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@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("account_id", accessLogPageDTO.getAccountId()));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog;
|
||||
|
||||
import cn.iocoder.mall.mybatis.query.QueryWrapperX;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Mapper
|
||||
*/
|
||||
@Repository
|
||||
public interface SystemAccessLogMapper extends BaseMapper<SystemAccessLogDO> {
|
||||
|
||||
default IPage<SystemAccessLogDO> selectPage(SystemAccessLogPageBO pageBO) {
|
||||
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
|
||||
new QueryWrapperX<SystemAccessLogDO>()
|
||||
.eqIfPresent("user_id", pageBO.getUserId())
|
||||
.eqIfPresent("user_type", pageBO.getUserType())
|
||||
.eqIfPresent("application_name", pageBO.getApplicationName())
|
||||
.orderByDesc("start_time"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ExceptionLogMapper extends BaseMapper<ExceptionLogDO> {
|
||||
public interface SystemExceptionLogMapper extends BaseMapper<SystemExceptionLogDO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package cn.iocoder.mall.systemservice.manager.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.convert.systemlog.SystemAccessLogConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.SystemAccessLogService;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Manager
|
||||
*/
|
||||
@Service
|
||||
public class SystemAccessLogManager {
|
||||
|
||||
@Autowired
|
||||
private SystemAccessLogService systemAccessLogService;
|
||||
|
||||
/**
|
||||
* 创建系统访问日志
|
||||
*
|
||||
* @param createDTO 创建系统访问日志 DTO
|
||||
*/
|
||||
public void createSystemAccessLog(SystemAccessLogCreateDTO createDTO) {
|
||||
systemAccessLogService.createSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(createDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得系统访问日志分页
|
||||
*
|
||||
* @param pageDTO 系统访问日志分页查询
|
||||
* @return 系统访问日志分页结果
|
||||
*/
|
||||
public PageResult<SystemAccessLogVO> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
PageResult<SystemAccessLogBO> pageResultBO = systemAccessLogService.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO));
|
||||
return SystemAccessLogConvert.INSTANCE.convertPage(pageResultBO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.iocoder.mall.systemservice.manager.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.convert.systemlog.SystemExceptionLogConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.SystemExceptionLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统异常日志 Manager
|
||||
*/
|
||||
@Service
|
||||
public class SystemExceptionLogManager {
|
||||
|
||||
@Autowired
|
||||
private SystemExceptionLogService systemLogService;
|
||||
|
||||
public void createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) {
|
||||
systemLogService.createSystemExceptionLog(SystemExceptionLogConvert.INSTANCE.convert(createDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package cn.iocoder.mall.systemservice.manager.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.convert.systemlog.SystemLogConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.SystemLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SystemLogManager {
|
||||
|
||||
@Autowired
|
||||
private SystemLogService systemLogService;
|
||||
|
||||
public void addAccessLog(AccessLogAddDTO accessLogAddDTO) {
|
||||
systemLogService.addAccessLog(SystemLogConvert.INSTANCE.convert(accessLogAddDTO));
|
||||
}
|
||||
|
||||
public void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) {
|
||||
systemLogService.addExceptionLog(SystemLogConvert.INSTANCE.convert(exceptionLogAddDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.manager.systemlog.SystemAccessLogManager;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Rpc 实现类
|
||||
*/
|
||||
@Service(version = "${dubbo.provider.SystemAccessLogRpc.version}", validation = "false")
|
||||
public class SystemAccessLogRpcImpl implements SystemAccessLogRpc {
|
||||
|
||||
@Autowired
|
||||
private SystemAccessLogManager systemAccessLogManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> createSystemAccessLog(SystemAccessLogCreateDTO createDTO) {
|
||||
systemAccessLogManager.createSystemAccessLog(createDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<SystemAccessLogVO>> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
return success(systemAccessLogManager.pageSystemAccessLog(pageDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.systemservice.manager.systemlog.SystemExceptionLogManager;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Service(version = "${dubbo.provider.SystemExceptionLogRpc.version}", validation = "false")
|
||||
public class SystemExceptionLogRpcImpl implements SystemExceptionLogRpc {
|
||||
|
||||
@Autowired
|
||||
private SystemExceptionLogManager systemExceptionLogManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) {
|
||||
systemExceptionLogManager.createSystemExceptionLog(createDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.systemservice.manager.systemlog.SystemLogManager;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@Service(version = "${dubbo.provider.SystemLogRPC.version}", validation = "false")
|
||||
public class SystemLogRPCImpl implements SystemLogRPC {
|
||||
|
||||
@Autowired
|
||||
private SystemLogManager systemLogManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addAccessLog(AccessLogAddDTO accessLogAddDTO) {
|
||||
systemLogManager.addAccessLog(accessLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) {
|
||||
systemLogManager.addExceptionLog(exceptionLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package cn.iocoder.mall.systemservice.service.systemlog;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.convert.systemlog.SystemAccessLogConvert;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.SystemAccessLogMapper;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogCreateBO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统访问日志 Service
|
||||
*/
|
||||
@Service
|
||||
public class SystemAccessLogService {
|
||||
|
||||
@Autowired
|
||||
private SystemAccessLogMapper systemAccessLogMapper;
|
||||
|
||||
/**
|
||||
* 创建系统访问日志
|
||||
*
|
||||
* @param createBO 创建系统访问日志 BO
|
||||
*/
|
||||
public void createSystemAccessLog(SystemAccessLogCreateBO createBO) {
|
||||
SystemAccessLogDO logDO = SystemAccessLogConvert.INSTANCE.convert(createBO);
|
||||
systemAccessLogMapper.insert(logDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得系统访问日志分页
|
||||
*
|
||||
* @param pageBO 系统访问日志分页查询
|
||||
* @return 系统访问日志分页结果
|
||||
*/
|
||||
public PageResult<SystemAccessLogBO> pageSystemAccessLog(SystemAccessLogPageBO pageBO) {
|
||||
IPage<SystemAccessLogDO> systemAccessLogDOPage = systemAccessLogMapper.selectPage(pageBO);
|
||||
return SystemAccessLogConvert.INSTANCE.convertPage(systemAccessLogDOPage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.iocoder.mall.systemservice.service.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.convert.systemlog.SystemExceptionLogConvert;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.SystemExceptionLogMapper;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogCreateBO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 系统异常日志 Service
|
||||
*/
|
||||
@Service
|
||||
public class SystemExceptionLogService {
|
||||
|
||||
@Autowired
|
||||
private SystemExceptionLogMapper systemExceptionLogMapper;
|
||||
|
||||
public void createSystemExceptionLog(SystemExceptionLogCreateBO createBO) {
|
||||
SystemExceptionLogDO logDO = SystemExceptionLogConvert.INSTANCE.convert(createBO);
|
||||
systemExceptionLogMapper.insert(logDO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package cn.iocoder.mall.systemservice.service.systemlog;
|
||||
|
||||
import cn.iocoder.mall.systemservice.convert.systemlog.SystemLogConvert;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.AccessLogDO;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.AccessLogMapper;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.ExceptionLogMapper;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.AccessLogAddBO;
|
||||
import cn.iocoder.mall.systemservice.service.systemlog.bo.ExceptionLogAddBO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SystemLogService {
|
||||
|
||||
@Autowired
|
||||
private AccessLogMapper accessLogMapper;
|
||||
@Autowired
|
||||
private ExceptionLogMapper exceptionLogMapper;
|
||||
|
||||
public void addAccessLog(AccessLogAddBO accessLogAddBO) {
|
||||
AccessLogDO logDO = SystemLogConvert.INSTANCE.convert(accessLogAddBO);
|
||||
accessLogMapper.insert(logDO);
|
||||
}
|
||||
|
||||
public void addExceptionLog(ExceptionLogAddBO exceptionLogAddBO) {
|
||||
ExceptionLogDO logDO = SystemLogConvert.INSTANCE.convert(exceptionLogAddBO);
|
||||
exceptionLogMapper.insert(logDO);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SuppressWarnings("Duplicates")
|
||||
// public PageResult<AccessLogBO> getAccessLogPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
// PageResult<AccessLogBO> accessLogPageBOPageResult = SystemLogConvert.INSTANCE.convertPage(
|
||||
// accessLogMapper.selectPage(accessLogPageDTO)); // TODO FROM 芋艿 to 2447007062:可以考虑直接 return,简洁 + IDEA 不告警;
|
||||
// return accessLogPageBOPageResult;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package cn.iocoder.mall.systemservice.service.systemlog.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 系统访问日志 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SystemAccessLogBO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 链路追踪编号
|
||||
*/
|
||||
private String traceId;
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
private String applicationName;
|
||||
/**
|
||||
* 访问地址
|
||||
*/
|
||||
private String uri;
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private String queryString;
|
||||
/**
|
||||
* http 方法
|
||||
*/
|
||||
private String method;
|
||||
/**
|
||||
* userAgent
|
||||
*/
|
||||
private String userAgent;
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
private String ip;
|
||||
/**
|
||||
* 请求时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 响应时长 -- 毫秒级
|
||||
*/
|
||||
private Integer responseTime;
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
private Integer errorCode;
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String errorMessage;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -13,7 +12,7 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogAddBO implements Serializable {
|
||||
public class SystemAccessLogCreateBO {
|
||||
|
||||
/**
|
||||
* 账号编号
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.mall.systemservice.service.systemlog.bo;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统访问日志分页 BO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class SystemAccessLogPageBO extends PageParam {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private Integer userType;
|
||||
/**
|
||||
* 应用名
|
||||
*/
|
||||
private String applicationName;
|
||||
|
||||
}
|
||||
@@ -8,11 +8,11 @@ import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 异常日志添加 BO
|
||||
* 系统异常日志添加 BO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ExceptionLogAddBO {
|
||||
public class SystemExceptionLogCreateBO {
|
||||
|
||||
/**
|
||||
* 账号编号
|
||||
Reference in New Issue
Block a user