@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()); }
@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()); } }
@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()); }
@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()); }
@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()); }