def update_nodes_cache(node_uids): ''' 更新节点缓存 ''' print("update_nodes_cache", node_uids) nodes = Node.retrieve_nodes(node_uids) for node in nodes: node.update_cache()
def get_nodes(instance): ''' 管理节点范围 ''' if instance.scope_subject == 2: for node in Node.retrieve_nodes(instance.nodes): yield { 'node_uid': node.node_uid, 'node_subject': node.node_subject, 'name': node.name, }
def all_node_uids(self): ''' 所有直属节点以及隶属节点的uid ''' key = f'oneid:user:{self.username}:upstream_node' cache_data = cache.get(key) if cache_data is None: res = set() for parent_node in Node.retrieve_nodes(self.node_uids): res.update(parent_node.upstream_uids) cache.set(key, res) return res return cache_data