private void setAuditFields()

in bigtop-manager-dao/src/main/java/org/apache/bigtop/manager/dao/interceptor/AuditingInterceptor.java [93:118]


    private void setAuditFields(Object object, SqlCommandType sqlCommandType) throws IllegalAccessException {
        Long userId = currentUser.get();
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

        List<Field> fields = ClassUtils.getFields(object.getClass());

        for (Field field : fields) {
            boolean accessible = field.canAccess(object);
            field.setAccessible(true);
            if (field.isAnnotationPresent(CreateBy.class)
                    && SqlCommandType.INSERT == sqlCommandType
                    && userId != null) {
                field.set(object, userId);
            }
            if (field.isAnnotationPresent(CreateTime.class) && SqlCommandType.INSERT == sqlCommandType) {
                field.set(object, timestamp);
            }
            if (field.isAnnotationPresent(UpdateBy.class) && userId != null) {
                field.set(object, userId);
            }
            if (field.isAnnotationPresent(UpdateTime.class)) {
                field.set(object, timestamp);
            }
            field.setAccessible(accessible);
        }
    }