对于mybatisplus的queryWrapper

对于mybatisplus的queryWrapper

1.分组分页查询

 QueryWrapper<IuNotice> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("count(*) as noticeNumber," +
                "standard_project_name as standardProjectName," +
                "modality as modality ,standard_second_body_part as standardSecondBodyPart")
                .groupBy("standard_project_name,modality,standard_second_body_part")
                .eq("operate_type_id", checkAnalysisVo.getOperateTypeId())
                .eq(StringUtils.isNotEmpty(checkAnalysisVo.getModality()), "modality", checkAnalysisVo.getModality())
                .ge("notice_time", checkAnalysisVo.getStartTime())
                .lt("notice_time", checkAnalysisVo.getEndTime())
                .like(StringUtils.isNotEmpty(checkAnalysisVo.getStandardProjectName()), "standard_project_name", checkAnalysisVo.getStandardProjectName())
                .like(StringUtils.isNotEmpty(checkAnalysisVo.getStandardSecondBodyPart()), "standard_second_body_part", checkAnalysisVo.getStandardSecondBodyPart())
                .orderByDesc("noticeNumber");

请添加图片描述

 Preparing: SELECT count(*) as noticeNumber,standard_project_name as standardProjectName,modality as modality ,standard_second_body_part as standardSecondBodyPart FROM iu_notice WHERE (operate_type_id = ? AND notice_time >= ? AND notice_time < ?) GROUP BY standard_project_name,modality,standard_second_body_part ORDER BY noticeNumber DESC LIMIT ?
==> Parameters: 5(String), 2021-01-14 00:00:00(String), 2023-02-13 00:00:00(String), 10(Long)
<==    Columns: noticeNumber, standardProjectName, modality, standardSecondBodyPart
<==        Row: 563, CT胸部平扫, CT, 胸部
<==        Row: 228, CT头颅平扫, CT, 头颅
<==        Row: 196, CT头颅平扫, , 头颅
<==        Row: 110, CT胸部平扫, , 胸部
<==        Row: 75, DX左足正位片, DR, 左足
<==        Row: 61, CT盆腔平扫, CT, 盆腔
<==        Row: 56, DX胸部正位片, DR, 胸部
<==        Row: 44, CT眼睛平扫, , 眼睛
<==        Row: 38, DX左足斜位片, DR, 左足
<==        Row: 28, DX右侧腕关节侧位片, DR, 右侧腕关节
<==      Total: 10

请添加图片描述

//mp中使用的一些方法
.last("limit 5")//取五条
.isNotNull("standard_project_name")//is not null
.ne("standard_project_name", "")//不等于
.ge("operate_time", checkAnalysisVo.getStartTime())//大于等于 gt是大于
.lt("operate_time", checkAnalysisVo.getEndTime())//小于  le是小于等于

请添加图片描述

2.注解的方式实现

//注解的方式实现
@DS("clickhouse")
@Select("select count(his_user_id) from iu_digital_images_analysis.iu_operate " +
        "where hospital_id=#{hospitalId} and operate_type_id=#{operateTypeId}")
Integer queryCountUseTimesByHospitalId(@Param("operateTypeId") String operateTypeId, @Param("hospitalId") String hospitalId);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值