chenjunkai před 6 roky
rodič
revize
9de68dfe4e
3 změnil soubory, kde provedl 41 přidání a 45 odebrání
  1. 3 2
      Ansjer/mqtt/mqtt_client.py
  2. 37 43
      Controller/AppInfo.py
  3. 1 0
      Object/AWS/SesClassObject.py

+ 3 - 2
Ansjer/mqtt/mqtt_client.py

@@ -13,14 +13,15 @@
 """
 import paho.mqtt.client as mqtt
 
-HOST = "192.168.136.40"
+HOST = "192.168.136.45"
 PORT = 1883
 
 
 def test():
     client = mqtt.Client()
     client.connect(HOST, PORT, 60)
-    client.publish("chat", "hello chenfulin", 2)
+    client.publish("chat", "hello chenfulin11111", 2)
+    # client.loop()
     client.loop_forever()
 
 

+ 37 - 43
Controller/AppInfo.py

@@ -95,46 +95,40 @@ class AppInfo(View):
             data=[appBundleId, appName, systemLanguage, newAppversion, content, app_type, bundleVersion])
         if param_flag is not True:
             return response.json(444)
-
-        try:
-            has_app_info = App_Info.objects.filter(appBundleId=appBundleId)
-        except Exception:
-            errorInfo = traceback.format_exc()
-            print(errorInfo)
-            return response.json(424, {'details': errorInfo})
+        has_app_info = App_Info.objects.filter(appBundleId=appBundleId)
+        if has_app_info.exists():
+            return response.json(174)
         else:
-            if has_app_info.exists():
-                return response.json(174)
+            try:
+                app_Info = App_Info(
+                    appBundleId=appBundleId,
+                    appName=appName,
+                    newAppversion=newAppversion,
+                    systemLanguage=systemLanguage,
+                    content=content,
+                    app_type=app_type,
+                    bundleVersion=bundleVersion,
+                    downloadLink=downloadLink)
+                app_Info.save()
+            except Exception:
+                errorInfo = traceback.format_exc()
+                print(errorInfo)
+                return response.json(500, {'details': errorInfo})
             else:
-                try:
-                    app_Info = App_Info(
-                        appBundleId=appBundleId,
-                        appName=appName,
-                        newAppversion=newAppversion,
-                        systemLanguage=systemLanguage,
-                        content=content,
-                        app_type=app_type,
-                        bundleVersion=bundleVersion,
-                        downloadLink=downloadLink)
-                    app_Info.save()
-                except Exception:
-                    errorInfo = traceback.format_exc()
-                    print(errorInfo)
-                    return response.json(500, {'details': errorInfo})
+                if app_Info.id:
+                    res = {'appBundleId': app_Info.appBundleId,
+                           'appName': app_Info.appName,
+                           'newAppversion': app_Info.newAppversion,
+                           'systemLanguage': app_Info.systemLanguage,
+                           'content': app_Info.content,
+                           'app_type': app_Info.app_type,
+                           'id': app_Info.id,
+                           'downloadLink': downloadLink,
+                           'bundleVersion': app_Info.bundleVersion}
+                    return response.json(0, res)
                 else:
-                    if app_Info.id:
-                        res = {'appBundleId': app_Info.appBundleId,
-                               'appName': app_Info.appName,
-                               'newAppversion': app_Info.newAppversion,
-                               'systemLanguage': app_Info.systemLanguage,
-                               'content': app_Info.content,
-                               'app_type': app_Info.app_type,
-                               'id': app_Info.id,
-                               'downloadLink': downloadLink,
-                               'bundleVersion': app_Info.bundleVersion}
-                        return response.json(0, res)
-                    else:
-                        return response.json(500)
+                    return response.json(500)
+
 
     def query(self, request_dict, userID, response):
         own_perm = ModelService.check_perm(userID=userID, permID=30)
@@ -166,13 +160,10 @@ class AppInfo(View):
         app_type = request_dict.get('app_type', None)
         bundleVersion = request_dict.get('bundleVersion', None)
         downloadLink = request_dict.get('downloadLink', None)
-        param_flag = CommonService.get_param_flag(
-            data=[appBundleId, appName, systemLanguage, newAppversion, content, app_type, bundleVersion,
-                  downloadLink])
-        if param_flag is not True:
+        if not all([appBundleId, appName, systemLanguage, newAppversion, content, app_type, bundleVersion, downloadLink]):
             return response.json(444)
-        app_info = App_Info.objects.get(id=id)
-        if app_info.id:
+        try:
+            app_info = App_Info.objects.get(id=id)
             app_info.appBundleId = appBundleId
             app_info.appName = appName
             app_info.systemLanguage = systemLanguage
@@ -182,6 +173,9 @@ class AppInfo(View):
             app_info.bundleVersion = bundleVersion
             app_info.downloadLink = downloadLink
             app_info.save()
+        except Exception as e:
+            return response.json(404,repr(e))
+        else:
             return response.json(0, {'update_id': app_info.id, 'update_time': str(app_info.update_time)})
 
     def delete(self, request_dict, userID, response):

+ 1 - 0
Object/AWS/SesClassObject.py

@@ -11,6 +11,7 @@ from email.mime.base import MIMEBase
 from email.mime.application import MIMEApplication
 from email.header import Header
 
+
 class SesClassObject:
    def __init__(self, *args, **kwargs):
         self.access_id = AWS_SES_ACCESS_ID