public ResponseResult bind(DriverCarBindingRelationship driverCarBindingRelationship){
/*
* 判断:在绑定司机和车辆关系之前,先判断一下二者之间是否已经绑定,如果已经绑定过,则不容许再绑定
* */
QueryWrapper<DriverCarBindingRelationship> queryWrapper = new QueryWrapper<>(); //查询包装器
//多种条件情况下进行查询,以下三种情况必须满足
queryWrapper.eq("driver_id",driverCarBindingRelationship.getDriverId());
queryWrapper.eq("car_id",driverCarBindingRelationship.getCarId());
queryWrapper.eq("bind_state",DriverCarConstants.DRIVER_CAR_BIND);
Integer integer = driverCarBindingRelationshipMapper.selectCount(queryWrapper);
if(integer.intValue()>0){
return ResponseResult.fail(CommonStatusEnum.DRIVER_CAR_BIND_EXIST.getCode(),CommonStatusEnum.DRIVER_CAR_BIND_EXIST.getValue());
}
}
底层运行结果:文章来源:https://www.toymoban.com/news/detail-635108.html
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@66061384] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@704441103 wrapping com.mysql.cj.jdbc.ConnectionImpl@4e911e70] will not be managed by Spring
> Preparing: SELECT COUNT( * ) FROM driver_car_binding_relationship WHERE (driver_id = ? AND car_id = ? AND bind_state = ?)
> Parameters: 53(Long), 6(Long), 1(Integer)
< Columns: COUNT( * )
< Row: 0
<== Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@66061384]文章来源地址https://www.toymoban.com/news/detail-635108.html
到了这里,关于QueryWrapper中eq的用法案例的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!