Search in sources :

Example 1 with PastBookVideoVO

use of com.bc.pmpheep.back.vo.PastBookVideoVO in project pmph by BCSquad.

the class BookVideoServiceImpl method getList.

@Override
public PageResult<PastBookVideoVO> getList(Integer pageSize, Integer pageNumber, String bookName) {
    Map<String, Object> map = new HashMap<String, Object>(3);
    if (!StringUtil.isEmpty(bookName)) {
        bookName = StringUtil.toAllCheck(bookName.trim());
        map.put("bookName", bookName);
    }
    map.put("start", ((pageNumber - 1) * pageSize));
    map.put("pageSize", pageSize);
    // 获取书籍的分页
    PageResult<Book> listBooks = bookService.listBook(pageSize, pageNumber, bookName);
    List<PastBookVideoVO> lst = new ArrayList<PastBookVideoVO>();
    Integer total = 0;
    if (null != listBooks && null != listBooks.getTotal() && listBooks.getTotal().intValue() > 0) {
        total = listBooks.getTotal();
        List<Long> bookIds = new ArrayList<Long>(listBooks.getRows().size());
        for (Book book : listBooks.getRows()) {
            bookIds.add(book.getId());
            PastBookVideoVO pastBookVideoVO = new PastBookVideoVO();
            pastBookVideoVO.setAuthor(book.getAuthor()).setBookId(book.getId()).setBookname(book.getBookname()).setImageUrl(book.getImageUrl()).setRevision(book.getRevision()).setSn(book.getSn());
            lst.add(pastBookVideoVO);
        }
        List<BookVideo> BookVideos = bookVideoDao.getBookVideoByBookIds(bookIds);
        for (PastBookVideoVO pastBookVideoVO : lst) {
            List<BookVideo> bookVideos = new ArrayList<BookVideo>();
            for (BookVideo BookVideo : BookVideos) {
                if (pastBookVideoVO.getBookId().equals(BookVideo.getBookId())) {
                    bookVideos.add(BookVideo);
                }
            }
            pastBookVideoVO.setBookVideos(bookVideos);
        }
    }
    PageResult<PastBookVideoVO> BookVideoVOlst = new PageResult<PastBookVideoVO>();
    BookVideoVOlst.setPageNumber(pageNumber);
    BookVideoVOlst.setPageSize(pageSize);
    BookVideoVOlst.setTotal(total);
    BookVideoVOlst.setRows(lst);
    return BookVideoVOlst;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BookVideo(com.bc.pmpheep.back.po.BookVideo) PageResult(com.bc.pmpheep.back.plugin.PageResult) Book(com.bc.pmpheep.back.po.Book) PastBookVideoVO(com.bc.pmpheep.back.vo.PastBookVideoVO)

Aggregations

PageResult (com.bc.pmpheep.back.plugin.PageResult)1 Book (com.bc.pmpheep.back.po.Book)1 BookVideo (com.bc.pmpheep.back.po.BookVideo)1 PastBookVideoVO (com.bc.pmpheep.back.vo.PastBookVideoVO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1