Field[] fields = params.getClass().getDeclaredFields(); try { for (Field field : fields) { field.setAccessible(true); String name = field.getName(); String methodName = "get" + name; for (Method method : declaredMethods) { if (method.getName().equalsIgnoreCase(methodName)) { String invoke = (String) method.invoke(params); if(StringUtils.isNotBlank(invoke)){ objectQueryWrapper.eq(name, method.invoke(params)); } } } } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); }
标签:实体类,String,invoke,name,field,逐一,params,method,赋值 From: https://www.cnblogs.com/zhiyong-666/p/17610314.html