note_cloud--删除笔记功能
来源:互联网 发布:化妆品好坏知多少 txt 编辑:程序博客网 时间:2024/06/06 08:30
笔记的删除功能
发送Ajax请求
绑定事件:监听alert页面创建按钮(给按钮增加ID:deleteNote)
$("#can").on("click","#deleteNote",function(){});
获取参数:笔记ID
var $li=$("#note_ul a.checked").parent();var noteId=$li.data("noteId");
发送请求: /note/delete.do
服务器处理
DeleteNoteController.execute(String noteId)
NoteService.deleteNote(String noteId);
NoteDao.update(String noteId)
Mapper:
<update id="update" parameterType="String">update cn_note set cn_note_status_id='2'where cn_note_id=#{id}</update>
Ajax回调处理
success:
删除笔记列表中的li元素
提示:笔记删除成功
success:function(result){ if(result.state==0){ $li.remove(); alert("删除笔记成功"); } }
error:提示笔记删除失败
代码如下:
----------------------------------------------------------------------------------------
Dao接口:
//删除笔记(本质是修改cn_note_status_id =2)public int update(String noteId);返回int值,若为1,则表示更新成功
----------------------------------------------------------------------------------------
映射文件:
<!-- 删除笔记(本质是修改cn_note_status_id =2) --> <update id="update" parameterType="string"> update cn_note set cn_note_status_id = '2' where cn_note_id = #{id} </update>
----------------------------------------------------------------------------------------
业务层接口:
//删除笔记(本质是修改cn_note_status_id =2)public NoteResult<Object> deleteNote(String noteId);
----------------------------------------------------------------------------------------
业务层实现类:
//删除笔记(本质是修改cn_note_status_id =2)public NoteResult<Object> deleteNote(String noteId) {NoteResult<Object> result = new NoteResult<Object>();int rows = dao.update(noteId);if(rows == 0){result.setStatus(1);result.setMsg("删除笔记失败");return result;}result.setStatus(0);result.setMsg("删除笔记成功");return result;}
----------------------------------------------------------------------------------------
控制层Controller:
package cn.tedu.cloud_note.controller;import javax.annotation.Resource;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import cn.tedu.cloud_note.service.NoteService;import cn.tedu.cloud_note.util.NoteResult;@Controller@RequestMapping("/note")public class DeleteNoteController {@Resource(name="noteService")private NoteService service;@RequestMapping("/delete.do")@ResponseBodypublic NoteResult<Object> execute(String noteId){NoteResult<Object> result = service.deleteNote(noteId);return result;}}
----------------------------------------------------------------------------------------
HTML部分代码:
//笔记下拉按钮的删除按钮弹出对话框$("#note_ul").on("click",".btn_delete",alertDeleteNoteWindow);//功能(单击删除按钮,弹出删除页面成功后弹窗提示删除成功)$("#can").on("click","#deleteNote",deleteNote);
----------------------------------------------------------------------------------------
引用的JS代码:
//弹出删除笔记对话框function alertDeleteNoteWindow(){$("#can").load("alert/alert_delete_note.html");$(".opacity_bg").show();}-----------------------------------------------------------
//删除笔记function deleteNote(){//获取笔记IDvar $li = $("#note_ul a[class='checked']").parent();var noteId = $li.data("noteId");//console.log(noteId);//发送ajax请求$.ajax({url:path + "/note/delete.do",type:"post",data:{"noteId":noteId},dataType:"json",success:function(result){if(result.status == 0){console.log("OOKK");//将笔记列表中的笔记删除$li.remove();alert(result.msg);}},error:function(){alert("删除笔记失败");}});}
阅读全文
0 0
- note_cloud--删除笔记功能
- note_cloud--笔记分享功能
- note_cloud--登录功能
- note_cloud--注册功能
- note_cloud--笔记本加载功能
- note_cloud--修改密码功能
- note_cloud--加载笔记列表
- note_cloud--创建笔记
- note_cloud--搜索笔记功能(已经分享了的笔记)(两个功能)
- note_cloud--显示笔记下拉菜单
- note_cloud--编辑区域中的“保存笔记”--更新笔记信息
- note_cloud--单击笔记使笔记标题和内容显示在编辑区域
- note_cloud--创建笔记本
- nodejs实战express笔记之增加编辑与删除功能
- mybatis学习笔记-实现添加修改删除用户功能
- 简单删除功能
- SQL自动删除功能
- DataGrid中删除功能
- ARM Linux 3.x的设备树(Device Tree)
- 2017年8月5日 Ubuntu 14.04 修复日志
- MongoDB 存储引擎:WiredTiger和In-Memory
- 大话设计模式读后感之代理模式(JAVA)
- php常用函数
- note_cloud--删除笔记功能
- 不懂电脑出现的误解,你中招了没?
- 拓扑排序的原理及其实现
- QT在ubuntu下的安装
- 安装Python
- linux中磁盘加密配额阵列和lvm
- linux常用命令汇总1
- java 线程之executors线程池
- 事务管理之Hibernate事务管理