package org.yeshi.utils.generater.util;
|
|
import org.springframework.data.annotation.Id;
|
|
import java.lang.annotation.Annotation;
|
import java.lang.reflect.Field;
|
|
/**
|
* @author Administrator
|
* @title: EntityUtil
|
* @description: 实体帮助类
|
* @date 2021/10/11 12:13
|
*/
|
public class EntityUtil {
|
|
//获取主键ID
|
public static Field getIdentifyId(Class clazz) {
|
Field[] fs = clazz.getDeclaredFields();
|
for (Field fd : fs) {
|
Annotation[] as = fd.getAnnotations();
|
if (as != null)
|
for (Annotation a : as) {
|
if (a instanceof Id) {
|
return fd;
|
}
|
}
|
}
|
return null;
|
}
|
|
}
|