From f55f7ceb3f10e320728943b7a943fbf350d596db Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Sat, 16 Dec 2023 23:31:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/dataSources.local.xml | 1 - .idea/encodings.xml | 1 + .idea/inspectionProfiles/Project_Default.xml | 1 + .idea/uiDesigner.xml | 124 ++++++++++++++++++ .idea/workspace.xml | 47 +++++-- spzx-common/common-log/pom.xml | 46 +++++++ .../bunny/log/annotation/EnableLogAspect.java | 15 +++ .../java/cn/bunny/log/annotation/Log.java | 20 +++ .../java/cn/bunny/log/aspect/LogAspect.java | 40 ++++++ .../java/cn/bunny/log/enums/OperatorType.java | 7 + .../log/service/AsyncOperLogService.java | 8 ++ .../java/cn/bunny/log/utils/LogUtils.java | 61 +++++++++ spzx-common/pom.xml | 1 + spzx-manager/pom.xml | 7 + .../main/java/cn/bunny/MangerApplication.java | 2 + .../bunny/controller/OrderInfoController.java | 2 + .../cn/bunny/mapper/SysOperLogMapper.java | 11 ++ .../bunny/service/CategoryBrandService.java | 7 + .../service/impl/AsyncOperLogServiceImpl.java | 20 +++ .../resources/mapper/log/SysOperLogMapper.xml | 36 +++++ 20 files changed, 445 insertions(+), 12 deletions(-) create mode 100644 .idea/uiDesigner.xml create mode 100644 spzx-common/common-log/pom.xml create mode 100644 spzx-common/common-log/src/main/java/cn/bunny/log/annotation/EnableLogAspect.java create mode 100644 spzx-common/common-log/src/main/java/cn/bunny/log/annotation/Log.java create mode 100644 spzx-common/common-log/src/main/java/cn/bunny/log/aspect/LogAspect.java create mode 100644 spzx-common/common-log/src/main/java/cn/bunny/log/enums/OperatorType.java create mode 100644 spzx-common/common-log/src/main/java/cn/bunny/log/service/AsyncOperLogService.java create mode 100644 spzx-common/common-log/src/main/java/cn/bunny/log/utils/LogUtils.java create mode 100644 spzx-manager/src/main/java/cn/bunny/mapper/SysOperLogMapper.java create mode 100644 spzx-manager/src/main/java/cn/bunny/service/impl/AsyncOperLogServiceImpl.java create mode 100644 spzx-manager/src/main/resources/mapper/log/SysOperLogMapper.xml diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index 408a33c..f6abbf6 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -5,7 +5,6 @@ #@ ` - true master_key diff --git a/.idea/encodings.xml b/.idea/encodings.xml index ad50fd9..6dbb144 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,6 +1,7 @@ + diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 5afb336..ca22935 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -9,5 +9,6 @@ \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a7c58c5..7389f7c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,15 +4,27 @@ \ No newline at end of file diff --git a/spzx-manager/src/main/java/cn/bunny/MangerApplication.java b/spzx-manager/src/main/java/cn/bunny/MangerApplication.java index e4d73b3..a6e1970 100644 --- a/spzx-manager/src/main/java/cn/bunny/MangerApplication.java +++ b/spzx-manager/src/main/java/cn/bunny/MangerApplication.java @@ -1,5 +1,6 @@ package cn.bunny; +import cn.bunny.log.annotation.EnableLogAspect; import cn.bunny.properties.MinioProperties; import cn.bunny.properties.UserProperties; import org.springframework.boot.SpringApplication; @@ -7,6 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.scheduling.annotation.EnableScheduling; +@EnableLogAspect @SpringBootApplication @EnableConfigurationProperties(value = {UserProperties.class, MinioProperties.class}) @EnableScheduling diff --git a/spzx-manager/src/main/java/cn/bunny/controller/OrderInfoController.java b/spzx-manager/src/main/java/cn/bunny/controller/OrderInfoController.java index d6fee27..d916a90 100644 --- a/spzx-manager/src/main/java/cn/bunny/controller/OrderInfoController.java +++ b/spzx-manager/src/main/java/cn/bunny/controller/OrderInfoController.java @@ -4,6 +4,7 @@ import cn.bunny.common.spzx.model.dto.order.OrderStatisticsDto; import cn.bunny.common.spzx.model.vo.common.Result; import cn.bunny.common.spzx.model.vo.common.ResultCodeEnum; import cn.bunny.common.spzx.model.vo.order.OrderStatisticsVo; +import cn.bunny.log.annotation.Log; import cn.bunny.service.OrderInfoService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -19,6 +20,7 @@ public class OrderInfoController { @Autowired private OrderInfoService orderInfoService; + @Log(title = "统计查询接口", businessType = 1) @Operation(summary = "统计查询", description = "统计查询") @GetMapping("getOrderStatisticsData") public Result getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto) { diff --git a/spzx-manager/src/main/java/cn/bunny/mapper/SysOperLogMapper.java b/spzx-manager/src/main/java/cn/bunny/mapper/SysOperLogMapper.java new file mode 100644 index 0000000..166c014 --- /dev/null +++ b/spzx-manager/src/main/java/cn/bunny/mapper/SysOperLogMapper.java @@ -0,0 +1,11 @@ +package cn.bunny.mapper; + +import cn.bunny.common.spzx.model.entity.system.SysOperLog; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface SysOperLogMapper { + // 保存日志数据 + public void insert(SysOperLog sysOperLog); +} + diff --git a/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java b/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java index 0f8b9ec..df32b8b 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java +++ b/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java @@ -3,6 +3,7 @@ package cn.bunny.service; import cn.bunny.common.spzx.model.dto.product.CategoryBrandDto; import cn.bunny.common.spzx.model.entity.product.Brand; import cn.bunny.common.spzx.model.entity.product.CategoryBrand; +import cn.bunny.common.spzx.model.entity.system.SysOperLog; import com.github.pagehelper.PageInfo; import java.util.List; @@ -22,4 +23,10 @@ public interface CategoryBrandService { // 根据id查询对应商品数据 List findBrandByCategoryId(Long categoryId); + + interface AsyncOperLogService { + + // 保存日志数据 + public abstract void saveSysOperLog(SysOperLog sysOperLog) ; + } } diff --git a/spzx-manager/src/main/java/cn/bunny/service/impl/AsyncOperLogServiceImpl.java b/spzx-manager/src/main/java/cn/bunny/service/impl/AsyncOperLogServiceImpl.java new file mode 100644 index 0000000..03db5bc --- /dev/null +++ b/spzx-manager/src/main/java/cn/bunny/service/impl/AsyncOperLogServiceImpl.java @@ -0,0 +1,20 @@ +package cn.bunny.service.impl; + +import cn.bunny.common.spzx.model.entity.system.SysOperLog; +import cn.bunny.log.service.AsyncOperLogService; +import cn.bunny.mapper.SysOperLogMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class AsyncOperLogServiceImpl implements AsyncOperLogService { + @Autowired + private SysOperLogMapper sysOperLogMapper; + + + // 保存日志数据 + @Override + public void saveSysOperLog(SysOperLog sysOperLog) { + sysOperLogMapper.insert(sysOperLog); + } +} diff --git a/spzx-manager/src/main/resources/mapper/log/SysOperLogMapper.xml b/spzx-manager/src/main/resources/mapper/log/SysOperLogMapper.xml new file mode 100644 index 0000000..acecd09 --- /dev/null +++ b/spzx-manager/src/main/resources/mapper/log/SysOperLogMapper.xml @@ -0,0 +1,36 @@ + + + + + + + + insert into sys_oper_log ( + id, + title, + method, + request_method, + operator_type, + oper_name, + oper_url, + oper_ip, + oper_param, + json_result, + status, + error_msg + ) values ( + #{id}, + #{title}, + #{method}, + #{requestMethod}, + #{operatorType}, + #{operName}, + #{operUrl}, + #{operIp}, + #{operParam}, + #{jsonResult}, + #{status}, + #{errorMsg} + ) + +