use of com.bc.pmpheep.annotation.LogDetail 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.annotation.LogDetail in project pmph by BCSquad.
the class FileDownLoadController method exportResultSchool.
/**
* Description:申报结果统计页面按申报单位统计导出统计结果
*
* @author:lyc
* @date:2018年1月9日上午11:16:01
* @param
* @return void
*/
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "申报结果统计页面按申报单位统计导出统计结果")
@RequestMapping(value = "/result/exportResultSchool", method = RequestMethod.GET)
public void exportResultSchool(Long materialId, String schoolName, Integer state, HttpServletRequest request, HttpServletResponse response) {
PageParameter<DeclarationResultSchoolVO> pageParameter = new PageParameter<>(1, 50000);
DeclarationResultSchoolVO declarationResultSchoolVO = new DeclarationResultSchoolVO();
declarationResultSchoolVO.setMaterialId(materialId);
declarationResultSchoolVO.setSchoolName(schoolName);
pageParameter.setParameter(declarationResultSchoolVO);
Workbook workbook = null;
List<DeclarationResultSchoolVO> list = null;
String sheetName = "";
if (state.intValue() == 1) {
list = decPositionService.listChosenDeclarationResultSchoolVOs(pageParameter).getRows();
sheetName = "申报结果按单位统计(按当选数排序)";
} else if (state.intValue() == 2) {
list = decPositionService.listPresetDeclarationResultSchoolVOs(pageParameter).getRows();
sheetName = "申报结果按单位统计(按申报数排序)";
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "未知的排序方式");
}
if (list.size() == 0) {
list.add(new DeclarationResultSchoolVO());
}
try {
workbook = excelHelper.fromBusinessObjectList(list, sheetName);
} catch (CheckedServiceException | IllegalArgumentException | IllegalAccessException e) {
logger.warn("数据表格化的时候失败");
}
Material material = materialService.getMaterialById(materialId);
String fileName = returnFileName(request, material.getMaterialName() + ".xls");
response.setCharacterEncoding("utf-8");
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
try (OutputStream out = response.getOutputStream()) {
workbook.write(out);
out.flush();
out.close();
} catch (Exception e) {
logger.warn("文件下载时出现IO异常: {}", e.getMessage());
throw new CheckedServiceException(CheckedExceptionBusiness.FILE, CheckedExceptionResult.FILE_DOWNLOAD_FAILED, "文件在传输时中断");
}
}
use of com.bc.pmpheep.annotation.LogDetail 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.annotation.LogDetail 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.annotation.LogDetail 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));
}
Aggregations