Initial commit
This commit is contained in:
parent
c8f4073b6e
commit
f8801cdef6
@ -8,7 +8,6 @@ import lombok.Data;
|
|||||||
*
|
*
|
||||||
* lombok
|
* lombok
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class Book {
|
public class Book {
|
||||||
private int id;
|
private int id;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.yv.service;
|
package com.yv.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.yv.admain.Book;
|
import com.yv.admain.Book;
|
||||||
|
|
||||||
@ -9,4 +10,13 @@ import com.yv.admain.Book;
|
|||||||
*/
|
*/
|
||||||
public interface IBookService extends IService<Book> {
|
public interface IBookService extends IService<Book> {
|
||||||
|
|
||||||
|
boolean saveBook(Book book);
|
||||||
|
|
||||||
|
boolean modify(Book book);
|
||||||
|
|
||||||
|
boolean delete(Integer id);
|
||||||
|
|
||||||
|
IPage<Book> getPage(int currentPage, int pageSize);
|
||||||
|
|
||||||
|
IPage<Book> getPage(int currentPage, int pageSize, Book book);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package com.yv.service.impl;
|
package com.yv.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.yv.admain.Book;
|
import com.yv.admain.Book;
|
||||||
import com.yv.dao.BookDao;
|
import com.yv.dao.BookDao;
|
||||||
import com.yv.service.IBookService;
|
import com.yv.service.IBookService;
|
||||||
|
import org.apache.logging.log4j.util.Strings;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,4 +17,40 @@ import org.springframework.stereotype.Service;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class BookServiceImpl extends ServiceImpl<BookDao, Book> implements IBookService {
|
public class BookServiceImpl extends ServiceImpl<BookDao, Book> implements IBookService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BookDao bookDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveBook(Book book) {
|
||||||
|
return bookDao.insert(book) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean modify(Book book) {
|
||||||
|
return bookDao.updateById(book) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean delete(Integer id) {
|
||||||
|
return bookDao.deleteById(id) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<Book> getPage(int currentPage, int pageSize) {
|
||||||
|
IPage page = new Page(currentPage,pageSize);
|
||||||
|
bookDao.selectPage(page,null);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<Book> getPage(int currentPage, int pageSize, Book book) {
|
||||||
|
LambdaQueryWrapper<Book> lqw = new LambdaQueryWrapper<Book>();
|
||||||
|
lqw.like(Strings.isNotEmpty(book.getType()),Book::getType,book.getType());
|
||||||
|
lqw.like(Strings.isNotEmpty(book.getName()),Book::getName,book.getName());
|
||||||
|
lqw.like(Strings.isNotEmpty(book.getDescription()),Book::getDescription,book.getDescription());
|
||||||
|
IPage page = new Page(currentPage,pageSize);
|
||||||
|
bookDao.selectPage(page,lqw);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user