您的位置:首页 > 游戏 > 游戏 > mybatisplus多条件对象xml分页查询

mybatisplus多条件对象xml分页查询

2024/11/17 18:30:45 来源:https://blog.csdn.net/liuming690452074/article/details/139999908  浏览:    关键词:mybatisplus多条件对象xml分页查询

不要用它自带的

selectPage方法,会有传参问题

controller


import java.util.Set;@RestController
@RequiredArgsConstructor
@RequestMapping("/deviceInfo" )
public class DeviceInfoController {private final  DeviceInfoService deviceInfoService;/*** 分页查询* @param page 分页对象* @param queryDto 设备信息查询对象* @return*/@GetMapping("/page" )@PreAuthorize("@pms.hasPermission('proxy_deviceInfo_view')" )public R selectPage(Page page, @Validated(value = SelectVerify.class) DeviceInfoDTO queryDto) {return R.ok(deviceInfoService.selectForPage(page, queryDto));}}

Mapper

public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> {IPage<DeviceInfoVO> selectForPage(Page page, @Param("queryDto") DeviceInfoDTO queryDto);List<DeviceInfoVO> selectList(DeviceInfoDTO queryDto);
}

xml


<resultMap id="deviceInfoVoMap" type="xx.xx.vo.DeviceInfoVO"><id property="id" column="id"/><id property="groupId" column="group_id"/><id property="deviceNumber" column="device_number"/><id property="deviceCategory" column="device_category"/><id property="deviceType" column="device_type"/><id property="manufacturer" column="manufacturer"/><id property="deviceModel" column="device_model"/><id property="remark" column="remark"/><id property="createBy" column="create_by"/><id property="createTime" column="create_time"/><id property="updateBy" column="update_by"/><id property="updateTime" column="update_time"/></resultMap><select id="selectForPage" resultMap="deviceInfoVoMap">SELECTdi.*FROM device_info di<where><if test="queryDto.groupId != null">AND di.group_id = #{queryDto.groupId}</if><if test="queryDto.deviceNumber != null and queryDto.deviceNumber != ''">AND di.device_number = #{queryDto.deviceNumber}</if><if test="queryDto.deviceTypeCollection != null and queryDto.deviceTypeCollection.size > 0">AND di.device_type IN<foreach collection="queryDto.deviceTypeCollection" index="idx" item="item" separator="," open="(" close=")">#{item}</foreach></if></where>ORDER BY di.device_number ASC</select>

Server

public interface DeviceInfoService extends IService<DeviceInfo> {/*** 分页查询*/IPage<DeviceInfoVO> selectForPage(Page page, DeviceInfoDTO queryDto);}

impl


@Service
@RequiredArgsConstructor
public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceInfo> implements DeviceInfoService {public IPage<DeviceInfoVO> selectForPage(Page page, DeviceInfoDTO queryDto) {return baseMapper.selectForPage(page, queryDto);}}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com