修改了实体父类

master
星期八 5 years ago
parent e8aa0312bd
commit eebe2021c9
  1. 11
      src/main/java/com/lq/code/entity/IdEntity.java

@ -1,7 +1,10 @@
package com.lq.code.entity; package com.lq.code.entity;
import com.lq.code.util.BeanUtil;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.List;
/** /**
* Created by qi on 2017/7/16. * Created by qi on 2017/7/16.
@ -37,9 +40,8 @@ public class IdEntity implements Serializable {
public String toString() { public String toString() {
StringBuffer stringBuffer=new StringBuffer(); StringBuffer stringBuffer=new StringBuffer();
Class clazz=this.getClass(); Class clazz=this.getClass();
Field[] fields=clazz.getDeclaredFields(); List<Field> fieldList = BeanUtil.getAllField(clazz);
stringBuffer.append("id:"+this.getId()+"\n"); fieldList.forEach((field)->{
for (Field field:fields){
field.setAccessible(true); field.setAccessible(true);
Object val=null; Object val=null;
try { try {
@ -48,7 +50,8 @@ public class IdEntity implements Serializable {
e.printStackTrace(); e.printStackTrace();
} }
stringBuffer.append(field.getName()+":"+val+"\n"); stringBuffer.append(field.getName()+":"+val+"\n");
}
});
return stringBuffer.toString(); return stringBuffer.toString();
} }
} }

Loading…
Cancel
Save