2024年5月11日发(作者:)

* @return Map

* @throws IllegalAccessException 类型转换时报错

*/

private static Map changeValueToMap(Object entity) throws IllegalAccessException {

Map resultMap = new HashMap<>();

Field[] fields = ss().getDeclaredFields();

for (Field field : fields) {

String name = e();

if (able(entity, name) && eable(entity, name)) {

if (tationPresent()) {

Description anno = otation();

//获取private对象字段值

essible(true);

((), (entity));

}

}

}

return resultMap;

}

}

/**

* @author huangzhihua

* @date 2020/11/7

*/

@Data

@Builder

public class User extends Base {

@Description(name = "id", ignore = true)

public Long id;

@Description(name = "姓名")

private String name;

@Description(name = "年龄")

private Integer age;

@Description(name = "描述")

private String desc;

@Override

EnumTableName getTableName() {

return ;

}

}

/**

* @author huangzhihua

* @date 2020/11/9

*/

public enum EnumTableName {

User("user");

EnumTableName(String tableName) {

ame = tableName;

}

private String tableName;

public String getTableName() {

return tableName;

}

}

@Test

void test() {

User user1 = r().id(1L).name("jack").age(19).desc("my name").build();

User user2 = r().id(1L).name("rose").age(18).desc("my name").build();

try {

UnityLog log = Log(, user1);

n("log = " + log);

} catch (IllegalAccessException e) {

tackTrace();

}

}