package com.ruoyi.goods.controller.management;
|
|
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.core.utils.page.PageDTO;
|
import com.ruoyi.goods.controller.management.dto.GoodsCategoryDTO;
|
import com.ruoyi.goods.controller.management.dto.GoodsCategoryQuery;
|
import com.ruoyi.goods.controller.management.vo.GoodsCategoryVO;
|
import com.ruoyi.goods.service.IGoodsCategoryService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
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
|
@RequiredArgsConstructor
|
@RequestMapping("/mgt/goods-category")
|
@Api(value = "管理后台商品分类相关接口", tags = {"管理后台接口"})
|
public class MgtGoodsCategoryController {
|
|
private final IGoodsCategoryService goodsCategoryService;
|
|
/**
|
* 获取商品分类列表的分页数据
|
*
|
* @param query 商品分类查询条件,通过RequestBody接收前端传来的查询参数。
|
* @return 返回一个包含商品分类分页数据的结果对象,其中数据部分为PageDTO<GoodsCategoryVO>类型。
|
*/
|
@ApiOperation(value = " 获取商品分类列表的分页数据", notes = " 获取商品分类列表的分页数据")
|
@PostMapping("/page")
|
public R<PageDTO<GoodsCategoryVO>> getGoodsCategoryPage(
|
@Validated @RequestBody GoodsCategoryQuery query) {
|
return R.ok(goodsCategoryService.getGoodsCategoryPage(query));
|
}
|
|
/**
|
* 新增/编辑商品分类。 该接口用于接收前端发送的商品分类数据,通过商品分类数据传输对象(GoodsCategoryDTO)来新增或编辑商品分类信息。
|
*
|
* @param dto 商品分类数据传输对象,包含商品分类的详细信息,通过RequestBody接收。 使用@Validated注解进行参数验证,确保数据的完整性和正确性。
|
* @return 返回操作结果,使用R<Void>作为返回类型,其中R是自定义的结果封装类,Void表示操作不返回具体数据。 如果操作成功,返回R.ok(),表示操作成功。
|
*/
|
@ApiOperation(value = "新增/编辑 商品分类", notes = "新增/编辑 商品分类")
|
@PostMapping("/save")
|
public R<Void> saveGoodsCategory(@Validated @RequestBody GoodsCategoryDTO dto) {
|
goodsCategoryService.saveGoodsCategory(dto);
|
return R.ok();
|
}
|
|
/**
|
* 删除商品分类
|
*
|
* @param id 商品分类的唯一标识符
|
* @return 返回操作结果,如果操作成功,则返回一个成功的标识
|
*/
|
@ApiOperation(value = "删除商品分类", notes = "删除商品分类")
|
@DeleteMapping("/{id}")
|
public R<Void> deleteGoodsCategory(@Validated @PathVariable("id") Long id) {
|
goodsCategoryService.removeById(id);
|
return R.ok();
|
}
|
}
|