From 2432594a4d11b47a503795349defa31872f85789 Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期三, 04 十二月 2024 12:33:39 +0800
Subject: [PATCH] 操作日志

---
 src/main/java/com/mzl/flower/web/flower/FlowerCategoryController.java |   49 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/mzl/flower/web/flower/FlowerCategoryController.java b/src/main/java/com/mzl/flower/web/flower/FlowerCategoryController.java
index e40416e..46f70a4 100644
--- a/src/main/java/com/mzl/flower/web/flower/FlowerCategoryController.java
+++ b/src/main/java/com/mzl/flower/web/flower/FlowerCategoryController.java
@@ -1,14 +1,16 @@
 package com.mzl.flower.web.flower;
 
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.mzl.flower.base.BaseController;
 import com.mzl.flower.base.R;
 import com.mzl.flower.base.ReturnDataDTO;
+import com.mzl.flower.base.annotation.OperationLog;
 import com.mzl.flower.dto.request.flower.FlowerCategoryCreateDTO;
 import com.mzl.flower.dto.request.flower.FlowerCategoryQueryDTO;
 import com.mzl.flower.dto.request.flower.FlowerCategoryUpdateDTO;
 import com.mzl.flower.dto.response.flower.FlowerCategoryDTO;
 import com.mzl.flower.dto.response.flower.FlowerCategoryTreeDTO;
+import com.mzl.flower.entity.flower.FlowerCategory;
+import com.mzl.flower.entity.log.OperationRecord;
 import com.mzl.flower.service.flower.FlowerCategoryService;
 import com.mzl.flower.service.flower.FlowerService;
 import io.swagger.annotations.Api;
@@ -18,6 +20,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
+import org.springframework.util.StringUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -38,17 +41,33 @@
     private FlowerService flowerService;
 
     @PostMapping("/tree/new")
+    @OperationLog(value = "新增商品分类",type = "flower_category")
     @ApiOperation(value = "新增商品分类")
     public ResponseEntity<ReturnDataDTO> addCategory(@RequestBody FlowerCategoryCreateDTO dto) {
-        return returnData(R.SUCCESS.getCode(), categoryService.addCategory(dto));
+        String content = "";
+        if (StringUtils.isEmpty(dto.getParentId())) {
+            content = "新增商品分类:分类名称:【" + dto.getName() + "】,等级:【" + dto.getLevelLimit() + "】";
+        } else {
+            content = "新增商品分类:上级分类id:【" + dto.getParentId() + "】分类名称:【" + dto.getName() + "】,等级:【" + dto.getLevelLimit() + "】";
+        }
+        OperationRecord operationRecord = getOperationRecord(content);
+        return returnData(R.SUCCESS.getCode(), categoryService.addCategory(dto), operationRecord);
     }
 
     @PostMapping("/tree/edit")
+    @OperationLog(value = "编辑商品分类",type = "flower_category")
     @ApiOperation(value = "编辑商品分类")
     public ResponseEntity<ReturnDataDTO> updateCategory(@RequestBody FlowerCategoryUpdateDTO dto) {
         Long category = categoryService.updateCategory(dto);
         flowerService.updateCategoryInfo(category);
-        return returnData(R.SUCCESS.getCode(), category);
+        String content = "";
+        if (StringUtils.isEmpty(dto.getParentId())) {
+            content = "编辑商品分类:分类名称:【" + dto.getName() + "】,等级:【" + dto.getLevelLimit() + "】";
+        } else {
+            content = "编辑商品分类:上级分类id:【" + dto.getParentId() + "】分类名称:【" + dto.getName() + "】,等级:【" + dto.getLevelLimit() + "】";
+        }
+        OperationRecord operationRecord = getOperationRecord(content);
+        return returnData(R.SUCCESS.getCode(), category, operationRecord);
     }
 
     @GetMapping("/tree/view")
@@ -73,33 +92,51 @@
     }
 
     @GetMapping("/tree/delete")
+    @OperationLog(value = "删除商品分类",type = "flower_category")
     @ApiOperation(value = "删除商品分类")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "商品分类id", required = true, dataType = "Long", paramType = "query")
     })
     public ResponseEntity<ReturnDataDTO<?>> deleteCategory(Long id){
+        FlowerCategory flowerCategory = categoryService.selectCategoryById(id);
         categoryService.deleteCategory(id);
-        return returnData(R.SUCCESS.getCode(), null);
+        String content = "";
+        if (StringUtils.isEmpty(flowerCategory.getParentId())) {
+            content = "删除商品分类id:【" + id + "】,分类名称:【" + flowerCategory.getName() + "】,等级:【" + flowerCategory.getLevelLimit() + "】";
+        } else {
+            content = "删除商品分类id:【" + id + "】,上级分类id:【" + flowerCategory.getParentId() + "】,分类名称:【" + flowerCategory.getName() + "】,等级:【" + flowerCategory.getLevelLimit() + "】";
+        }
+        OperationRecord operationRecord = getOperationRecord(content);
+        return returnData(R.SUCCESS.getCode(), null, operationRecord);
     }
 
     @GetMapping("/tree/shown")
+    @OperationLog(value = "显示商品分类",type = "flower_category")
     @ApiOperation(value = "显示商品分类")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "商品分类id", required = true, dataType = "Long", paramType = "query")
     })
     public ResponseEntity<ReturnDataDTO<?>> showCategory(Long id){
         categoryService.setCategoryShown(id, true);
-        return returnData(R.SUCCESS.getCode(), null);
+        FlowerCategory flowerCategory = categoryService.selectCategoryById(id);
+        String content = "显示商品分类id:【" + id + "】,分类名称:【" + flowerCategory.getName() + "】,等级:【" + flowerCategory.getLevelLimit() + "】";
+        OperationRecord operationRecord = getOperationRecord(content);
+        return returnData(R.SUCCESS.getCode(), null, operationRecord);
+
     }
 
     @GetMapping("/tree/hidden")
+    @OperationLog(value = "隐藏商品分类",type = "flower_category")
     @ApiOperation(value = "隐藏商品分类")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "商品分类id", required = true, dataType = "Long", paramType = "query")
     })
     public ResponseEntity<ReturnDataDTO<?>> hideCategory(Long id){
         categoryService.setCategoryShown(id, false);
-        return returnData(R.SUCCESS.getCode(), null);
+        FlowerCategory flowerCategory = categoryService.selectCategoryById(id);
+        String content = "隐藏商品分类id:【" + id + "】,分类名称:【" + flowerCategory.getName() + "】,等级:【" + flowerCategory.getLevelLimit() + "】";
+        OperationRecord operationRecord = getOperationRecord(content);
+        return returnData(R.SUCCESS.getCode(), null, operationRecord);
     }
 
 }

--
Gitblit v1.9.3