Search in sources :

Example 1 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean in project pmph by BCSquad.

the class FileDownLoadController method download.

/**
 * 小组文件下载
 *
 * @param id
 *            图片在MongoDB中的id
 * @param groupId
 *            小组id
 * @param response
 *            服务响应
 * @return ResponseBean对象
 */
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "小组文件下载")
@RequestMapping(value = "/groupfile/download/{id}", method = RequestMethod.GET)
public ResponseBean download(@PathVariable("id") String id, @RequestParam("groupId") long groupId, HttpServletRequest request, HttpServletResponse response) {
    if (groupId < 1) {
        throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "小组id错误(负数或零)");
    }
    response.setCharacterEncoding("utf-8");
    response.setContentType("application/force-download");
    GridFSDBFile file = fileService.get(id);
    if (null == file) {
        logger.warn("未找到id为'{}'的文件", id);
        throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "未找到对应文件");
    }
    String fileName = returnFileName(request, file.getFilename());
    response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
    try (OutputStream out = response.getOutputStream()) {
        file.writeTo(out);
        out.flush();
        out.close();
        return new ResponseBean(groupFileService.updatePmphGroupFileOfDown(groupId, id));
    } catch (IOException ex) {
        logger.warn("文件下载时出现IO异常:{}", ex.getMessage());
        throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
    }
}
Also used : GridFSDBFile(com.mongodb.gridfs.GridFSDBFile) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) IOException(java.io.IOException) LogDetail(com.bc.pmpheep.annotation.LogDetail) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean in project pmph by BCSquad.

the class BookUserCommentController method list.

/**
 * 功能描述:分页初始化/模糊查询图书评论
 *
 * @param pageSize
 *            当页的数据条数
 * @param pageNumber
 *            当前页码
 * @param name
 *            数据名称/isbn
 * @param isAuth
 *            是否通过审核
 * @return
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "分页初始化/模糊查询图书评论")
@RequestMapping(value = "/list", method = RequestMethod.GET)
public ResponseBean list(Integer pageSize, Integer pageNumber, String name, Integer isAuth, Boolean isLong) {
    PageParameter<BookUserCommentVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    BookUserCommentVO bookUserCommentVO = new BookUserCommentVO();
    bookUserCommentVO.setIsAuth(isAuth);
    // 去除空格
    bookUserCommentVO.setName(name.replaceAll(" ", ""));
    bookUserCommentVO.setIsLong(isLong);
    pageParameter.setParameter(bookUserCommentVO);
    return new ResponseBean(bookUserCommentService.listBookUserComment(pageParameter));
}
Also used : BookUserCommentVO(com.bc.pmpheep.back.vo.BookUserCommentVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean 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 4 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean 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 5 with ResponseBean

use of com.bc.pmpheep.controller.bean.ResponseBean in project pmph by BCSquad.

the class DecPositionController method schoolListPreset.

/**
 * Description:加载学校统计结果(按申报数排序)
 *
 * @author:lyc
 * @date:2017年12月5日下午2:57:51
 * @param
 * @return ResponseBean
 */
@ResponseBody
@RequestMapping(value = "/list/schoolListPreset", method = RequestMethod.GET)
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "加载学校统计结果(按申报数排序)")
public ResponseBean schoolListPreset(Integer pageSize, Integer pageNumber, Long materialId, String schoolName) {
    PageParameter<DeclarationResultSchoolVO> pageParameter = new PageParameter<>(pageNumber, pageSize);
    DeclarationResultSchoolVO declarationResultSchoolVO = new DeclarationResultSchoolVO();
    declarationResultSchoolVO.setMaterialId(materialId);
    declarationResultSchoolVO.setSchoolName(schoolName);
    pageParameter.setParameter(declarationResultSchoolVO);
    return new ResponseBean(decPositionService.listPresetDeclarationResultSchoolVOs(pageParameter));
}
Also used : DeclarationResultSchoolVO(com.bc.pmpheep.back.vo.DeclarationResultSchoolVO) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)67 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)67 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)65 LogDetail (com.bc.pmpheep.annotation.LogDetail)61 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)37 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 TopicLog (com.bc.pmpheep.back.po.TopicLog)5 DesRun (com.bc.pmpheep.back.util.DesRun)4 Properties (java.util.Properties)4 BookVideo (com.bc.pmpheep.back.po.BookVideo)3 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)3 PmphUser (com.bc.pmpheep.back.po.PmphUser)3 Topic (com.bc.pmpheep.back.po.Topic)3 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)2 PmphRole (com.bc.pmpheep.back.po.PmphRole)2 WriterUser (com.bc.pmpheep.back.po.WriterUser)2 DeclarationResultSchoolVO (com.bc.pmpheep.back.vo.DeclarationResultSchoolVO)2