背景:
springboot项目,使用mybatis-plus,实现模糊查询
public interface BedequipmentMapper extends BaseMapper<Bedequipment> {
List<Bedequipment> getEquipmentFrontList(Page<Bedequipment> page,EquipmentQuery equipmentQuery);
}
parameterType="cn.moonmark.equipmentservice.entity.vo.EquipmentQuery"
resultType="cn.moonmark.equipmentservice.entity.Bedequipment">
SELECT
a.bedEquipmentId,
a.wirelessMAC,
a.bedBehaviorTime,
a.bedBehaviorVersion,
a.isBed,
b.bedUpgradeTypeName
FROM bedequipment a
LEFT JOIN bedupgradetype b ON a.upgradeType = b.bedUpgradeTypeId
<where>
<if test="bedEquipmentId != null and bedEquipmentId != ''">
and a.bedEquipmentId like concat('%',#{bedEquipmentId},'%')
</if>
...
</where>
ORDER BY a.bedBehaviorTime DESC
</select>
报错点:
BindingException: Parameter 'bedEquipmentId ' not found. Available parameters are [arg1, arg0, param1, param2]
根据报错内容,可以大致知道是参数识别问题。
经过测试,单个参数不影响查询,多个参数会报错。
所以需要在List<Bedequipment> getEquipmentFrontList(Page<Bedequipment> page,EquipmentQuery equipmentQuery);
的参数前添加注解 @param
@Component(value = "BedequipmentMapper")
public interface BedequipmentMapper extends BaseMapper<Bedequipment> {
List<BedequipmentResult> getEquipmentFrontList(Page<BedequipmentResult> page,
@Param("query") EquipmentQuery equipmentQuery);
}
即可。