12345678910111213141516171819202122232425 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- from sqlalchemy.orm import Session
- from sqlalchemy import text, exists, and_, or_, not_
- from sqlalchemy.sql import func
- from database import get_db
- from models import *
- from extensions import logger
- from utils import *
- # 根据经纬度获取地区代码
- def get_region_code_by_gps(db: Session, lng: str, lat: str):
- return "4409"
- def id_get_area_info(db: Session,id):
- query = db.query(GovdataArea)
- query = query.filter(GovdataArea.id == id)
- return query.first()
- def id_get_area_parent_list(db: Session,id,li:list = []):
- area = id_get_area_info(db,id)
- # print({"id":id,'label':area.area_name})
- li.append({"id":id,'label':area.area_name})
- if area.parent_id<=1:
- return li[::-1]
- return id_get_area_parent_list(db,area.parent_id,li)
|