@classmethod
def to_dict(cls, obj, key='name'):
    """
        convert the object to dict

        :param obj:
        :return:
        """
    result = dict()
    for u in obj:
        if u is not None:
            values = {}
            for attribute in list(u.__dict__.keys()):
                if not attribute.startswith('_sa'):
                    values[attribute] = u.__dict__[attribute]
            result[values[key]] = values
    return result
