feat(新增-商品规格管理): 加载商品规格数据

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-26 15:58:43 +08:00
parent 0affca82f0
commit 77bd3496d5
5 changed files with 43 additions and 0 deletions

View File

@ -3,12 +3,15 @@ package com.atguigu.spzx.manger.controller;
import com.atguigu.spzx.manger.service.ProductSpecService; import com.atguigu.spzx.manger.service.ProductSpecService;
import com.atguigu.spzx.model.entity.product.ProductSpec; import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.atguigu.spzx.model.vo.result.Result; import com.atguigu.spzx.model.vo.result.Result;
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "商品规格管理") @Tag(name = "商品规格管理")
@RestController @RestController
@RequestMapping(value = "/admin/product/productSpec") @RequestMapping(value = "/admin/product/productSpec")
@ -43,4 +46,11 @@ public class ProductSpecController {
productSpecService.deleteById(id); productSpecService.deleteById(id);
return Result.success(); return Result.success();
} }
@Operation(summary = "加载商品规格数据", description = "加载商品规格数据")
@GetMapping("findAll")
public Result<List<ProductSpec>> findAll() {
List<ProductSpec> list = productSpecService.findAll();
return Result.build(list, ResultCodeEnum.SUCCESS);
}
} }

View File

@ -34,4 +34,11 @@ public interface ProductSpecMapper {
* @param id 要删除的ID * @param id 要删除的ID
*/ */
void deleteById(Long id); void deleteById(Long id);
/**
* 加载商品规格数据
*
* @return 列表
*/
List<ProductSpec> findAll();
} }

View File

@ -3,6 +3,8 @@ package com.atguigu.spzx.manger.service;
import com.atguigu.spzx.model.entity.product.ProductSpec; import com.atguigu.spzx.model.entity.product.ProductSpec;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import java.util.List;
public interface ProductSpecService { public interface ProductSpecService {
/** /**
* 列表查询 * 列表查询
@ -33,4 +35,11 @@ public interface ProductSpecService {
* @param id 要删除的ID * @param id 要删除的ID
*/ */
void deleteById(Long id); void deleteById(Long id);
/**
* 加载商品规格数据
*
* @return 列表
*/
List<ProductSpec> findAll();
} }

View File

@ -75,4 +75,14 @@ public class ProductSpecServiceImpl implements ProductSpecService {
emptyUtil.isEmpty(id, MessageConstant.UPDATE_ID_IS_NOT_EMPTY); emptyUtil.isEmpty(id, MessageConstant.UPDATE_ID_IS_NOT_EMPTY);
productSpecMapper.deleteById(id); productSpecMapper.deleteById(id);
} }
/**
* 加载商品规格数据
*
* @return 列表
*/
@Override
public List<ProductSpec> findAll() {
return productSpecMapper.findAll();
}
} }

View File

@ -41,4 +41,11 @@
from product_spec from product_spec
where is_deleted = 0 order by id desc where is_deleted = 0 order by id desc
</select> </select>
<!-- 加载商品规格数据 -->
<select id="findAll" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
select
<include refid="columns"/>
from product_spec where is_deleted = 0 order by id
</select>
</mapper> </mapper>