实体对象转QueryWrapper 便捷实现条件查询
mybatis plus中提供了QueryWrapper做条件查询,
方法定义是public Children eq(boolean condition,R column,java.lang.Object val)
参数:condition – 执行条件;column – 字段;val – 值
我们通常是这样写的,
1 public IhTimeSchedule getTimeSchedule(String serviceCode,String appointDate, String noonType, 2 String appointTimeInterval, String deptCode, String doctorCode, 3 String clinicTypeCode,String serviceType) { 4 QueryWrapper<IhTimeSchedule> wrapper=new QueryWrapper<IhTimeSchedule>() 5 .eq("DEPT_CODE",deptCode) 6 .eq("SERVICE_CODE",serviceCode) 7 .eq(StringUtils.isNotBlank(doctorCode),"DOCTOR_CODE",doctorCode) 8 .eq("CLINIC_DATE",appointDate+" 00:00:00") 9 .eq(StringUtils.isNotBlank(noonType),"NOON_TYPE",noonType). 10 eq(StringUtils.isNotBlank(appointTimeInterval),"TIME_DIVISION",appointTimeInterval). 11 eq("CLINIC_TYPE_CODE",clinicTypeCode); 12 IhTimeSchedule schedule = scheduleMapper.selectOne(wrapper); 13 return schedule; 14 }