Search in sources :

Example 6 with BookDTO

use of com.github.lybgeek.spilt.dto.BookDTO in project springboot-learning by lyb-geek.

the class BookController method upadteBook.

@PostMapping(value = "/update")
public Result<BookDTO> upadteBook(BookDTO bookDTO) {
    Result<BookDTO> result = new Result<>();
    if (bookDTO.getId() == null) {
        result.setStatus(Result.fail);
        result.setMessage("id不能为空");
        return result;
    }
    BookDTO book = bookService.editBook(bookDTO);
    result.setData(book);
    return result;
}
Also used : BookDTO(com.github.lybgeek.spilt.dto.BookDTO) Result(com.github.lybgeek.common.model.Result) PageResult(com.github.lybgeek.common.model.PageResult) BindingResult(org.springframework.validation.BindingResult) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 7 with BookDTO

use of com.github.lybgeek.spilt.dto.BookDTO in project springboot-learning by lyb-geek.

the class SplitTableApplicationTest method testAddBook.

@Test
public void testAddBook() {
    for (int i = 1; i <= 10; i++) {
        BookDTO bookDTO = BookDTO.builder().bookName("docker从入门到精通(第" + i + ")版").author("张三" + i).description("docker从入门到精通(第" + i + ")版,热门系列").price(BigDecimal.valueOf(i * 10)).stock(i).build();
        bookDTO = bookService.addBook(bookDTO);
        System.out.println(bookDTO);
    }
}
Also used : BookDTO(com.github.lybgeek.spilt.dto.BookDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

BookDTO (com.github.lybgeek.spilt.dto.BookDTO)7 Book (com.github.lybgeek.spilt.model.Book)3 PageResult (com.github.lybgeek.common.model.PageResult)2 Result (com.github.lybgeek.common.model.Result)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 BindingResult (org.springframework.validation.BindingResult)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 IPage (com.baomidou.mybatisplus.core.metadata.IPage)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 BizException (com.github.lybgeek.common.exception.BizException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Transactional (org.springframework.transaction.annotation.Transactional)1