admin
2021-10-12 664cc2fd39177fd3daa6d3988396c704d130882c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
    }
 
}