MyBatisPlus框架sql书写时,有关大于或小于号的使用,如果不拼接sql(查询时条件拼接)直接>或<即可,如果拼接sql的话,需要使用 > 和<进行比较.示例代码如下:
@Select("<script>" +
"SELECT detail.latoId,IFNULL(detail.classify,'') AS classify,detail.latoId AS maintainId,plan.planNo,detail.machineName," +
"detail.machineId,detail.maintainDate AS planDate,detail.lastMaintainDate,detail.lastMaintenanceContent,detail.maintenanceContent,detail.model " +
" from " + EntityMap.MAINTAIN_INFO + " AS plan" +
" LEFT JOIN " + EntityMap.MAINTAIN_DETAIL + " AS detail ON plan.latoId=detail.formId " +
" LEFT JOIN " + EntityMap.DEVICE_INFO + " AS info ON detail.machineId=info.machineId " +
" where detail.maintainDate < DATE(NOW()) " +
"<if test='time !=null '>AND detail.maintainDate > #{time}</if>" +
"<if test='endTime !=null '> AND detail.endDate BETWEEN detail.endDate AND #{endTime} </if>" +
"<if test='shop !=null '> AND info.department=#{shop} </if>" +
"<if test='classify !=null '> AND detail.classify=#{classify} </if>" +
"<if test='item !=null '> AND detail.maintenanceContent like concat(concat('%',#{item},'%')) </if>" +
" ORDER BY plan.planDate DESC limit #{startRow},#{pageSize}" +
"</script>")