feat(root):add mysql
This commit is contained in:
@@ -277,11 +277,31 @@ class MongoEngine(AbstractEngineClass):
|
||||
os.makedirs(temp_dir, exist_ok=True)
|
||||
return temp_dir
|
||||
|
||||
def _expand_headers_with_id_fields(self, cols: dict) -> list:
|
||||
"""
|
||||
اگر design.nature در فیلدها باشد، design.nature_id هم اضافه میشود.
|
||||
اگر design.budget در فیلدها باشد، design.budget_id هم اضافه میشود.
|
||||
"""
|
||||
headers = list(cols.keys())
|
||||
expanded = []
|
||||
pair_rules = [
|
||||
('design.nature', 'design.nature_id', 'نام ماهیت'),
|
||||
('design.budget', 'design.budget_id', 'نام دسته بودجه'),
|
||||
]
|
||||
for h in headers:
|
||||
expanded.append(h)
|
||||
for field, id_field, default_title in pair_rules:
|
||||
if h == field and id_field not in headers and id_field not in expanded:
|
||||
expanded.append(id_field)
|
||||
cols[id_field] = cols.get(field, default_title) + ' (نام)'
|
||||
break
|
||||
return expanded
|
||||
|
||||
async def output_generator(self, query, file_name, cols):
|
||||
datas = query
|
||||
file_dir = os.path.join(self._excel_temp_dir(), file_name)
|
||||
head_cols = list(str(string.ascii_uppercase))
|
||||
headers = list(cols.keys())
|
||||
headers = self._expand_headers_with_id_fields(cols)
|
||||
|
||||
workbook = xlsxwriter.Workbook(file_dir)
|
||||
worksheet = workbook.add_worksheet()
|
||||
|
||||
Reference in New Issue
Block a user