云风网
 云风笔记
 云风知识库
笔记列表数据接口除了获取全部数据,还需要考虑分页获取/以及各个参数查询获取数据。这样才符合日常需要。
模糊查询一般是定义一个固定的查询参数searchName,查询同数据类型的参数,比如都是字符串数据类型。由于我们名称、类型、内容、备注都是字符串,所以可以都加上
1、改造service/NoteApi接口定义
原有定义:
public interface NoteApi {
    ...
    List<NoteManage> getNoteList();
}
 
现加入searchName参数
public interface NoteApi {
	...
    List<NoteManage> getNoteList(String searchName);
}
 
2、改造service/impl/NoteServiceImpl接口实现
public List<NoteManage> getNoteList(String searchName){
   return noteMapper.getNoteList(searchName);
}
 
3、改造mapper/NoteMapper
public interface NoteMapper {
    ...
    List<NoteManage> getNoteList(String searchName);
}
 
4、改造sql语句
<select id="getNoteList" resultType="com.example.study.note.NoteManage">
    SELECT * FROM `note` where name like concat('%',#{searchName},'%') or type like concat('%',#{searchName},'%') or content like concat('%',#{searchName},'%')
</select >
 
5、改造NoteManage
private String searchName;
public NoteManage(String searchName) {
    this.searchName = searchName;
}
public void setSearchNameName(String searchName){
   this.searchName = searchName;
}
public String getSearchName(){
   return searchName;
}
 
6、改造控制类NoteController
@RequestMapping(value = "/getNoteList",method = RequestMethod.POST)
public Response getNoteList(@RequestBody NoteManage noteManage){
    String searchName = noteManage.getSearchName();
    Response response = new Response();
    List<NoteManage> noteList = service.getNoteList(searchName);
    response.setResponse(true,"查询成功",200,noteList);
    return response;
}
 
7、测试接口请求

 
 











![[渗透测试]-CVE-2016-4437-Shiro550漏洞复现](https://i-blog.csdnimg.cn/direct/ac5327e61af34c3cb1ce933cd5cde957.png)







