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.
87 lines
2.1 KiB
87 lines
2.1 KiB
3 months ago
|
package com.example.controller;
|
||
|
|
||
|
import com.example.common.Result;
|
||
|
import com.example.entity.Collect;
|
||
|
import com.example.service.CollectService;
|
||
|
import com.github.pagehelper.PageInfo;
|
||
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
||
|
import javax.annotation.Resource;
|
||
|
import java.util.List;
|
||
|
|
||
|
/**
|
||
|
* 收藏前端操作接口
|
||
|
**/
|
||
|
@RestController
|
||
|
@RequestMapping("/collect")
|
||
|
public class CollectController {
|
||
|
|
||
|
@Resource
|
||
|
private CollectService collectService;
|
||
|
|
||
|
/**
|
||
|
* 新增
|
||
|
*/
|
||
|
@PostMapping("/add")
|
||
|
public Result add(@RequestBody Collect collect) {
|
||
|
collectService.add(collect);
|
||
|
return Result.success();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 删除
|
||
|
*/
|
||
|
@DeleteMapping("/delete/{id}")
|
||
|
public Result deleteById(@PathVariable Integer id) {
|
||
|
collectService.deleteById(id);
|
||
|
return Result.success();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 批量删除
|
||
|
*/
|
||
|
@DeleteMapping("/delete/batch")
|
||
|
public Result deleteBatch(@RequestBody List<Integer> ids) {
|
||
|
collectService.deleteBatch(ids);
|
||
|
return Result.success();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 修改
|
||
|
*/
|
||
|
@PutMapping("/update")
|
||
|
public Result updateById(@RequestBody Collect collect) {
|
||
|
collectService.updateById(collect);
|
||
|
return Result.success();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 根据ID查询
|
||
|
*/
|
||
|
@GetMapping("/selectById/{id}")
|
||
|
public Result selectById(@PathVariable Integer id) {
|
||
|
Collect collect = collectService.selectById(id);
|
||
|
return Result.success(collect);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 查询所有
|
||
|
*/
|
||
|
@GetMapping("/selectAll")
|
||
|
public Result selectAll(Collect collect ) {
|
||
|
List<Collect> list = collectService.selectAll(collect);
|
||
|
return Result.success(list);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 分页查询
|
||
|
*/
|
||
|
@GetMapping("/selectPage")
|
||
|
public Result selectPage(Collect collect,
|
||
|
@RequestParam(defaultValue = "1") Integer pageNum,
|
||
|
@RequestParam(defaultValue = "10") Integer pageSize) {
|
||
|
PageInfo<Collect> page = collectService.selectPage(collect, pageNum, pageSize);
|
||
|
return Result.success(page);
|
||
|
}
|
||
|
|
||
|
}
|