1、官方网站:https://bs.zhxu.cn/guide/latest/introduction.html
2、pom
<!-- SpringBoot / Grails 的项目直接使用以下依赖,更为方便(只添加这一个依赖即可) -->
<dependency>
<groupId>cn.zhxu</groupId>
<artifactId>bean-searcher-boot-starter</artifactId>
<version>4.2.7</version>
</dependency>
3、内连接查询
(1)查询实体
@SearchBean(
tables = "student_course r inner join student s on s.id = r.student_id inner join course c on c.id = r.course_id",
autoMapTo = "s"
)
@Data
public class StudentVo {
@DbField("s.id")
private Integer id;
@DbField("s.name")
private String studentName;
@DbField("c.name")
private String courseName;
private String grade;
private Integer age;
private String birthday;
private String gender;
}
(2)调用
@Resource
private MapSearcher mapSearcher;
@GetMapping("/index")
public SearchResult<Map<String, Object>> index(){
return mapSearcher.search(StudentVo.class);
}
(3)返回结果
{
"totalCount": 2,
"dataList": [
{
"birthday": "2005-01-23",
"courseName": "法学",
"gender": "男",
"studentName": "张三",
"grade": "计算221",
"id": 1,
"age": 19
},
{
"birthday": "2005-01-23",
"courseName": "金融学",
"gender": "女",
"studentName": "李四",
"grade": "计算221",
"id": 2,
"age": 19
}
],
"summaries": []
}