Esempio n. 1
0
  @RequestMapping("diary")
  public String diary(Model model, String c) {

    List<Diary> list = diaryDao.getDiaries();
    model.addAttribute("list", list);

    return "diary.diary";
  }
Esempio n. 2
0
  @RequestMapping(value = "diaryDelete", method = RequestMethod.POST)
  public String diaryDelete(String c, String dc) {

    diaryDao.removeDiary(c);
    if (c.equals(dc)) {
      diaryImageDao.removeDiaryImage(dc);
    }

    return "redirect:diary";
  }
Esempio n. 3
0
  @RequestMapping("diaryDetail")
  public String diaryDetail(String c, Model model) {

    DiaryImage di = diaryImageDao.getDiaryImage(c);
    Diary d = diaryDao.getDiary(c);

    model.addAttribute("d", d);
    model.addAttribute("di", di);

    return "diary.diaryDetail";
  }
Esempio n. 4
0
  @RequestMapping(value = "diaryUdtReg", method = RequestMethod.GET)
  public String diaryUdtReg(String c, Model model) {

    DiaryImage di = diaryImageDao.getDiaryImage(c);
    Diary d = diaryDao.getDiary(c);

    model.addAttribute("d", d);
    model.addAttribute("di", di);

    return "diary.diaryUdtReg";
  }
Esempio n. 5
0
  @RequestMapping(value = "diaryReg", method = RequestMethod.POST)
  public String diaryReg(
      Diary d, MultipartFile file, Principal principal, HttpServletRequest request)
      throws IOException {

    d.setMemberId(principal.getName());

    diaryDao.addDiary(d);

    if (!file.isEmpty()) {
      ServletContext application = request.getServletContext();

      String url = "/resource/upload/diary";
      String path = application.getRealPath(url);
      String temp = file.getOriginalFilename();
      String fname = temp.substring(temp.lastIndexOf('\\') + 1);
      String fpath = path + "\\" + fname;

      InputStream ins = file.getInputStream();
      OutputStream outs = new FileOutputStream(fpath); // ÀúÀå

      byte[] bigData = new byte[1024];
      int len = 0;

      while ((len = ins.read(bigData, 0, 1024)) >= 0) outs.write(bigData, 0, len);

      outs.flush();
      outs.close();
      ins.close();

      DiaryImage diaryImage = new DiaryImage();
      diaryImage.setName(fname);
      diaryImage.setDiaryCode(diaryDao.getLastCode());
      diaryImageDao.addDiaryImage(diaryImage);
    }
    return "redirect:diary";
  }