You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.8 KiB
110 lines
2.8 KiB
package com.example.controller;
|
|
|
|
import com.example.common.Result;
|
|
import com.example.entity.Goods;
|
|
import com.example.service.GoodsService;
|
|
import com.github.pagehelper.PageInfo;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 商品信息表前端操作接口
|
|
**/
|
|
@RestController
|
|
@RequestMapping("/goods")
|
|
public class GoodsController {
|
|
|
|
@Resource
|
|
private GoodsService goodsService;
|
|
|
|
/**
|
|
* 新增
|
|
*/
|
|
@PostMapping("/add")
|
|
public Result add(@RequestBody Goods goods) {
|
|
goodsService.add(goods);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
@DeleteMapping("/delete/{id}")
|
|
public Result deleteById(@PathVariable Integer id) {
|
|
goodsService.deleteById(id);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 批量删除
|
|
*/
|
|
@DeleteMapping("/delete/batch")
|
|
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
|
goodsService.deleteBatch(ids);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 修改
|
|
*/
|
|
@PutMapping("/update")
|
|
public Result updateById(@RequestBody Goods goods) {
|
|
goodsService.updateById(goods);
|
|
return Result.success();
|
|
}
|
|
|
|
/**
|
|
* 根据ID查询
|
|
*/
|
|
@GetMapping("/selectById")
|
|
public Result selectById(@RequestParam Integer id) {
|
|
Goods goods = goodsService.selectById(id);
|
|
return Result.success(goods);
|
|
}
|
|
@GetMapping("/selectTop15")
|
|
public Result selectTop15() {
|
|
List<Goods> list = goodsService.selectTop15();
|
|
return Result.success(list);
|
|
}
|
|
|
|
/**
|
|
* 查询所有
|
|
*/
|
|
@GetMapping("/selectAll")
|
|
public Result selectAll(Goods goods ) {
|
|
List<Goods> list = goodsService.selectAll(goods);
|
|
return Result.success(list);
|
|
}
|
|
|
|
@GetMapping("/selectByTypeId")
|
|
public Result selectByTypeId(@RequestParam Integer id) {
|
|
List<Goods> list = goodsService.selectByTypeId(id);
|
|
return Result.success(list);
|
|
}
|
|
|
|
@GetMapping("/selectByName")
|
|
public Result selectByName(@RequestParam String name) {
|
|
List<Goods> list = goodsService.selectByName(name);
|
|
return Result.success(list);
|
|
}
|
|
|
|
@GetMapping("/selectByBusinessId")
|
|
public Result selectByBusinessId(@RequestParam Integer id) {
|
|
List<Goods> list = goodsService.selectByBusinessId(id);
|
|
return Result.success(list);
|
|
}
|
|
|
|
/**
|
|
* 分页查询
|
|
*/
|
|
@GetMapping("/selectPage")
|
|
public Result selectPage(Goods goods,
|
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
|
@RequestParam(defaultValue = "10") Integer pageSize) {
|
|
PageInfo<Goods> page = goodsService.selectPage(goods, pageNum, pageSize);
|
|
return Result.success(page);
|
|
}
|
|
|
|
} |