mirror of https://gitee.com/stylefeng/roses
【8.0】【log】更新业务日志详情表
parent
9504ac90aa
commit
89803da797
|
@ -32,7 +32,6 @@ import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusiness;
|
|||
import cn.stylefeng.roses.kernel.log.business.service.SysLogBusinessService;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.BizLog;
|
||||
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
|
@ -116,9 +115,6 @@ public class BusinessLogRecordAop implements Ordered {
|
|||
// 设置业务日志的类型编码
|
||||
sysLogBusiness.setLogTypeCode(bizLog.logTypeCode());
|
||||
|
||||
// 设置调用链id
|
||||
sysLogBusiness.setTraceId(IdWorker.getId());
|
||||
|
||||
// 设置请求的URL
|
||||
String servletPath = HttpServletUtil.getRequest().getServletPath();
|
||||
sysLogBusiness.setRequestUrl(servletPath);
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusinessContent;
|
||||
import cn.stylefeng.roses.kernel.log.business.pojo.request.SysLogBusinessContentRequest;
|
||||
import cn.stylefeng.roses.kernel.log.business.service.SysLogBusinessContentService;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 业务日志详情记录控制器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "业务日志详情记录控制器")
|
||||
public class SysLogBusinessContentController {
|
||||
|
||||
@Resource
|
||||
private SysLogBusinessContentService sysLogBusinessContentService;
|
||||
|
||||
/**
|
||||
* 分页获取业务日志详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@GetResource(name = "分页获取业务日志详情", path = "/sysLogBusinessContent/page")
|
||||
public ResponseData<PageResult<SysLogBusinessContent>> page(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
return new SuccessResponseData<>(sysLogBusinessContentService.findPage(sysLogBusinessContentRequest));
|
||||
}
|
||||
|
||||
}
|
|
@ -8,15 +8,19 @@ import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务日志记录控制器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "业务日志记录")
|
||||
|
@ -26,12 +30,70 @@ public class SysLogBusinessController {
|
|||
private SysLogBusinessService sysLogBusinessService;
|
||||
|
||||
/**
|
||||
* 查询业务日志列表(带分页)
|
||||
* 添加
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@GetResource(name = "查询业务日志列表(带分页)", path = "/sysLogBusiness/page")
|
||||
@PostResource(name = "添加", path = "/sysLogBusiness/add")
|
||||
public ResponseData<SysLogBusiness> add(@RequestBody @Validated(SysLogBusinessRequest.add.class) SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
sysLogBusinessService.add(sysLogBusinessRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@PostResource(name = "删除", path = "/sysLogBusiness/delete")
|
||||
public ResponseData<?> delete(@RequestBody @Validated(SysLogBusinessRequest.delete.class) SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
sysLogBusinessService.del(sysLogBusinessRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@PostResource(name = "编辑", path = "/sysLogBusiness/edit")
|
||||
public ResponseData<?> edit(@RequestBody @Validated(SysLogBusinessRequest.edit.class) SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
sysLogBusinessService.edit(sysLogBusinessRequest);
|
||||
return new SuccessResponseData<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@GetResource(name = "查看详情", path = "/sysLogBusiness/detail")
|
||||
public ResponseData<SysLogBusiness> detail(@Validated(SysLogBusinessRequest.detail.class) SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
return new SuccessResponseData<>(sysLogBusinessService.detail(sysLogBusinessRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@GetResource(name = "获取列表", path = "/sysLogBusiness/list")
|
||||
public ResponseData<List<SysLogBusiness>> list(SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
return new SuccessResponseData<>(sysLogBusinessService.findList(sysLogBusinessRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@GetResource(name = "分页查询", path = "/sysLogBusiness/page")
|
||||
public ResponseData<PageResult<SysLogBusiness>> page(SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
return new SuccessResponseData<>(sysLogBusinessService.findPage(sysLogBusinessRequest));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import lombok.EqualsAndHashCode;
|
|||
* 业务日志记录实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@TableName("sys_log_business")
|
||||
@Data
|
||||
|
@ -41,20 +41,6 @@ public class SysLogBusiness extends BaseEntity {
|
|||
@ChineseDescription("日志的标题,摘要信息")
|
||||
private String logTitle;
|
||||
|
||||
/**
|
||||
* 日志记录的内容
|
||||
*/
|
||||
@TableField("log_content")
|
||||
@ChineseDescription("日志记录的内容")
|
||||
private String logContent;
|
||||
|
||||
/**
|
||||
* 调用链唯一id,一个id代表一次接口调用
|
||||
*/
|
||||
@TableField("trace_id")
|
||||
@ChineseDescription("调用链唯一id,一个id代表一次接口调用")
|
||||
private Long traceId;
|
||||
|
||||
/**
|
||||
* 当前用户请求的url
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 业务日志记录实例类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@TableName("sys_log_business_content")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysLogBusinessContent extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "content_id", type = IdType.ASSIGN_ID)
|
||||
@ChineseDescription("主键")
|
||||
private Long contentId;
|
||||
|
||||
/**
|
||||
* 对应主表主键id
|
||||
*/
|
||||
@TableField("business_log_id")
|
||||
@ChineseDescription("对应主表主键id")
|
||||
private Long businessLogId;
|
||||
|
||||
/**
|
||||
* 日志记录的内容
|
||||
*/
|
||||
@TableField("log_content")
|
||||
@ChineseDescription("日志记录的内容")
|
||||
private String logContent;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 业务日志记录异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@Getter
|
||||
public enum SysLogBusinessContentExceptionEnum implements AbstractExceptionEnum {
|
||||
|
||||
/**
|
||||
* 查询结果不存在
|
||||
*/
|
||||
SYS_LOG_BUSINESS_CONTENT_NOT_EXISTED(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10001", "查询结果不存在");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private final String errorCode;
|
||||
|
||||
/**
|
||||
* 提示用户信息
|
||||
*/
|
||||
private final String userTip;
|
||||
|
||||
SysLogBusinessContentExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import lombok.Getter;
|
|||
* 业务日志记录异常相关枚举
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@Getter
|
||||
public enum SysLogBusinessExceptionEnum implements AbstractExceptionEnum {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.mp.injector.CustomBaseMapper;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusinessContent;
|
||||
|
||||
/**
|
||||
* 业务日志记录 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
public interface SysLogBusinessContentMapper extends CustomBaseMapper<SysLogBusinessContent> {
|
||||
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.mp.injector.CustomBaseMapper;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusiness;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 业务日志记录 Mapper 接口
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
public interface SysLogBusinessMapper extends CustomBaseMapper<SysLogBusiness> {
|
||||
public interface SysLogBusinessMapper extends BaseMapper<SysLogBusiness> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.log.business.mapper.SysLogBusinessContentMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,39 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.pojo.request;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 业务日志记录封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysLogBusinessContentRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "主键不能为空", groups = {edit.class, delete.class})
|
||||
@ChineseDescription("主键")
|
||||
private Long contentId;
|
||||
|
||||
/**
|
||||
* 对应主表主键id
|
||||
*/
|
||||
@ChineseDescription("对应主表主键id")
|
||||
private Long businessLogId;
|
||||
|
||||
/**
|
||||
* 日志记录的内容
|
||||
*/
|
||||
@ChineseDescription("日志记录的内容")
|
||||
private String logContent;
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull;
|
|||
* 业务日志记录封装类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
@ -36,18 +36,6 @@ public class SysLogBusinessRequest extends BaseRequest {
|
|||
@ChineseDescription("日志的标题,摘要信息")
|
||||
private String logTitle;
|
||||
|
||||
/**
|
||||
* 日志记录的内容
|
||||
*/
|
||||
@ChineseDescription("日志记录的内容")
|
||||
private String logContent;
|
||||
|
||||
/**
|
||||
* 调用链唯一id,一个id代表一次接口调用
|
||||
*/
|
||||
@ChineseDescription("调用链唯一id,一个id代表一次接口调用")
|
||||
private Long traceId;
|
||||
|
||||
/**
|
||||
* 当前用户请求的url
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusinessContent;
|
||||
import cn.stylefeng.roses.kernel.log.business.pojo.request.SysLogBusinessContentRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务日志记录 服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
public interface SysLogBusinessContentService extends IService<SysLogBusinessContent> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param sysLogBusinessContentRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
void add(SysLogBusinessContentRequest sysLogBusinessContentRequest);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param sysLogBusinessContentRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
void del(SysLogBusinessContentRequest sysLogBusinessContentRequest);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysLogBusinessContentRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
void edit(SysLogBusinessContentRequest sysLogBusinessContentRequest);
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param sysLogBusinessContentRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
SysLogBusinessContent detail(SysLogBusinessContentRequest sysLogBusinessContentRequest);
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param sysLogBusinessContentRequest 请求参数
|
||||
* @return List<SysLogBusinessContent> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
List<SysLogBusinessContent> findList(SysLogBusinessContentRequest sysLogBusinessContentRequest);
|
||||
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param sysLogBusinessContentRequest 请求参数
|
||||
* @return PageResult<SysLogBusinessContent> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
PageResult<SysLogBusinessContent> findPage(SysLogBusinessContentRequest sysLogBusinessContentRequest);
|
||||
|
||||
/**
|
||||
* 批量保存业务日志详情
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/7/21 19:07
|
||||
*/
|
||||
void batchSaveContent(List<SysLogBusinessContent> sysLogBusinessContentList);
|
||||
|
||||
}
|
|
@ -11,63 +11,63 @@ import java.util.List;
|
|||
* 业务日志记录 服务类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
public interface SysLogBusinessService extends IService<SysLogBusiness> {
|
||||
|
||||
/**
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
void add(SysLogBusinessRequest sysLogBusinessRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
void del(SysLogBusinessRequest sysLogBusinessRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
void edit(SysLogBusinessRequest sysLogBusinessRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
SysLogBusiness detail(SysLogBusinessRequest sysLogBusinessRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @return List<SysLogBusiness> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
List<SysLogBusiness> findList(SysLogBusinessRequest sysLogBusinessRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @param sysLogBusinessRequest 请求参数
|
||||
* @return PageResult<SysLogBusiness> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
PageResult<SysLogBusiness> findPage(SysLogBusinessRequest sysLogBusinessRequest);
|
||||
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package cn.stylefeng.roses.kernel.log.business.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusinessContent;
|
||||
import cn.stylefeng.roses.kernel.log.business.enums.SysLogBusinessContentExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.log.business.mapper.SysLogBusinessContentMapper;
|
||||
import cn.stylefeng.roses.kernel.log.business.pojo.request.SysLogBusinessContentRequest;
|
||||
import cn.stylefeng.roses.kernel.log.business.service.SysLogBusinessContentService;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务日志记录业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@Service
|
||||
public class SysLogBusinessContentServiceImpl extends ServiceImpl<SysLogBusinessContentMapper, SysLogBusinessContent> implements
|
||||
SysLogBusinessContentService {
|
||||
|
||||
@Override
|
||||
public void add(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
SysLogBusinessContent sysLogBusinessContent = new SysLogBusinessContent();
|
||||
BeanUtil.copyProperties(sysLogBusinessContentRequest, sysLogBusinessContent);
|
||||
this.save(sysLogBusinessContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
SysLogBusinessContent sysLogBusinessContent = this.querySysLogBusinessContent(sysLogBusinessContentRequest);
|
||||
this.removeById(sysLogBusinessContent.getContentId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
SysLogBusinessContent sysLogBusinessContent = this.querySysLogBusinessContent(sysLogBusinessContentRequest);
|
||||
BeanUtil.copyProperties(sysLogBusinessContentRequest, sysLogBusinessContent);
|
||||
this.updateById(sysLogBusinessContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysLogBusinessContent detail(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
return this.querySysLogBusinessContent(sysLogBusinessContentRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<SysLogBusinessContent> findPage(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
LambdaQueryWrapper<SysLogBusinessContent> wrapper = createWrapper(sysLogBusinessContentRequest);
|
||||
Page<SysLogBusinessContent> sysRolePage = this.page(PageFactory.defaultPage(), wrapper);
|
||||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSaveContent(List<SysLogBusinessContent> sysLogBusinessContentList) {
|
||||
this.getBaseMapper().insertBatchSomeColumn(sysLogBusinessContentList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysLogBusinessContent> findList(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
LambdaQueryWrapper<SysLogBusinessContent> wrapper = this.createWrapper(sysLogBusinessContentRequest);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
private SysLogBusinessContent querySysLogBusinessContent(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
SysLogBusinessContent sysLogBusinessContent = this.getById(sysLogBusinessContentRequest.getContentId());
|
||||
if (ObjectUtil.isEmpty(sysLogBusinessContent)) {
|
||||
throw new ServiceException(SysLogBusinessContentExceptionEnum.SYS_LOG_BUSINESS_CONTENT_NOT_EXISTED);
|
||||
}
|
||||
return sysLogBusinessContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建查询wrapper
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
private LambdaQueryWrapper<SysLogBusinessContent> createWrapper(SysLogBusinessContentRequest sysLogBusinessContentRequest) {
|
||||
LambdaQueryWrapper<SysLogBusinessContent> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
Long contentId = sysLogBusinessContentRequest.getContentId();
|
||||
Long businessLogId = sysLogBusinessContentRequest.getBusinessLogId();
|
||||
String logContent = sysLogBusinessContentRequest.getLogContent();
|
||||
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(contentId), SysLogBusinessContent::getContentId, contentId);
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(businessLogId), SysLogBusinessContent::getBusinessLogId, businessLogId);
|
||||
queryWrapper.like(ObjectUtil.isNotEmpty(logContent), SysLogBusinessContent::getLogContent, logContent);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,9 +6,11 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
|||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusiness;
|
||||
import cn.stylefeng.roses.kernel.log.business.entity.SysLogBusinessContent;
|
||||
import cn.stylefeng.roses.kernel.log.business.enums.SysLogBusinessExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.log.business.mapper.SysLogBusinessMapper;
|
||||
import cn.stylefeng.roses.kernel.log.business.pojo.request.SysLogBusinessRequest;
|
||||
import cn.stylefeng.roses.kernel.log.business.service.SysLogBusinessContentService;
|
||||
import cn.stylefeng.roses.kernel.log.business.service.SysLogBusinessService;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -16,6 +18,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -23,11 +26,14 @@ import java.util.List;
|
|||
* 业务日志记录业务实现层
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
@Service
|
||||
public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper, SysLogBusiness> implements SysLogBusinessService {
|
||||
|
||||
@Resource
|
||||
private SysLogBusinessContentService sysLogBusinessContentService;
|
||||
|
||||
@Override
|
||||
public void add(SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
SysLogBusiness sysLogBusiness = new SysLogBusiness();
|
||||
|
@ -67,15 +73,18 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
|
|||
return;
|
||||
}
|
||||
|
||||
List<SysLogBusiness> sysLogBusinesses = new ArrayList<>();
|
||||
for (String content : batchContentList) {
|
||||
SysLogBusiness sysLogBusiness = new SysLogBusiness();
|
||||
BeanUtil.copyProperties(context, sysLogBusiness);
|
||||
sysLogBusiness.setLogContent(content);
|
||||
sysLogBusinesses.add(sysLogBusiness);
|
||||
}
|
||||
// 先保存基础的日志信息
|
||||
this.save(context);
|
||||
|
||||
this.getBaseMapper().insertBatchSomeColumn(sysLogBusinesses);
|
||||
// 再保存详细的日志信息
|
||||
List<SysLogBusinessContent> sysLogBusinessContentList = new ArrayList<>();
|
||||
for (String content : batchContentList) {
|
||||
SysLogBusinessContent sysLogBusinessContent = new SysLogBusinessContent();
|
||||
sysLogBusinessContent.setBusinessLogId(context.getBusinessLogId());
|
||||
sysLogBusinessContent.setLogContent(content);
|
||||
sysLogBusinessContentList.add(sysLogBusinessContent);
|
||||
}
|
||||
this.sysLogBusinessContentService.batchSaveContent(sysLogBusinessContentList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,7 +97,7 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
|
|||
* 获取信息
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2023/07/21 15:00
|
||||
* @date 2023/07/21 19:02
|
||||
*/
|
||||
private SysLogBusiness querySysLogBusiness(SysLogBusinessRequest sysLogBusinessRequest) {
|
||||
SysLogBusiness sysLogBusiness = this.getById(sysLogBusinessRequest.getBusinessLogId());
|
||||
|
@ -111,15 +120,11 @@ public class SysLogBusinessServiceImpl extends ServiceImpl<SysLogBusinessMapper,
|
|||
String logTypeCode = sysLogBusinessRequest.getLogTypeCode();
|
||||
queryWrapper.eq(ObjectUtil.isNotEmpty(logTypeCode), SysLogBusiness::getLogTypeCode, logTypeCode);
|
||||
|
||||
// 根据调用链日志信息查询
|
||||
Long traceId = sysLogBusinessRequest.getTraceId();
|
||||
queryWrapper.eq(ObjectUtil.isNotNull(traceId), SysLogBusiness::getTraceId, traceId);
|
||||
|
||||
// 根据文本检索内容查询
|
||||
String searchText = sysLogBusinessRequest.getSearchText();
|
||||
if (ObjectUtil.isNotEmpty(searchText)) {
|
||||
queryWrapper.nested(wrap -> {
|
||||
wrap.like(SysLogBusiness::getLogTitle, searchText).or().like(SysLogBusiness::getLogContent, searchText);
|
||||
wrap.like(SysLogBusiness::getLogTitle, searchText).or().like(SysLogBusiness::getRequestUrl, searchText);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue