From eebe2021c98421baffb90b7dd0fcc01b8d3c4229 Mon Sep 17 00:00:00 2001 From: qi_liang Date: Thu, 22 Aug 2019 08:40:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E7=88=B6=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/lq/code/entity/IdEntity.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lq/code/entity/IdEntity.java b/src/main/java/com/lq/code/entity/IdEntity.java index 1ccee75..e7cd4c7 100755 --- a/src/main/java/com/lq/code/entity/IdEntity.java +++ b/src/main/java/com/lq/code/entity/IdEntity.java @@ -1,7 +1,10 @@ package com.lq.code.entity; +import com.lq.code.util.BeanUtil; + import java.io.Serializable; import java.lang.reflect.Field; +import java.util.List; /** * Created by qi on 2017/7/16. @@ -37,9 +40,8 @@ public class IdEntity implements Serializable { public String toString() { StringBuffer stringBuffer=new StringBuffer(); Class clazz=this.getClass(); - Field[] fields=clazz.getDeclaredFields(); - stringBuffer.append("id:"+this.getId()+"\n"); - for (Field field:fields){ + List fieldList = BeanUtil.getAllField(clazz); + fieldList.forEach((field)->{ field.setAccessible(true); Object val=null; try { @@ -48,7 +50,8 @@ public class IdEntity implements Serializable { e.printStackTrace(); } stringBuffer.append(field.getName()+":"+val+"\n"); - } + + }); return stringBuffer.toString(); } }