使用注解的方式动态查询Sql
@Select(value = {" <script>" +
" SELECT tb_car.* FROM tb_car " +
" <where> 1=1 " +
" <if test=\" carType !=null \" > AND tb_car.car_type =#{carType}</if> " +
" <if test=\" goodsType !=null \" > AND tb_car.goods_type =#{goodsType}</if> " +
" <if test=\" lineType!=null \" > AND tb_car.line_type =#{lineType}</if> " +
" <if test=\"startAddress != null \" > AND tb_car.start_address=#{startAddress}</if> " +
" <if test=\"endAddress != null \" > AND tb_car.end_address=#{endAddress}</if> " +
" <if test=\"maxPrice != null \" > AND tb_car.price <= #{maxPrice} </if> " +
" <if test=\"minPrice != null \" > AND tb_car.price >=#{minPrice} </if> " +
" <if test=\" maxWeight != null \" > AND tb_car.car_weight <= #{maxWeight}</if> " +
" <if test=\" minWeight != null \" > AND tb_car.car_weight >=#{minWeight}</if> " +
" </where>" +
"order by tb_car.id ASC"+
" </script>"})
List<Car> selectListCar(@Param("carType") Integer carType, @Param("endAddress") String endAddress,
@Param("startAddress") String startAddress, @Param("goodsType") Integer goodsType, @Param("lineType") Integer lineType,
@Param("maxPrice") Double maxPrice,@Param("minPrice") Double minPrice,@Param("minWeight") Double minWeight,@Param("maxWeight") Double maxWeight);