JAVA全系列 教程
3762个小节阅读:7094k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
在后台管理API模块编写商品类型控制器:
xxxxxxxxxx
/**
* 商品类型
*/
@RestController
@RequestMapping("/productType")
public class ProductTypeController {
@DubboReference
private ProductTypeService productTypeService;
/**
* 新增商品类型
* @param productType 商品类型
* @return 执行结果
*/
@PostMapping("/add")
public BaseResult add(@RequestBody ProductType productType){
productTypeService.add(productType);
return BaseResult.ok();
}
/**
* 修改商品类型
* @param productType 商品类型
* @return 执行结果
*/
@PutMapping("/update")
public BaseResult update(@RequestBody ProductType productType){
productTypeService.update(productType);
return BaseResult.ok();
}
/**
* 删除商品类型
* @param id 商品类型id
* @return 执行结果
*/
@DeleteMapping("/delete")
public BaseResult delete(Long id){
productTypeService.delete(id);
return BaseResult.ok();
}
/**
* 根据id查询商品类型
* @param id 商品类型id
* @return 查询结果
*/
@GetMapping("/findById")
public BaseResult<ProductType> findById(Long id){
ProductType productType = productTypeService.findById(id);
return BaseResult.ok(productType);
}
/**
* 分页查询商品类型
* @param productType 查询条件对象
* @param page 页码
* @param size 每页条数
* @return 查询结果
*/
@GetMapping("/search")
public BaseResult<Page<ProductType>> search(ProductType productType,int page,int size){
Page<ProductType> page1 = productTypeService.search(productType, page, size);
return BaseResult.ok(page1);
}
/**
* 查询商品类型列表
* @param productType 查询条件对象
* @return 查询结果
*/
@GetMapping("/findProductType")
public BaseResult<List<ProductType>> findProductType(ProductType productType){
List<ProductType> productType1 = productTypeService.findProductType(productType);
return BaseResult.ok(productType1);
}
/**
* 根据父类型id查询商品类型列表
* @param parentId 父类型id
* @return 查询结果
*/
@GetMapping("/findByParentId")
public BaseResult<List<ProductType>> findByParentId(Long parentId){
ProductType productType = new ProductType();
productType.setParentId(parentId);
List<ProductType> productType1 = productTypeService.findProductType(productType);
return BaseResult.ok(productType1);
}
}
启动服务,测试商品类型控制器方法