将dataframe转化为tree结构,代码是django代码.转换成普通python代码就是不要request和JSONREsponse即可
ROOT_NODE_PARENT_ID 是最上层的根节点.
def resource_data_tree(request):
res = []
resource_data_sql = "select * from resource_data_tree where is_active=1"
resource_data_df = download_data_from_db(resource_data_sql)
# TODO:将resource_data_tree缓存进redis
tree_df = resource_data_df[resource_data_df['parent_node_id'] == ROOT_NODE_PARENT_ID]
if not tree_df