package com.bohuikeji.frame.module.admin.comparator;


import com.bohuikeji.frame.module.admin.annotation.TableQueryField;
import com.bohuikeji.frame.module.admin.annotation.TableShowField;
import java.lang.reflect.Field;
import java.util.Comparator;

/**
 * 字段排序
 */
public class FieldComparator implements Comparator<Field> {
    @Override
    public int compare(Field o1, Field o2) {
        if(o1.getAnnotation(TableQueryField.class).sort()<o2.getAnnotation(TableQueryField.class).sort()){
            return -1;
        }
        if (o1.getAnnotation(TableQueryField.class).sort()>o2.getAnnotation(TableQueryField.class).sort()){
            return 1;
        }
        return 0;
    }
}
