当前位置: 首页 > news >正文

超详细超实用!!!零基础java开发之云风笔记接口开发之删除笔记(十一)

云风网
云风笔记
云风知识库

一、service/NoteApi新增delNode接口定义

public interface NoteApi {...int deleteNote(NoteManage noteManage);
}

二、service/impl/NoteServiceImpl接口实现逻辑

public class NoteServiceImpl implements NoteApi {@AutowiredNoteMapper noteMapper;...public int delNote(int id){int count = 0;try {count = noteMapper.delNote(id);}catch (Exception err){System.out.println(err);}return count;}}

三、mapper/NoteMapper新增接口

...
import org.apache.ibatis.annotations.Param;public interface NoteMapper {...int delNote(int noteId);
}
四、新增sql语句
<delete id="delNote">DELETE FROM note WHERE id = #{id}
</delete>
五、NoteManage添加获取id/设置id

之前更新接口已经声明,这里不用变更代码

六、控制类NoteController新增更新逻辑
 @RequestMapping(value = "/delNote",method = RequestMethod.POST)
public Response delNote(@RequestBody NoteManage noteManage){int id = noteManage.getNoteId();if(id!=0){int count = service.delNote(id);if(count>0){Response response = new Response(true,"删除成功",200);return response;}else {Response response = new Response(false,"删除失败",400);return response;}}else {Response response = new Response(false,"删除失败,请传入id",400);return response;}
}
六、接口请求测试

数据库原数据

在这里插入图片描述

删除笔记

在这里插入图片描述

在这里插入图片描述

删除成功!!!


http://www.mrgr.cn/news/29542.html

相关文章:

  • Python精选200Tips:141-145
  • Mybatis+Druid+MybatisPlus多数据源配置
  • 高效音频格式转换实战:使用Python和FFmpeg处理MP3到WAV的转换20240918
  • 启程Pulsar:深入剖析高速启动引擎,揭秘消息中间件巨兽的诞生
  • Matlab 的.m 文件批量转成py文件
  • Vue|mixin混入
  • YOLOv8 OBB win10+ visual 2022移植部署
  • 如何使用宝塔面板安装中间件
  • Fastdds_ContentFilteredTopicExample_代码剖析5_create_publisher
  • 【C++】多态的认识和理解
  • Java 中的 sleep、wait、join 怎么理解
  • Verdin AM62 引脚复用配置
  • 【MySQL】MySQL连接池原理与简易网站数据流动是如何进行
  • yaml注入配置文件
  • IEEE-754 32位十六进制数 转换为十进制浮点数
  • 游戏开发应具备的心理学知识
  • 【Python机器学习】NLP信息提取——正则模式
  • Kubernetes从零到精通(12-Ingress、Gateway API)
  • Sqlmap中文使用手册 - File system access模块参数使用
  • 米壳AI:跨境电商必备:不损失原图的图片翻译工具!