Przeglądaj źródła

根据语言获取国家进行排序

zhangdongming 2 lat temu
rodzic
commit
63c032cefa
1 zmienionych plików z 6 dodań i 5 usunięć
  1. 6 5
      Controller/RegionController.py

+ 6 - 5
Controller/RegionController.py

@@ -28,7 +28,7 @@ class RegionView(View):
         response = uidManageResponseObject()
         if operation == 'getCountry':
             return self.get_country(request_dict, response)
-        elif operation == 'getCountryAndDomainName':    # 获取国家和域名
+        elif operation == 'getCountryAndDomainName':  # 获取国家和域名
             return self.get_country_and_domain_name(request_dict, response)
         else:
             token = TokenObject(request_dict.get('token', None))
@@ -276,7 +276,8 @@ class RegionView(View):
                 lang_qs = LanguageModel.objects.filter(lang='en')
 
             lang = lang_qs[0]
-            country_qs = CountryLanguageModel.objects.filter(language_id=lang.id).values('country_name', 'country__number')
+            country_qs = CountryLanguageModel.objects.filter(language_id=lang.id).values('country_name',
+                                                                                         'country__number')
 
             return response.json(0, list(country_qs))
         else:
@@ -285,7 +286,7 @@ class RegionView(View):
     @staticmethod
     def get_country_and_domain_name(request_dict, response):
         lang = request_dict.get('lang', None)
-        app_bundle_id = request_dict.get('app_bundle_id', 'com.ansjer.zccloud')     # AVSS不传app_bundle_id参数
+        app_bundle_id = request_dict.get('app_bundle_id', 'com.ansjer.zccloud')  # AVSS不传app_bundle_id参数
         time_stamp = request_dict.get('time_stamp', None)
         time_stamp_token = request_dict.get('time_stamp_token', None)
 
@@ -313,7 +314,7 @@ class RegionView(View):
 
             # 根据app名返回相应域名
             app_name = app_inf_qs[0]['appName']
-            country_qs = CountryLanguageModel.objects.filter(language_id=lang.id).\
+            country_qs = CountryLanguageModel.objects.filter(language_id=lang.id). \
                 annotate(push_api=F('country__region__push_api'))
             if 'Zosi' in app_name:
                 country_qs = country_qs.annotate(api=F('country__region__zosi_api'))
@@ -321,7 +322,7 @@ class RegionView(View):
                 country_qs = country_qs.annotate(api=F('country__region__loocam_api'))
             else:
                 country_qs = country_qs.annotate(api=F('country__region__api'))
-            country_qs = country_qs.values('country_id', 'country_name', 'api', 'push_api')
+            country_qs = country_qs.values('country_id', 'country_name', 'api', 'push_api').order_by('country_id')
             return response.json(0, list(country_qs))
         except Exception as e:
             return response.json(500, repr(e))