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

超详细超实用!!!零基础java开发之云风笔记笔记列表接口条件查询(九)

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

笔记列表数据接口条件查询,一般是分页获取/以及各个参数查询获取数据

1、改造service/NoteApi接口定义

原有定义:

public interface NoteApi {...List<NoteManage> getNoteList();
}

现加入name/content参数

public interface NoteApi {...List<NoteManage> getNoteList(String searchName,String name,String content);
}
2、改造service/impl/NoteServiceImpl接口实现
public List<NoteManage> getNoteList(String searchName,String name,String content){return noteMapper.getNoteList(searchName,name,content);
}
3、改造mapper/NoteMapper
public interface NoteMapper {...List<NoteManage> getNoteList(String searchName,String name,String content);
}
4、改造sql语句
<select id="getNoteList" resultType="com.example.study.note.NoteManage">SELECT * FROM `note`<where><if test="searchName!= null and searchName!= ''">and name like concat('%',#{searchName},'%') or type like concat('%',#{searchName},'%') or content like concat('%',#{searchName},'%')</if><if test="name!= null and name!= ''">and name like concat('%',#{name},'%')</if><if test="content!= null and content!= ''">and content like concat('%',#{content},'%')</if></where>
</select >
5、改造NoteManage

已存在setName/getName、setContent/getContent。所以不需要变更逻辑代码

6、改造控制类NoteController
@RequestMapping(value = "/getNoteList",method = RequestMethod.POST)
public Response getNoteList(@RequestBody NoteManage noteManage){String searchName = noteManage.getSearchName();String name = noteManage.getName();String content = noteManage.getContent();Response response = new Response();List<NoteManage> noteList = service.getNoteList(searchName,name,content);response.setResponse(true,"查询成功",200,noteList);return response;
}
7、测试接口请求

在这里插入图片描述
在这里插入图片描述


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

相关文章:

  • C CS3214
  • 产品经理有必要学习大模型技术吗?
  • 数据治理新时代:掌握关键的数据提取技术
  • ai头像免费软件有哪些?卡哇伊头像用这些
  • 【Springboot】——响应与分层解耦架构
  • 如何利用AI进行有效的科技产品发布
  • idea 中MyBatisX插件没有出现蓝色鸟
  • 突破空间限制:4个远程控制电脑的办法
  • 十大最佳电子商务市场广告工具,助力提升你的业务
  • go-orm接口原生到框架
  • 印度2024年节日季节的数字营销趋势
  • 国产开源大语言模型优劣大盘点
  • GaussDB关键技术原理:高弹性(五)
  • 碳化硅肖特基二极管B3D50120H2高速开关与低损耗的完美结合
  • 金言问卷:国外问卷调查可以做吗?
  • 教程 | ArcGIS Pro如何自动保存数据编辑内容
  • 我的AI工具箱Tauri版-VideoClipMixingCut视频批量混剪
  • 镍镉离子电池
  • 运动耳机什么牌子质量好?五大超赞顶流机型汇总
  • 超详细!CEC2017测试函数最全公式图像介绍与调用方法 Matlab代码免费获取