From 9ee2776bdd158212e1591ecd1434e6cfe33765ee Mon Sep 17 00:00:00 2001 From: simontigers <47096077+simontigers@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:26:58 +0800 Subject: [PATCH] fix(api): common i18n wide (#351) * fix(api): common_i18n wide * fix(api): department i18n --- cmdb-api/api/lib/common_setting/department.py | 3 +++ cmdb-api/api/lib/common_setting/employee.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cmdb-api/api/lib/common_setting/department.py b/cmdb-api/api/lib/common_setting/department.py index d63d43b..9d11785 100644 --- a/cmdb-api/api/lib/common_setting/department.py +++ b/cmdb-api/api/lib/common_setting/department.py @@ -385,6 +385,9 @@ class DepartmentCRUD(object): d['employee_count'] = len(list(filter(lambda e: e['department_id'] in d_ids, all_employee_list))) + if int(department_parent_id) == -1: + d['department_name'] = ErrFormat.company_wide + return all_departments, department_id_list @staticmethod diff --git a/cmdb-api/api/lib/common_setting/employee.py b/cmdb-api/api/lib/common_setting/employee.py index 804c514..2836919 100644 --- a/cmdb-api/api/lib/common_setting/employee.py +++ b/cmdb-api/api/lib/common_setting/employee.py @@ -296,6 +296,8 @@ class EmployeeCRUD(object): for r in pagination.items: d = r.Employee.to_dict() d['department_name'] = r.Department.department_name if r.Department else '' + if r.Employee.department_id == 0: + d['department_name'] = ErrFormat.company_wide employees.append(d) return {