|
|
@ -20,7 +20,9 @@ public class GoodsController {
|
|
|
|
private GoodsService goodsService;
|
|
|
|
private GoodsService goodsService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 新增
|
|
|
|
* 新增商品信息
|
|
|
|
|
|
|
|
* @param goods 商品对象
|
|
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PostMapping("/add")
|
|
|
|
@PostMapping("/add")
|
|
|
|
public Result add(@RequestBody Goods goods) {
|
|
|
|
public Result add(@RequestBody Goods goods) {
|
|
|
@ -29,7 +31,9 @@ public class GoodsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 删除
|
|
|
|
* 根据ID删除商品信息
|
|
|
|
|
|
|
|
* @param id 商品ID
|
|
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@DeleteMapping("/delete/{id}")
|
|
|
|
@DeleteMapping("/delete/{id}")
|
|
|
|
public Result deleteById(@PathVariable Integer id) {
|
|
|
|
public Result deleteById(@PathVariable Integer id) {
|
|
|
@ -38,7 +42,9 @@ public class GoodsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 批量删除
|
|
|
|
* 批量删除商品信息
|
|
|
|
|
|
|
|
* @param ids 商品ID列表
|
|
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@DeleteMapping("/delete/batch")
|
|
|
|
@DeleteMapping("/delete/batch")
|
|
|
|
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
|
|
|
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
|
|
@ -47,7 +53,9 @@ public class GoodsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 修改
|
|
|
|
* 修改商品信息
|
|
|
|
|
|
|
|
* @param goods 商品对象
|
|
|
|
|
|
|
|
* @return 操作结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PutMapping("/update")
|
|
|
|
@PutMapping("/update")
|
|
|
|
public Result updateById(@RequestBody Goods goods) {
|
|
|
|
public Result updateById(@RequestBody Goods goods) {
|
|
|
@ -56,13 +64,20 @@ public class GoodsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 根据ID查询
|
|
|
|
* 根据ID查询商品信息
|
|
|
|
|
|
|
|
* @param id 商品ID
|
|
|
|
|
|
|
|
* @return 商品信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectById")
|
|
|
|
@GetMapping("/selectById")
|
|
|
|
public Result selectById(@RequestParam Integer id) {
|
|
|
|
public Result selectById(@RequestParam Integer id) {
|
|
|
|
Goods goods = goodsService.selectById(id);
|
|
|
|
Goods goods = goodsService.selectById(id);
|
|
|
|
return Result.success(goods);
|
|
|
|
return Result.success(goods);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询前15条商品信息
|
|
|
|
|
|
|
|
* @return 商品信息列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectTop15")
|
|
|
|
@GetMapping("/selectTop15")
|
|
|
|
public Result selectTop15() {
|
|
|
|
public Result selectTop15() {
|
|
|
|
List<Goods> list = goodsService.selectTop15();
|
|
|
|
List<Goods> list = goodsService.selectTop15();
|
|
|
@ -70,7 +85,9 @@ public class GoodsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询所有
|
|
|
|
* 查询所有商品信息
|
|
|
|
|
|
|
|
* @param goods 商品对象,用于条件查询
|
|
|
|
|
|
|
|
* @return 商品信息列表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectAll")
|
|
|
|
@GetMapping("/selectAll")
|
|
|
|
public Result selectAll(Goods goods ) {
|
|
|
|
public Result selectAll(Goods goods ) {
|
|
|
@ -78,18 +95,33 @@ public class GoodsController {
|
|
|
|
return Result.success(list);
|
|
|
|
return Result.success(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 根据类型ID查询商品信息
|
|
|
|
|
|
|
|
* @param id 类型ID
|
|
|
|
|
|
|
|
* @return 商品信息列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectByTypeId")
|
|
|
|
@GetMapping("/selectByTypeId")
|
|
|
|
public Result selectByTypeId(@RequestParam Integer id) {
|
|
|
|
public Result selectByTypeId(@RequestParam Integer id) {
|
|
|
|
List<Goods> list = goodsService.selectByTypeId(id);
|
|
|
|
List<Goods> list = goodsService.selectByTypeId(id);
|
|
|
|
return Result.success(list);
|
|
|
|
return Result.success(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 根据名称查询商品信息
|
|
|
|
|
|
|
|
* @param name 商品名称
|
|
|
|
|
|
|
|
* @return 商品信息列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectByName")
|
|
|
|
@GetMapping("/selectByName")
|
|
|
|
public Result selectByName(@RequestParam String name) {
|
|
|
|
public Result selectByName(@RequestParam String name) {
|
|
|
|
List<Goods> list = goodsService.selectByName(name);
|
|
|
|
List<Goods> list = goodsService.selectByName(name);
|
|
|
|
return Result.success(list);
|
|
|
|
return Result.success(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 根据商家ID查询商品信息
|
|
|
|
|
|
|
|
* @param id 商家ID
|
|
|
|
|
|
|
|
* @return 商品信息列表
|
|
|
|
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectByBusinessId")
|
|
|
|
@GetMapping("/selectByBusinessId")
|
|
|
|
public Result selectByBusinessId(@RequestParam Integer id) {
|
|
|
|
public Result selectByBusinessId(@RequestParam Integer id) {
|
|
|
|
List<Goods> list = goodsService.selectByBusinessId(id);
|
|
|
|
List<Goods> list = goodsService.selectByBusinessId(id);
|
|
|
@ -97,7 +129,11 @@ public class GoodsController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 分页查询
|
|
|
|
* 分页查询商品信息
|
|
|
|
|
|
|
|
* @param goods 商品对象,用于条件查询
|
|
|
|
|
|
|
|
* @param pageNum 页码
|
|
|
|
|
|
|
|
* @param pageSize 每页大小
|
|
|
|
|
|
|
|
* @return 分页查询结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GetMapping("/selectPage")
|
|
|
|
@GetMapping("/selectPage")
|
|
|
|
public Result selectPage(Goods goods,
|
|
|
|
public Result selectPage(Goods goods,
|
|
|
@ -107,4 +143,4 @@ public class GoodsController {
|
|
|
|
return Result.success(page);
|
|
|
|
return Result.success(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|