/** 获得时间树的天数和便签数 */ @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()); }
/** 获得时间树的年份和便签数 */ @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()); }
@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()); }
@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()); } }