日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 索取了多表联合查询分页,mybatis-plus多表联合分页查询

發布時間:2024/10/8 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 索取了多表联合查询分页,mybatis-plus多表联合分页查询 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.entity層要寫個Vo實體類

2.controller

@AutoLog(value = "員工CURD-分頁列表查詢")

@ApiOperation(value="員工CURD-分頁列表查詢", notes="員工CURD-分頁列表查詢")

@GetMapping(value = "/list")

public Result> queryPageList(EmployeeVo employee,

@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,

@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,

HttpServletRequest req) {

//QueryGenerator.initQueryWrapper是jeecg-boot封裝的查詢,默認支持所有復雜的檢索查詢

QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(employee, req.getParameterMap());

Page page = new Page(pageNo, pageSize);

//自定義getAll接口

IPage pageList=employeeService.getAll1(page,queryWrapper);

return Result.ok(pageList);

}

3.servlce

4.mapper.java

public interface EmployeeMapper extends BaseMapper {

/**

* mybatis-plus多表查詢

* @param page

* @param wrapper

* @return

*/

[email?protected](Constants.WRAPPER),xml里加上${ew.customSqlSegment}可以實現復雜條件檢索查詢

IPage findByPage(IPage page, @Param(Constants.WRAPPER) Wrapper wrapper);

}

5.mapper.xml

select employee.*,department.dep_name from employee left join department

on employee.sys_org_code = department.id ${ew.customSqlSegment}

6.查詢出來的結果

{

"success": true,

"message": "操作成功!",

"code": 200,

"result": {

"records": [

{

"createTime": "2020-10-14 16:35:36",

"sex": "女",

"name": "helloTest",

"updateTime": "2020-10-14 16:41:41",

"id": "1316296704307597313",

"depName": "研發部",//這個是部門表中的字段,同過兩表聯查查詢出來的

"age": 23,

"hobby": "打牌"

},

{

"createTime": "2020-08-01 16:50:04",

"sex": "男",

"name": "薩芬",

"updateTime": "2020-09-17 16:50:07",

"id": "2",

"depName": "人事部",

"age": 12,

"hobby": "阿斯頓"

}

],

"total": 2,

"size": 10,

"current": 1,

"orders": [],

"optimizeCountSql": true,

"hitCount": false,

"searchCount": true,

"pages": 1

},

"timestamp": 1602729521729

}

原文:https://www.cnblogs.com/exmyth/p/14342613.html

總結

以上是生活随笔為你收集整理的java 索取了多表联合查询分页,mybatis-plus多表联合分页查询的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。