From bfee419d3c4dca669960645dedb7643a6b8853cb Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 3 Apr 2024 08:33:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/controller/BrandController.java | 29 ++++++++++++- .../controller/CategoryController.java | 12 ++++-- .../com/muyu/product/mapper/BrandMapper.java | 11 +++++ .../muyu/product/mapper/CategoryMapper.java | 1 + .../muyu/product/service/BrandService.java | 10 +++++ .../muyu/product/service/CategoryService.java | 2 + .../service/impl/BrandServiceImpl.java | 27 ++++++++++++ .../service/impl/CategoryServiceImpl.java | 5 +++ .../resources/mapper/product/BrandMapper.xml | 42 ++++++++++++++++++- .../mapper/product/CategoryMapper.xml | 5 +++ 10 files changed, 138 insertions(+), 6 deletions(-) diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandController.java index 8a31770..17ad392 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/BrandController.java @@ -1,10 +1,12 @@ package com.muyu.product.controller; +import com.muyu.common.core.domain.AjaxResult; +import com.muyu.product.domain.DTO.Brand; import com.muyu.product.service.BrandService; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @Author: wangxinyuan @@ -17,4 +19,27 @@ public class BrandController { @Autowired private BrandService brandService; + + + @PostMapping + @ApiOperation("品牌添加") + public AjaxResult insertBrand(@RequestBody Brand brand){ + Integer res=brandService.insertBrand(brand); + return AjaxResult.success(res==1?"添加成功":"添加失败"); + } + + @DeleteMapping("/{brandId}") + @ApiOperation("品牌删除") + public AjaxResult deleteBrand(@PathVariable Integer brandId){ + Integer res = brandService.deleteBrand(brandId); + return AjaxResult.success(res==1?"删除成功":"删除失败"); + } + + @PutMapping + @ApiOperation("品牌修改") + public AjaxResult updateBrand(@RequestBody Brand brand){ + Integer res = brandService.updateBrand(brand); + return AjaxResult.success(res==1?"修改成功":"修改失败"); + } + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryController.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryController.java index 31b1395..ddd5649 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryController.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/controller/CategoryController.java @@ -3,10 +3,9 @@ package com.muyu.product.controller; import com.muyu.common.core.domain.AjaxResult; import com.muyu.product.domain.DTO.Category; import com.muyu.product.service.CategoryService; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -27,4 +26,11 @@ public class CategoryController { Listlist=categoryService.queryCategory(); return AjaxResult.success(list); } + + @DeleteMapping("{categoryId}") + @ApiOperation("分类删除") + public AjaxResult deleteCategory(@PathVariable Integer categoryId){ + Integer res = categoryService.deleteCategory(categoryId); + return AjaxResult.success(res==1?"删除成功":"删除失败"); + } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/BrandMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/BrandMapper.java index 7047bca..36d5fdb 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/BrandMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/BrandMapper.java @@ -1,11 +1,22 @@ package com.muyu.product.mapper; +import com.muyu.product.domain.DTO.Brand; +import org.apache.ibatis.annotations.Mapper; + /** * @Author: wangxinyuan * @Date: 2024/4/2 19:51 */ + +@Mapper public interface BrandMapper { + Integer deleteBrand(Integer brandId); + Integer insertBrand(Brand brand); + + + + Integer updateBrand(Brand brand); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryMapper.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryMapper.java index 902a0fa..dfff3c2 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryMapper.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/mapper/CategoryMapper.java @@ -13,4 +13,5 @@ import java.util.List; public interface CategoryMapper { List queryCategory(); + Integer deleteCategory(Integer categoryId); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/BrandService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/BrandService.java index d86241a..e79eab9 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/BrandService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/BrandService.java @@ -1,8 +1,18 @@ package com.muyu.product.service; +import com.muyu.product.domain.DTO.Brand; + /** * @Author: wangxinyuan * @Date: 2024/4/2 19:51 */ public interface BrandService { + Integer insertBrand(Brand brand); + + Integer deleteBrand(Integer brandId); + + + + + Integer updateBrand(Brand brand); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryService.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryService.java index a7e949a..26ba8ca 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryService.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/CategoryService.java @@ -10,4 +10,6 @@ import java.util.List; */ public interface CategoryService { List queryCategory(); + + Integer deleteCategory(Integer categoryId); } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandServiceImpl.java index 389872a..631f4e2 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/BrandServiceImpl.java @@ -1,6 +1,10 @@ package com.muyu.product.service.impl; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.product.domain.DTO.Brand; +import com.muyu.product.mapper.BrandMapper; import com.muyu.product.service.BrandService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** @@ -9,4 +13,27 @@ import org.springframework.stereotype.Service; */ @Service public class BrandServiceImpl implements BrandService { + + @Autowired + private BrandMapper brandMapper; + @Override + public Integer insertBrand(Brand brand) { + brand.setCreateBy(SecurityUtils.getUsername()); + return brandMapper.insertBrand(brand); + } + + @Override + public Integer deleteBrand(Integer brandId) { + return brandMapper.deleteBrand(brandId); + } + + + + @Override + public Integer updateBrand(Brand brand) { + brand.setCreateBy(SecurityUtils.getUsername()); + return brandMapper.updateBrand(brand); + } + + } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryServiceImpl.java b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryServiceImpl.java index a46fa31..f44ec5e 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryServiceImpl.java +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/java/com/muyu/product/service/impl/CategoryServiceImpl.java @@ -21,4 +21,9 @@ public class CategoryServiceImpl implements CategoryService { public List queryCategory() { return categoryMapper.queryCategory(); } + + @Override + public Integer deleteCategory(Integer categoryId) { + return categoryMapper.deleteCategory(categoryId); + } } diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/BrandMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/BrandMapper.xml index 7ccb729..4ead7a6 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/BrandMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/BrandMapper.xml @@ -3,9 +3,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + INSERT INTO `product`.`t_product_brand` ( + `brand_name`, + `first_letter`, + `sort`, + `factory_status`, + `show_status`, + `product_count`, + `product_comment_count`, + `logo`, + `big_pic`, + `brand_story`, + `create_by`, + `create_time` + ) + VALUES + ( + #{brandName}, + #{firstLetter}, + #{sort}, + #{factoryStatus}, + #{showStatus}, + #{productCount}, + #{productCommentCount}, + #{logo}, + #{bigPic}, + #{brandStory}, + #{createBy}, + now() + ); + + + update t_product_brand set brand_name= #{brandName},first_letter=#{firstLetter},sort=#{sort},factory_status=#{factoryStatus} + ,show_status=#{showStatus},product_count=#{productCount},product_comment_count=#{productCommentCount},logo=#{logo}, + big_pic=#{bigPic},brand_story=#{brandStory},create_by=#{createBy},update_time=now() where id = #{id} + + + update t_product_brand set id_delete = 0 where id = #{id} + + + diff --git a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryMapper.xml b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryMapper.xml index 47f42b0..d52bbb9 100644 --- a/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryMapper.xml +++ b/muyu-modules/muyu-product/muyu-product-server/src/main/resources/mapper/product/CategoryMapper.xml @@ -9,6 +9,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ,product_unit,nav_status,show_status,sort,icon,keywords,description + + update t_product_category set id_delete = 0 where id = #{id} + + +