Search in sources :

Example 1 with BookVideo

use of com.bc.pmpheep.back.po.BookVideo 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)

Example 2 with BookVideo

use of com.bc.pmpheep.back.po.BookVideo in project pmph by BCSquad.

the class BookVideoController method addVideo.

@ResponseBody
@RequestMapping(value = "/addVideo", method = RequestMethod.POST)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "保存微视频信息")
public ResponseBean<Integer> addVideo(Long userId, Long bookId, String title, String origPath, String origFileName, Long origFileSize, String path, String fileName, Long fileSize, @RequestParam("cover") MultipartFile cover) throws IOException {
    BookVideo bookVideo = new BookVideo();
    bookVideo.setBookId(bookId);
    bookVideo.setTitle(title);
    bookVideo.setOrigPath(origPath);
    bookVideo.setOrigFileName(origFileName);
    bookVideo.setOrigFileSize(origFileSize);
    bookVideo.setPath(path);
    bookVideo.setFileName(fileName);
    bookVideo.setFileSize(fileSize);
    return new ResponseBean(bookVideoService.addBookVideoFront(userId, bookVideo, cover));
}
Also used : ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) BookVideo(com.bc.pmpheep.back.po.BookVideo) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with BookVideo

use of com.bc.pmpheep.back.po.BookVideo in project pmph by BCSquad.

the class BookVideoController method addBookVideo.

/**
 * 保存视频
 *
 * @param request
 * @param cover
 * @throws java.io.IOException
 * @introduction
 * @author Mryang
 * @createDate 2018年2月10日 下午5:34:12
 * @return
 */
@ResponseBody
@RequestMapping(value = "/addBookVideo", method = RequestMethod.POST)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "保存微视频信息")
public ResponseBean<Integer> addBookVideo(HttpServletRequest request, Long bookId, String title, String origPath, String origFileName, Long origFileSize, String path, String fileName, Long fileSize, @RequestParam("cover") MultipartFile cover) throws IOException {
    String sessionId = CookiesUtil.getSessionId(request);
    if (StringUtil.isEmpty(sessionId)) {
        return new ResponseBean(new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.USER_SESSION, "尚未登录或session已过期"));
    }
    BookVideo bookVideo = new BookVideo();
    bookVideo.setBookId(bookId);
    bookVideo.setTitle(title);
    bookVideo.setOrigPath(origPath);
    bookVideo.setOrigFileName(origFileName);
    bookVideo.setOrigFileSize(origFileSize);
    bookVideo.setPath(path);
    bookVideo.setFileName(fileName);
    bookVideo.setFileSize(fileSize);
    return new ResponseBean(bookVideoService.addBookVideo(sessionId, bookVideo, cover));
}
Also used : ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) BookVideo(com.bc.pmpheep.back.po.BookVideo) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with BookVideo

use of com.bc.pmpheep.back.po.BookVideo in project pmph by BCSquad.

the class BookVideoController method audit.

/**
 * 审核视频
 *
 * @introduction
 * @author Mryang
 * @createDate 2018年2月6日 下午5:34:12
 * @return
 */
@ResponseBody
@RequestMapping(value = "/audit", method = RequestMethod.PUT)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "微视频审核")
public ResponseBean<Integer> audit(HttpServletRequest request, Long id, Boolean isAuth) {
    if (ObjectUtil.isNull(id)) {
        return new ResponseBean(new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.NULL_PARAM, "微视频id不能为空"));
    }
    if (ObjectUtil.isNull(isAuth)) {
        return new ResponseBean(new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.NULL_PARAM, "审核参数不能为空"));
    }
    String sessionId = CookiesUtil.getSessionId(request);
    if (StringUtil.isEmpty(sessionId)) {
        return new ResponseBean(new CheckedServiceException(CheckedExceptionBusiness.BOOK_VEDIO, CheckedExceptionResult.USER_SESSION, "尚未登录或session已过期"));
    }
    BookVideo bookVideo = new BookVideo();
    bookVideo.setId(id).setAuthDate(new Date()).setAuthUserId(SessionUtil.getPmphUserBySessionId(sessionId).getId()).setIsAuth(isAuth);
    return new ResponseBean(bookVideoService.updateBookVideo(bookVideo));
}
Also used : ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) BookVideo(com.bc.pmpheep.back.po.BookVideo) Date(java.util.Date) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

BookVideo (com.bc.pmpheep.back.po.BookVideo)4 LogDetail (com.bc.pmpheep.annotation.LogDetail)3 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 Book (com.bc.pmpheep.back.po.Book)1 PastBookVideoVO (com.bc.pmpheep.back.vo.PastBookVideoVO)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1