1234567891011121314151617181920212223242526272829303132 |
- '''Get space from database.
- '''
- from relations import test
- def get_space_data(floor_id,space_type):
- '''Cache space from database by floor_id,space_type.
- :param floor_id:
- :param space_type:
- :return:
- '''
- sql = "select " \
- "id,name,local_id,local_name,floor_id,outline,object_type" \
- "from zone_space_base " \
- "where floor_id='%s' " \
- "and object_type='%s' " \
- % (floor_id, space_type)
- COMPONENT_KEYS = [
- 'id',
- 'name',
- 'local_id',
- 'local_name',
- 'floor_id',
- 'outline',
- 'object_type'
- ]
- data = test.get_data(sql)
- element_data = []
- element_data.extend(utils.get_dicdata(data, COMPONENT_KEYS))
- element_data = list(map(utils.dic2obj, element_data))
- objects = utils.sqldata2objlist(element_data)
- return objects
|