feat(新增-品牌数据): 加载商品单元数据

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-26 15:55:58 +08:00
parent a8ba62125f
commit 0affca82f0
8 changed files with 106 additions and 7 deletions

View File

@ -6,7 +6,6 @@ import com.atguigu.spzx.model.dto.product.ProductDto;
import com.atguigu.spzx.model.entity.product.Brand;
import com.atguigu.spzx.model.entity.product.Product;
import com.atguigu.spzx.model.vo.result.Result;
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -38,6 +37,6 @@ public class ProductController {
@GetMapping("findBrandByCategoryId/{categoryId}")
public Result<List<Brand>> findBrandByCategoryId(@PathVariable Long categoryId) {
List<Brand> brandList = categoryBrandService.findBrandByCategoryId(categoryId);
return Result.build(brandList, ResultCodeEnum.SUCCESS);
return Result.success(brandList);
}
}

View File

@ -17,13 +17,14 @@ public class ProductSpecController {
private ProductSpecService productSpecService;
@Operation(summary = "列表查询", description = "列表查询")
@PutMapping("{page}/{limit}")
@GetMapping("{page}/{limit}")
public Result<PageInfo<ProductSpec>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) {
PageInfo<ProductSpec> pageInfo = productSpecService.findByPage(page, limit);
return Result.success(pageInfo);
}
@Operation(summary = "添加功能", description = "添加功能")
@PostMapping("save")
public Result<ProductSpec> save(@RequestBody ProductSpec productSpec) {
productSpecService.save(productSpec);
return Result.success();

View File

@ -0,0 +1,29 @@
package com.atguigu.spzx.manger.controller;
import com.atguigu.spzx.manger.service.ProductUnitService;
import com.atguigu.spzx.model.entity.base.ProductUnit;
import com.atguigu.spzx.model.vo.result.Result;
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Tag(name = "品牌数据")
@RestController
@RequestMapping("/admin/product/productUnit")
public class ProductUnitController {
@Autowired
private ProductUnitService productUnitService;
@Operation(summary = "加载商品单元数据", description = "加载商品单元数据")
@GetMapping("findAll")
public Result<List<ProductUnit>> findAll() {
List<ProductUnit> productUnitList = productUnitService.findAll();
return Result.build(productUnitList, ResultCodeEnum.SUCCESS);
}
}

View File

@ -0,0 +1,16 @@
package com.atguigu.spzx.manger.mapper;
import com.atguigu.spzx.model.entity.base.ProductUnit;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ProductUnitMapper {
/**
* 加载商品单元数据
*
* @return 产品单元实体类列表
*/
List<ProductUnit> findAll();
}

View File

@ -0,0 +1,14 @@
package com.atguigu.spzx.manger.service;
import com.atguigu.spzx.model.entity.base.ProductUnit;
import java.util.List;
public interface ProductUnitService {
/**
* 加载商品单元数据
*
* @return 产品单元实体类列表
*/
List<ProductUnit> findAll();
}

View File

@ -0,0 +1,25 @@
package com.atguigu.spzx.manger.service.impl;
import com.atguigu.spzx.manger.mapper.ProductUnitMapper;
import com.atguigu.spzx.manger.service.ProductUnitService;
import com.atguigu.spzx.model.entity.base.ProductUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProductUnitServiceImpl implements ProductUnitService {
@Autowired
private ProductUnitMapper productUnitMapper;
/**
* 加载商品单元数据
*
* @return 产品单元实体类列表
*/
@Override
public List<ProductUnit> findAll() {
return productUnitMapper.findAll();
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.atguigu.spzx.manger.mapper.ProductUnitMapper">
<sql id="columns">
id,name,create_time,update_time,is_deleted
</sql>
<!-- 加载商品单元数据 -->
<select id="findAll" resultType="com.atguigu.spzx.model.entity.base.ProductUnit">
select
<include refid="columns"/>
from product_unit
where is_deleted = 0 order by id desc
</select>
</mapper>

View File

@ -2,12 +2,12 @@ package com.atguigu.spzx.model.entity.base;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
@Schema(description = "产品单元实体类")
public class ProductUnit extends BaseEntity {
@Schema(description = "名称")
private String name;
@Schema(description = "名称")
private String name;
}