mybatis-plus 中 queryWrapper and与or嵌套

mybatis-plus 中 queryWrapper and与or嵌套
强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码
  • and ( ... or ... or...) 格式
queryWrapper.and(wrapper -> wrapper.like("project_name", keyWord)
					.or().like("initiate_units", keyWord)
					.or().like("aircraft_model", keyWord)
					.or().like("aircraft_number", keyWord));
AND ((project_name LIKE ? OR initiate_units LIKE ? OR aircraft_model LIKE ? OR aircraft_number LIKE ?))
  • or ( ... and  ... and ...) 格式
// 今天的日期
		String today= DateUtil.getDateTimeAsYYYYMMDD(LocalDateTime.now());
		flightplanSetQueryWrapper.eq("execute_date",today);
		// 昨天的日期
		String yesterday=DateUtil.pushDay(-1);
		//昨天实施中的场次
		flightplanSetQueryWrapper.or(wrapper -> wrapper.eq("execute_date", yesterday).eq("implementation_status",Constants.FLIGHT_PLAN_SET_IMPLEMENTATION_STATUS_OF_UNDER));
		flightplanSetQueryWrapper.eq("del_flag",Constants.DEL_FLAG_NORMAL);
WHERE (execute_date = ? OR ((execute_date = ? AND implementation_status = ?)) AND del_flag = ?) 

 

本文来源huayang183,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/18447

发表评论