コード例 #1
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 @RequestMapping("returnNoteContent")
 public void returnNoteContent(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException, InterruptedException {
   int startPage = DataHandle.returnValueInt(request, "startPage");
   if (startPage == 0) {
     startPage = 1;
   }
   int recordNum = DataHandle.returnValueInt(request, "recordNum");
   if (recordNum == 0) {
     recordNum = Constant.BLOGPAGE;
   }
   // String searchKey = DataHandle.returnValue(request, "searchKey");
   String timeValue = DataHandle.returnValue(request, "timeValue");
   // 1 年 2月  3日
   String condition = " 1 = 1 ";
   int timeType = DataHandle.returnValueInt(request, "timeType");
   if (timeType == 1) {
     condition +=
         " and createDate >= "
             + timeValue
             + "-01-01 00:00:00 and createDate <= "
             + timeValue
             + "-12-31 23:59:59";
   } else if (timeType == 2) {
     condition +=
         " and createDate >= "
             + timeValue
             + "-01 00:00:00 and createDate <= "
             + timeValue
             + "-31 23:59:59";
   } else if (timeType == 3) {
     condition +=
         " and createDate >= "
             + timeValue
             + " 00:00:00 and createDate <= "
             + timeValue
             + " 23:59:59";
   }
   condition += "order by createDate desc";
   Note note = new Note();
   note.setCondition(condition);
   note.setPage(recordNum);
   note.setStartPage((startPage - 1) * recordNum);
   List<Note> list = noteMapperService.selectList(note);
   int recordSum = noteMapperService.count(note);
   int pageSum = CommonHandle.returnPageCount(recordSum, recordNum);
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("data", list);
   jsonObject.put("recordSum", recordSum);
   jsonObject.put("pageSum", pageSum);
   response.getWriter().write(jsonObject.toString());
 }
コード例 #2
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 /** 获得时间树的天数和便签数 */
 @RequestMapping("returnTreeDay")
 public void returnTreeDay(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException {
   User user = (User) session.getAttribute(Constant.USER);
   String year = request.getParameter("year");
   String month = request.getParameter("month");
   String condition =
       "createDate >= '"
           + year
           + "-"
           + month
           + "-01 00:00:00' and createDate <= '"
           + year
           + "-"
           + month
           + "-31 23:59:59'";
   Note note = new Note();
   note.setUserId(user.getUserId());
   note.setCondition(condition);
   List<Map<String, Object>> noteList = noteMapperService.selectDay(note);
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("result", "success");
   jsonObject.put("data", noteList);
   response.getWriter().write(jsonObject.toString());
 }
コード例 #3
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 @RequestMapping("my/{userId}")
 public String toMyIndex(@PathVariable int userId, Model model) {
   Note note = new Note();
   note.setUserId(userId);
   List<Note> noteList = noteMapperService.selectList(note);
   model.addAttribute("noteList", noteList);
   return "note/myIndex";
 }
コード例 #4
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 @RequestMapping("my-updateNote")
 public void updateNote(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException {
   User user = (User) session.getAttribute(Constant.USER);
   int noteId = DataHandle.returnValueInt(request, "noteId");
   String content = DataHandle.returnValue(request, "content");
   Note note = new Note();
   note.setNoteId(noteId);
   note = noteMapperService.select(note);
   if (note.getUserId() == user.getUserId()) {
     note.setContent(content);
     noteMapperService.update(note);
     JSONObject jsonObject = new JSONObject();
     jsonObject.put("result", "success");
     jsonObject.put("message", "修改成功");
     response.getWriter().write(jsonObject.toString());
   }
 }
コード例 #5
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 @RequestMapping("my-deleteNote")
 public void deleteNote(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException {
   int noteId = DataHandle.returnValueInt(request, "noteId");
   Note note = new Note();
   note.setIds(noteId + "");
   noteMapperService.deleteByIds(note);
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("result", "success");
   jsonObject.put("message", "删除成功");
   response.getWriter().write(jsonObject.toString());
 }
コード例 #6
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 /** 获得时间树的年份和便签数 */
 @RequestMapping("returnTreeYear")
 public void returnTreeYear(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException {
   User user = (User) session.getAttribute(Constant.USER);
   Note note = new Note();
   note.setUserId(user.getUserId());
   List<Map<String, Object>> noteList = noteMapperService.selectYear(note);
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("result", "success");
   jsonObject.put("data", noteList);
   response.getWriter().write(jsonObject.toString());
 }
コード例 #7
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 @RequestMapping("returnNote")
 public void returnNote(
     HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException {
   int noteId = DataHandle.returnValueInt(request, "noteId");
   Note note = new Note();
   note.setNoteId(noteId);
   note = noteMapperService.select(note);
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("result", "success");
   jsonObject.put("data", note);
   response.getWriter().write(jsonObject.toString());
 }
コード例 #8
0
ファイル: NoteController.java プロジェクト: xjjaid13/datac
 @RequestMapping("my-addNote")
 public void addNote(HttpServletRequest request, HttpServletResponse response, HttpSession session)
     throws IOException {
   User user = (User) session.getAttribute(Constant.USER);
   String content = DataHandle.returnValue(request, "content");
   Note note = new Note();
   note.setContent(content);
   note.setCreateDate(TimeHandle.currentTime());
   note.setUserId(user.getUserId());
   noteMapperService.insert(note);
   JSONObject jsonObject = new JSONObject();
   jsonObject.put("result", "success");
   jsonObject.put("message", "新增成功");
   response.getWriter().write(jsonObject.toString());
 }