Initial commit
This commit is contained in:
parent
113b034afb
commit
f53fd046d0
@ -1,13 +1,11 @@
|
||||
package com.yv.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yv.admain.Book;
|
||||
import com.yv.controller.utils.R;
|
||||
import com.yv.service.IBookService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author YoVinchen
|
||||
* @date 2023/3/17 下午 8:00
|
||||
@ -20,33 +18,34 @@ public class BookController {
|
||||
private IBookService bookService;
|
||||
|
||||
@GetMapping
|
||||
public List<Book> getAll() {
|
||||
return bookService.list();
|
||||
public R getAll() {
|
||||
return new R(true, bookService.list());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Boolean save(@RequestBody Book book) {
|
||||
return bookService.save(book);
|
||||
public R save(@RequestBody Book book) {
|
||||
return new R(bookService.save(book));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Boolean update(@RequestBody Book book) {
|
||||
return bookService.modify(book);
|
||||
public R update(@RequestBody Book book) {
|
||||
return new R(bookService.modify(book));
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
public Boolean detect(@PathVariable Integer id) {
|
||||
return bookService.delete(id);
|
||||
public R detect(@PathVariable Integer id) {
|
||||
return new R(bookService.delete(id));
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
public Book getById(@PathVariable Integer id) {
|
||||
return bookService.getById(id);
|
||||
public R getById(@PathVariable Integer id) {
|
||||
return new R(true, bookService.getById(id));
|
||||
}
|
||||
|
||||
@GetMapping("{currentPage}/{pageSize}")
|
||||
public IPage<Book> getPage(@PathVariable int currentPage,@PathVariable int pageSize) {
|
||||
return bookService.getPage(currentPage, pageSize);
|
||||
public R getPage(@PathVariable int currentPage, @PathVariable int pageSize) {
|
||||
return new R(true, bookService.getPage(currentPage, pageSize));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,4 +10,15 @@ import lombok.Data;
|
||||
public class R {
|
||||
private Boolean flag;
|
||||
private Object data;
|
||||
|
||||
public R(){};
|
||||
|
||||
public R(Boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public R(Boolean flag,Object data){
|
||||
this.flag = flag;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user