From 6c823dd44dbde79f008001a2a11e7bf9bc6bf8cc Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期三, 04 十二月 2024 18:15:44 +0800 Subject: [PATCH] fix:合伙人列表操作日志 --- src/main/java/com/mzl/flower/web/flower/FlowerCategoryController.java | 61 +++++++++++++++++++++++++++--- 1 files changed, 55 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 9fca3fc..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,15 +1,18 @@ 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; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -17,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.*; @@ -33,16 +37,37 @@ @Autowired private FlowerCategoryService categoryService; + @Autowired + 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) { - return returnData(R.SUCCESS.getCode(), categoryService.updateCategory(dto)); + Long category = categoryService.updateCategory(dto); + flowerService.updateCategoryInfo(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") @@ -60,34 +85,58 @@ return returnData(R.SUCCESS.getCode(), categoryService.selectCategoryTree(dto)); } + @GetMapping("/list") + @ApiOperation(value = "获取商品分类列表") + public ResponseEntity<ReturnDataDTO<List<FlowerCategoryTreeDTO>>> selectCategoryList(FlowerCategoryQueryDTO dto){ + return returnData(R.SUCCESS.getCode(), categoryService.selectCategoryList(dto)); + } + @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