package com.ruoyi.goods.controller.management;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.utils.page.PageDTO;
|
import com.ruoyi.goods.controller.management.dto.GoodsInfoTitleQuery;
|
import com.ruoyi.goods.controller.management.dto.GoodsSkuDTO;
|
import com.ruoyi.goods.controller.management.dto.GoodsSkuQuery;
|
import com.ruoyi.goods.controller.management.vo.GoodsBrandVO;
|
import com.ruoyi.goods.controller.management.vo.GoodsCategoryVO;
|
import com.ruoyi.goods.controller.management.vo.GoodsFlavorTypeVO;
|
import com.ruoyi.goods.controller.management.vo.GoodsInfoTitleVO;
|
import com.ruoyi.goods.controller.management.vo.GoodsSeriesVO;
|
import com.ruoyi.goods.controller.management.vo.GoodsSkuVO;
|
import com.ruoyi.goods.service.IGoodsBrandService;
|
import com.ruoyi.goods.service.IGoodsCategoryService;
|
import com.ruoyi.goods.service.IGoodsFlavorTypeService;
|
import com.ruoyi.goods.service.IGoodsInfoTitleService;
|
import com.ruoyi.goods.service.IGoodsSeriesService;
|
import com.ruoyi.goods.service.IGoodsSkuService;
|
import com.ruoyi.system.api.domain.dto.ListStatusDTO;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import java.util.List;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
/**
|
* <p>
|
* 商品表 前端控制器
|
* </p>
|
*
|
* @author mitao
|
* @since 2024-05-16
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/mgt/goods-sku")
|
@RequiredArgsConstructor
|
@Api(value = "管理后台商品相关接口", tags = {"管理后台接口"})
|
public class MgtGoodsSkuController {
|
|
private final IGoodsSkuService goodsSkuService;
|
private final IGoodsBrandService goodsBrandService;
|
private final IGoodsSeriesService goodsSeriesService;
|
private final IGoodsCategoryService goodsCategoryService;
|
private final IGoodsInfoTitleService goodsInfoTitleService;
|
private final IGoodsFlavorTypeService goodsFlavorTypeService;
|
|
/**
|
* 获取商品分类列表的接口 该接口不需要接收任何参数,调用后返回商品分类的列表信息。
|
*
|
* @return R<List < GoodsCategoryVO>> 返回类型为R的封装结果,其中包含商品分类的列表信息。
|
* List<GoodsCategoryVO>是商品分类的实体列表,GoodsCategoryVO是商品分类的视图对象。
|
*/
|
@ApiOperation(value = "获取商品分类列表", notes = "获取商品分类列表")
|
@GetMapping("/category/list")
|
public R<List<GoodsCategoryVO>> getGoodsCategoryList() {
|
return R.ok(goodsCategoryService.getGoodsCategoryList());
|
}
|
|
/**
|
* 获取商品系列列表的接口
|
* 该接口不需要任何请求参数,调用后返回商品系列的列表信息。
|
*
|
* @return R<List < GoodsSeriesVO>> 返回类型为R的封装结果,其中包含商品系列的列表信息。
|
* List<GoodsSeriesVO>是商品系列的实体列表,GoodsSeriesVO是商品系列的视图对象。
|
*/
|
@ApiOperation(value = "获取商品系列列表", notes = "获取商品系列列表")
|
@GetMapping("/series/list")
|
public R<List<GoodsSeriesVO>> getGoodsSeriesList() {
|
return R.ok(goodsSeriesService.getGoodsSeriesList());
|
}
|
|
/**
|
* 获取商品品牌列表的接口 该接口不需要接收任何参数,调用后返回商品品牌的列表信息。
|
*
|
* @return R<List < GoodsBrandVO>> 返回类型为R包装的GoodsBrandVO对象列表,R是框架定义的结果包装类, 其中包含了操作状态码和操作结果信息。
|
*/
|
@ApiOperation(value = "获取商品品牌列表", notes = "获取商品品牌列表")
|
@GetMapping("/brand/list")
|
public R<List<GoodsBrandVO>> getGoodsBrandList() {
|
return R.ok(goodsBrandService.getGoodsBrandList());
|
}
|
|
|
/**
|
* 获取商品香型列表
|
* <p>
|
* 该接口用于查询商品的香型列表信息。 不需要传入任何参数,返回商品香型的列表。
|
*
|
* @return R<List < GoodsFlavorTypeVO>> 包含商品香型列表的响应对象。
|
*/
|
@ApiOperation(value = "获取商品香型列表", notes = "获取商品香型列表")
|
@GetMapping("/flavor/list")
|
public R<List<GoodsFlavorTypeVO>> getGoodsFlavorTypeList() {
|
return R.ok(goodsFlavorTypeService.getGoodsFlavorTypeList());
|
}
|
|
|
/**
|
* 获取商品信息标题列表的分页数据。
|
*
|
* @param query 商品信息标题查询条件对象,通过验证后传入。
|
* @return 返回商品信息标题列表的分页数据响应对象。
|
*/
|
@ApiOperation(value = "获取商品信息标题列表的分页数据", notes = "获取商品信息标题列表的分页数据")
|
@PostMapping("/title/page")
|
public R<PageDTO<GoodsInfoTitleVO>> getGoodsInfoTitlePage(
|
@Validated @RequestBody GoodsInfoTitleQuery query) {
|
return R.ok(goodsInfoTitleService.getGoodsInfoTitlePage(query));
|
}
|
|
|
/**
|
* 添加/编辑商品
|
*
|
* @param dto 商品SKU数据传输对象,经过验证的请求体参数,用于传递商品信息。
|
* @return R<Void>
|
*/
|
@ApiOperation(value = "添加/编辑商品", notes = "添加商品")
|
@PostMapping("/save")
|
public R<Void> saveGoods(@Validated @RequestBody GoodsSkuDTO dto) {
|
try {
|
goodsSkuService.saveGoods(dto);
|
} catch (JsonProcessingException e) {
|
log.error("JSON转换异常", e);
|
return R.fail();
|
}
|
return R.ok();
|
}
|
|
/**
|
* 获取商品列表的分页数据
|
*
|
* @param query 商品分页查询条件
|
* @return 返回商品分页数据的响应对象
|
*/
|
@ApiOperation(value = "获取商品列表的分页数据", notes = "获取商品列表的分页数据")
|
@PostMapping("/page")
|
public R<PageDTO<GoodsSkuVO>> getGoodsPage(@Validated @RequestBody GoodsSkuQuery query) {
|
return R.ok(goodsSkuService.getGoodsPage(query));
|
}
|
|
/**
|
* 更新商品状态,实现商品下架或上架。
|
*
|
* @param dto 包含需要更新状态的商品信息的数据传输对象,类型为 ListStatusDTO。
|
* @return 返回一个表示操作结果的 R<Void> 对象,如果操作成功,则 R<Void>.ok() 方法返回一个成功标记。
|
*/
|
@ApiOperation(value = "下架/上架 商品", notes = "下架/上架 商品")
|
@PutMapping("/upd-status")
|
public R<Void> updStatus(@RequestBody ListStatusDTO dto) {
|
goodsSkuService.updStatus(dto);
|
return R.ok();
|
}
|
|
}
|