From 0657d7185cc29dfd2811758ccf3e2d3684606058 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Sat, 16 Dec 2023 10:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=93=81=E7=89=8C=E5=A2=9E?= =?UTF-8?q?=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CategoryBrandController.java | 29 +++++++++++++++---- .../cn/bunny/mapper/CategoryBrandMapper.java | 9 ++++++ .../bunny/service/CategoryBrandService.java | 9 ++++++ .../impl/CategoryBrandServiceImpl.java | 19 ++++++++++++ .../mapper/brand/CategoryBrandMapper.xml | 24 +++++++++++++++ 5 files changed, 85 insertions(+), 5 deletions(-) diff --git a/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java b/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java index 862e4b0..486055c 100644 --- a/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java +++ b/spzx-manager/src/main/java/cn/bunny/controller/CategoryBrandController.java @@ -10,10 +10,7 @@ import com.github.pagehelper.PageInfo; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @Tag(name = "分类品牌列表接口") @RestController @@ -22,12 +19,34 @@ public class CategoryBrandController { @Autowired private CategoryBrandService categoryBrandService; + + @Operation(summary = "删除分类品牌", description = "删除分类品牌") + @DeleteMapping("/deleteById/{id}") + private Result deleteById(@PathVariable Long id) { + categoryBrandService.deleteById(id); + return Result.build(null, ResultCodeEnum.SUCCESS); + } + + @Operation(summary = "分类品牌修改功能", description = "分类品牌修改功能") + @PutMapping("updateById") + public Result updateById(@RequestBody CategoryBrand categoryBrand) { + categoryBrandService.updateById(categoryBrand); + return Result.build(null, ResultCodeEnum.SUCCESS); + } + + @Operation(summary = "分类品牌添加", description = "分类品牌添加") + @PostMapping("save") + public Result save(@RequestBody CategoryBrand categoryBrand) { + categoryBrandService.save(categoryBrand); + return Result.build(null, ResultCodeEnum.SUCCESS); + } + @Operation(summary = "分类品牌条件分页查询", description = "分类品牌条件分页查询") @GetMapping("/{page}/{limit}") public Result findByPage(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, CategoryBrandDto categoryBrandDto) { - PageInfo categoryBrandPageInfo = categoryBrandService.findByPage(page, limit,categoryBrandDto); + PageInfo categoryBrandPageInfo = categoryBrandService.findByPage(page, limit, categoryBrandDto); return Result.build(categoryBrandPageInfo, ResultCodeEnum.SUCCESS); } } diff --git a/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java b/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java index bb1c41c..d2fecba 100644 --- a/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java +++ b/spzx-manager/src/main/java/cn/bunny/mapper/CategoryBrandMapper.java @@ -10,4 +10,13 @@ import java.util.List; public interface CategoryBrandMapper { // 分类品牌条件分页查询 public List findByPage(CategoryBrandDto categoryBrandDto); + + // 分类品牌添加 + void save(CategoryBrand categoryBrand); + + // 品牌修改功能 + void updateById(CategoryBrand categoryBrand); + + // 删除分类品牌 + void deleteById(Long id); } 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 febc00e..bf26f5f 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java +++ b/spzx-manager/src/main/java/cn/bunny/service/CategoryBrandService.java @@ -7,4 +7,13 @@ import com.github.pagehelper.PageInfo; public interface CategoryBrandService { // 分类品牌条件分页查询 PageInfo findByPage(Integer page, Integer limit, CategoryBrandDto categoryBrandDto); + + // 分类品牌添加 + void save(CategoryBrand categoryBrand); + + // 品牌修改功能 + void updateById(CategoryBrand categoryBrand); + + // 删除分类品牌 + void deleteById(Long id); } diff --git a/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java b/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java index ddd6c54..69d0e34 100644 --- a/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java +++ b/spzx-manager/src/main/java/cn/bunny/service/impl/CategoryBrandServiceImpl.java @@ -25,4 +25,23 @@ public class CategoryBrandServiceImpl implements CategoryBrandService { return new PageInfo(categoryBrandDtoList); } + + + // 分类品牌添加 + @Override + public void save(CategoryBrand categoryBrand) { + categoryBrandMapper.save(categoryBrand); + } + + // 品牌修改功能 + @Override + public void updateById(CategoryBrand categoryBrand) { + categoryBrandMapper.updateById(categoryBrand); + } + + // 删除分类品牌 + @Override + public void deleteById(Long id) { + categoryBrandMapper.deleteById(id); + } } diff --git a/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml b/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml index 25400e6..8fe1282 100644 --- a/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml +++ b/spzx-manager/src/main/resources/mapper/brand/CategoryBrandMapper.xml @@ -8,6 +8,30 @@ id,brand_id,category_id,create_time,update_time,is_deleted + + + insert into category_brand (id, brand_id, category_id, create_time, update_time, is_deleted) + values (#{id},#{brandId},#{categoryId},now(),now(),0); + + + + + update category_brand set + + brand_id=#{brandId} + + + category_id=#{categoryId} + + update_timen==now() + where id=#{id} + + + + + update category_brand set update_time=now(),is_deleted=1 where id=#{id} + +