package com.bonus.canteen.core.common.utils;

import com.bonus.common.core.exception.ServiceException;

import java.lang.reflect.Field;

public class ObjectUtils {
    public static void setAllFieldsToNull(Object obj) {
        for (Field field : obj.getClass().getDeclaredFields()) {
            field.setAccessible(true);
            try {
                field.set(obj, null);
            } catch (IllegalAccessException e) {
                throw new ServiceException("系统异常");
            }
        }
    }
}
