Skip to content

Commit

Permalink
商品属性管理
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxianzi-99 committed Jan 22, 2025
1 parent 47bc68e commit fd10a24
Show file tree
Hide file tree
Showing 23 changed files with 501 additions and 6 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
### 基础功能

1. 角色管理、用户管理、菜单管理

2. 商品管理、品牌管理、分类管理
2.
2. 商品管理、品牌管理、分类管理

### 拓展功能

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
package com.manager.controller;

import com.github.pagehelper.PageInfo;
import com.manager.service.CategoryBrandService;
import com.model.dto.product.CategoryBrandDto;
import com.model.entity.product.CategoryBrand;
import com.model.vo.common.Result;
import com.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/20
**/
@RestController
@RequestMapping("/admin/product/categoryBrand")
public class CategoryBrandController {
@Autowired
private CategoryBrandService categoryBrandService;

@GetMapping("/list/{pageNum}/{pageSize}")
public Result<PageInfo<CategoryBrand>> listCategoryBrand(@PathVariable("pageNum") Integer pageNum,
@PathVariable("pageSize") Integer pageSize,
CategoryBrandDto categoryBrandDto) {
PageInfo<CategoryBrand> categoryBrandPageInfo = categoryBrandService.listCategoryBrand(pageNum, pageSize, categoryBrandDto);
return Result.build(categoryBrandPageInfo, ResultCodeEnum.SUCCESS);
}
@PostMapping("/save")
public Result save(@RequestBody CategoryBrand categoryBrand) {
categoryBrandService.save(categoryBrand);
return Result.build(null,ResultCodeEnum.SUCCESS);
}
@PutMapping("/update")
public Result update(@RequestBody CategoryBrand categoryBrand) {
categoryBrandService.update(categoryBrand);
return Result.build(null,ResultCodeEnum.SUCCESS);
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Long id) {
categoryBrandService.delete(id);
return Result.build(null,ResultCodeEnum.SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.manager.controller;

import com.github.pagehelper.PageInfo;
import com.manager.service.ProductSpecService;
import com.model.entity.product.ProductSpec;
import com.model.vo.common.Result;
import com.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/21
**/
@RestController
@RequestMapping("/admin/product/productSpec")
public class ProductSpecController {
@Autowired
ProductSpecService productSpecService;
@GetMapping("/listByPage/{pageNum}/{pageSize}")
public Result<PageInfo<ProductSpec>> listByPage(@PathVariable("pageNum") Integer pageNum,
@PathVariable("pageSize") Integer pageSize){
PageInfo<ProductSpec> productSpecPageInfo = productSpecService.listByPage(pageNum,pageSize);
return Result.build(productSpecPageInfo, ResultCodeEnum.SUCCESS);
}
@PostMapping("/save")
public Result saveProductSpec(@RequestBody ProductSpec productSpec) {
productSpecService.saveProductSpec(productSpec);
return Result.build(null,ResultCodeEnum.SUCCESS);
}
@PutMapping("/updateById")
public Result updateProductSpec( @RequestBody ProductSpec productSpec) {
productSpecService.updateProductSpec(productSpec);
return Result.build(null,ResultCodeEnum.SUCCESS);
}
@DeleteMapping("/deleteById/{id}")
public Result deleteProductSpec(@PathVariable("id") Long id) {
productSpecService.deleteProductSpec(id);
return Result.build(null,ResultCodeEnum.SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.manager.controller;

import com.github.pagehelper.PageInfo;
import com.manager.service.ProductService;
import com.model.dto.product.ProductDto;
import com.model.entity.product.Product;
import com.model.vo.common.Result;
import com.model.vo.common.ResultCodeEnum;
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;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/22
**/
@RestController
@RequestMapping("/admin/product/product")
public class productController {
@Autowired
private ProductService productService;
@GetMapping("/listByPage/{pageNum}/{pageSize}")
public Result<PageInfo<Product>> listByPage(@PathVariable("pageNum") Integer pageNum,
@PathVariable("pageSize") Integer pageSize,
ProductDto productDto){
PageInfo<Product> productPageInfo =productService.listByPage(pageNum,pageSize,productDto);
return Result.build(productPageInfo, ResultCodeEnum.SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.manager.mapper;

import com.model.dto.product.CategoryBrandDto;
import com.model.entity.product.CategoryBrand;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/20
**/
@Mapper
public interface CategoryBrandMapper {
List<CategoryBrand> listCategoryBrand(CategoryBrandDto categoryBrandDto);

void save(CategoryBrand categoryBrand);

void update(CategoryBrand categoryBrand);

void delete(Long id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.manager.mapper;

import com.model.dto.product.ProductDto;
import com.model.entity.product.Product;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/22
**/
@Mapper
public interface ProductMapper {
List<Product> listByPage(ProductDto productDto);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.manager.mapper;

import com.model.entity.product.ProductSpec;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/21
**/
@Mapper
public interface ProductSpecMapper {
List<ProductSpec> listByPage();

void saveProductSpec(ProductSpec productSpec);

void updateProductSpec(ProductSpec productSpec);

void deleteProductSpec(Long id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.manager.service;

import com.github.pagehelper.PageInfo;
import com.model.dto.product.CategoryBrandDto;
import com.model.entity.product.CategoryBrand;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/20
**/
public interface CategoryBrandService {

PageInfo<CategoryBrand> listCategoryBrand(Integer pageNum, Integer pageSize, CategoryBrandDto categoryBrandDto);

void save(CategoryBrand categoryBrand);

void update(CategoryBrand categoryBrand);

void delete(Long id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.manager.service;

import com.github.pagehelper.PageInfo;
import com.model.dto.product.ProductDto;
import com.model.entity.product.Product;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/22
**/
public interface ProductService {
PageInfo<Product> listByPage(Integer pageNum, Integer pageSize, ProductDto productDto);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.manager.service;

import com.github.pagehelper.PageInfo;
import com.model.entity.product.ProductSpec;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/21
**/
public interface ProductSpecService {
PageInfo<ProductSpec> listByPage(Integer pageNum, Integer pageSize);

void saveProductSpec(ProductSpec productSpec);

void updateProductSpec(ProductSpec productSpec);

void deleteProductSpec(Long id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.manager.mapper.CategoryBrandMapper;
import com.manager.service.CategoryBrandService;
import com.model.dto.product.CategoryBrandDto;
import com.model.entity.product.CategoryBrand;
import com.model.vo.common.ResultCodeEnum;
import com.service.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/20
**/
@Service
public class CategoryBrandServiceImpl implements CategoryBrandService {
@Autowired
private CategoryBrandMapper categoryBrandMapper;
@Override
public PageInfo<CategoryBrand> listCategoryBrand(Integer pageNum, Integer pageSize, CategoryBrandDto categoryBrandDto) {
PageHelper.startPage(pageNum,pageSize);
List<CategoryBrand> categoryBrands = categoryBrandMapper.listCategoryBrand(categoryBrandDto);
PageInfo<CategoryBrand> pageInfo = new PageInfo(categoryBrands);
return pageInfo;
}

@Override
public void save(CategoryBrand categoryBrand) {
CategoryBrandDto categoryBrandDto = new CategoryBrandDto();
categoryBrandDto.setBrandId(categoryBrand.getBrandId());
categoryBrandDto.setCategoryId(categoryBrand.getCategoryId());
List<CategoryBrand> categoryBrands = categoryBrandMapper.listCategoryBrand(categoryBrandDto);
if(!categoryBrands.isEmpty()) {
throw new BusinessException(ResultCodeEnum.CATEGOREBRAND_IS_EXISTS);
}
categoryBrandMapper.save(categoryBrand);
}

@Override
public void update(CategoryBrand categoryBrand) {
categoryBrandMapper.update(categoryBrand);
}

@Override
public void delete(Long id) {
categoryBrandMapper.delete(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.manager.mapper.ProductMapper;
import com.manager.service.ProductService;
import com.model.dto.product.ProductDto;
import com.model.entity.product.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/22
**/
@Service
public class ProductServiceImpl implements ProductService {
@Autowired
ProductMapper productMapper;
@Override
public PageInfo<Product> listByPage(Integer pageNum, Integer pageSize, ProductDto productDto) {
PageHelper.startPage(pageNum,pageSize);
List<Product> productList = productMapper.listByPage(productDto);
PageInfo<Product> productPageInfo =new PageInfo(productList);
return productPageInfo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.manager.mapper.ProductSpecMapper;
import com.manager.service.ProductSpecService;
import com.model.entity.product.ProductSpec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 帕斯卡的芦苇
* @date 2025/1/21
**/
@Service
public class ProductSpecServiceImpl implements ProductSpecService {
@Autowired
ProductSpecMapper productSpecMapper;

@Override
public PageInfo<ProductSpec> listByPage(Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum,pageSize);
List<ProductSpec> productSpecList = productSpecMapper.listByPage();
PageInfo<ProductSpec> productSpecPageInfo =new PageInfo(productSpecList);
return productSpecPageInfo;
}

@Override
public void saveProductSpec(ProductSpec productSpec) {
productSpecMapper.saveProductSpec(productSpec);
}

@Override
public void updateProductSpec(ProductSpec productSpec) {
productSpecMapper.updateProductSpec(productSpec);
}

@Override
public void deleteProductSpec(Long id) {
productSpecMapper.deleteProductSpec(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.manager.service.impl;

import com.manager.helper.MenuHelper;
import com.manager.util.MenuHelper;
import com.manager.mapper.SysMenuMapper;
import com.manager.service.SysMenuService;
import com.model.dto.system.SysMenu;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.manager.helper;
package com.manager.util;

import com.model.dto.system.SysMenu;
import com.model.vo.system.SysMenuVo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</sql>
<update id="update">
update brand set
<if test="name != null">name = #{name}name = #{name},</if>
<if test="name != null">name = #{name},</if>
<if test="logo != null">logo = #{logo},</if>
update_time = now() where id = #{id}
</update>
Expand Down
Loading

0 comments on commit fd10a24

Please sign in to comment.