Esempio n. 1
0
 @RequestMapping(value = "download")
 public void download(String id, HttpServletRequest request, HttpServletResponse response) {
   BaseMessage msg = null;
   if (StringUtils.isBlank(id)) {
     return;
   }
   Video video = videoService.queryVideo(id);
   String path = video.getUrl();
   String srcFolderPath = context.getRealPath("/") + path;
   FileInputStream fis = null;
   try {
     fis = new FileInputStream(new File(srcFolderPath));
     // 设置响应头和保存文件名
     //            response.setContentType("APPLICATION/OCTET-STREAM");
     response.addHeader("Content-Length", new File(srcFolderPath).length() + "");
     response.setHeader(
         "Content-Disposition",
         "attachment; filename=\"" + video.getName() + ".mp4" + "\""); // 写出流信息
     int b = 0;
     try {
       OutputStream out = response.getOutputStream();
       while ((b = fis.read()) != -1) {
         out.write(b);
       }
       out.close();
       out.close();
     } catch (FileNotFoundException e) {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 2
0
 @RequestMapping(value = "init")
 public ModelAndView initView(String unitId) {
   ModelAndView mav = new ModelAndView();
   List<VideoDomain> videos = videoService.list(null, unitId, SHORT);
   mav.addObject("videos", videos);
   mav.addObject("unitId", unitId);
   mav.setViewName("/mgr/mgr");
   return mav;
 }
Esempio n. 3
0
 @RequestMapping(value = "delete")
 @ResponseBody
 public BaseMessage delete(String id) {
   BaseMessage msg = null;
   try {
     videoService.deleteVideo(id);
     msg = BaseMessage.successMsg("update success");
   } catch (Exception e) {
     e.printStackTrace();
     msg = BaseMessage.errorMsg("update error");
   }
   return msg;
 }
Esempio n. 4
0
 @RequestMapping(value = "list")
 @ResponseBody
 public BaseMessage list(String unitId) {
   BaseMessage msg = null;
   if (StringUtils.isBlank(unitId)) {
     msg = BaseMessage.errorMsg("unitId is null");
     return msg;
   }
   try {
     List<VideoDomain> videos = videoService.list(null, unitId, SHORT);
     VideoPlayOrderHelper.sortAscVideos(videos);
     msg = BaseMessage.successMsg("success", videos);
   } catch (Exception e) {
     e.printStackTrace();
     msg = BaseMessage.errorMsg("error");
   }
   return msg;
 }
Esempio n. 5
0
 @RequestMapping(value = "update")
 @ResponseBody
 public BaseMessage update(
     String id,
     String ch,
     String en,
     @RequestParam MultipartFile file,
     HttpServletRequest request,
     HttpServletResponse response) {
   BaseMessage msg = null;
   try {
     videoService.updateVideo(id, ch, en, file);
     msg = BaseMessage.successMsg("update success");
   } catch (Exception e) {
     e.printStackTrace();
     msg = BaseMessage.errorMsg("update error");
   }
   return msg;
 }