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, "文件在传输时中断");
}
}
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));
}
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));
}
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));
}
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));
}
Aggregations