不要用它自带的
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">
SELECT
di.*
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);
}
}
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » mybatisplus多条件对象xml分页查询
发表评论 取消回复