Browse Source

Merge branch 'test' of http://192.168.136.99:3000/SERVER/AnsjerServer into test

Ansjer 4 years ago
parent
commit
7aa42f5287

+ 18 - 18
Ansjer/local_settings.py

@@ -73,15 +73,15 @@ TEMPLATES = [
 WSGI_APPLICATION = 'Ansjer.local_wsgi.application'
 
 # 服务器类型
-DATABASE_DATA = 'ansjerlocal'
-SERVER_HOST = '127.0.0.1'
-DATABASES_USER = 'root'
-DATABASES_PASS = '123456'
+DATABASE_DATA = 'AnsjerLocal'
+SERVER_HOST = '192.168.136.99'
+DATABASES_USER = 'ansjer'
+DATABASES_PASS = 'ansjer.x.x'
 
-DATABASE_DATA2 = 'asjl'
-SERVER_HOST2 = '127.0.0.1'
-DATABASES_USER2 = 'root'
-DATABASES_PASS2 = '123456'
+# DATABASE_DATA2 = 'asjl'
+# SERVER_HOST2 = '127.0.0.1'
+# DATABASES_USER2 = 'root'
+# DATABASES_PASS2 = '123456'
 
 DATABASES = {
     'default': {
@@ -94,16 +94,16 @@ DATABASES = {
         'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
         'AUTOCOMMIT': True
     },
-    'mysql02': {
-        'ENGINE': 'django.db.backends.mysql',
-        'NAME': DATABASE_DATA2,
-        'USER': DATABASES_USER2,
-        'PASSWORD': DATABASES_PASS2,
-        'HOST': SERVER_HOST2,
-        'PORT': '3306',
-        'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
-        'AUTOCOMMIT': True
-    }
+    # 'mysql02': {
+    #     'ENGINE': 'django.db.backends.mysql',
+    #     'NAME': DATABASE_DATA2,
+    #     'USER': DATABASES_USER2,
+    #     'PASSWORD': DATABASES_PASS2,
+    #     'HOST': SERVER_HOST2,
+    #     'PORT': '3306',
+    #     'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
+    #     'AUTOCOMMIT': True
+    # }
 }
 DATABASE_ROUTERS = ['Ansjer.database_router.DatabaseAppsRouter']
 DATABASE_APPS_MAPPING = {

+ 46 - 0
Ansjer/test_zositech_help_weekly_task.py

@@ -0,0 +1,46 @@
+import json
+
+import requests
+import time
+
+
+# url = 'http://test.dvema.com'
+base_url = 'http://127.0.0.1:8000/'
+#base_url = 'http://test.dvema.com/'
+username='13800138001'
+password='ansjer999999'
+login_url = base_url + 'account/login'
+
+data = {
+    'userName': username,
+    'userPwd': password
+}
+res = requests.post(url=login_url, data=data)
+res = res.json()
+
+if res['result_code'] == 0:
+    isbool = True
+    while isbool:
+        try:
+            statistics_url = base_url + 'faq/synZositechHelp'
+            zhcnDatares = requests.get(
+                url='https://mobileapphelp.zendesk.com/api/v2/help_center/articles/embeddable_search.json?locale=zh-cn&section=null&origin=web_widget', timeout=1).text
+
+            enusDatares = requests.get(
+                url='https://mobileapphelp.zendesk.com/api/v2/help_center/articles/embeddable_search.json?locale=en-us&section=null&origin=web_widget', timeout=1).text
+
+            data = {
+                'token': res['result']['access_token'],
+                'zhresults': zhcnDatares,
+                'enresults': enusDatares
+            }
+            isbool = False
+            res = requests.post(url=statistics_url, data=data)
+
+        except Exception as e:
+            isbool=True
+            time.sleep(3)
+
+
+
+

+ 4 - 1
Ansjer/urls.py

@@ -10,7 +10,7 @@ from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppIn
     StsOssController, UIDPreview, OssCrd, SysMsg, UidUser, EquipmentManagerV2, EquipmentManagerV3, PushDeploy, \
     AppSetController, \
     ApplicationController, UserExController, CloudStorage, TestApi, UserBrandControllerV2, \
-    StatisticsController, Alexa, FAQController, AppLogController
+    StatisticsController, Alexa, FAQController, AppLogController, EquipmentVersionLimit
 
 urlpatterns = [
     url(r'^testApi/(?P<operation>.*)$', TestApi.testView.as_view()),
@@ -235,6 +235,9 @@ urlpatterns = [
 
     # 本地登录接口
     url(r'^local/(?P<operation>.*)$', UserController.LocalUserView.as_view()),
+    url(r'^account/updateUserCountry', UserController.updateUserCountry),
+    url(r'^equipmentVersionLimit/(?P<operation>.*)$', EquipmentVersionLimit.EquipmentVersionLimitView.as_view()),
+
 
     # app 设备消息模板
     # 路由加参数参考

+ 48 - 30
Controller/CloudStorage.py

@@ -207,7 +207,7 @@ class CloudStorageView(View):
         vh_qs = VodHlsModel.objects.filter(uid=uid, channel=channel, time=storeTime, endTime__gte=now_time). \
             values("sec", "fg", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
         if not vh_qs.exists():
-            return response.json(11,'不存在')
+            return response.json(11,'不存在.')
         sec = vh_qs[0]['sec']
         fg = vh_qs[0]['fg']
         bucket__region = vh_qs[0]['bucket__region']
@@ -226,23 +226,44 @@ class CloudStorageView(View):
         '''
         conn = session.client('s3')
         playlist_entries = []
-        for i in range(fg):
-            thumbspng = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
-                format(uid=uid, channel=channel, time=storeTime, i=i)
-            response_url = conn.generate_presigned_url(
-                'get_object',
-                Params={
-                    'Bucket': bucket_name,
-                    'Key': thumbspng
-                },
-                ExpiresIn=3600
-            )
-            # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
-            #     format(uid=uid, channel=channel, time=vod['time'])
-            playlist_entries.append({
-                'name': response_url,
-                'duration': 10,
-            })
+        # for i in range(fg):
+        #     thumbspng = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
+        #         format(uid=uid, channel=channel, time=storeTime, i=i)
+        #     response_url = conn.generate_presigned_url(
+        #         'get_object',
+        #         Params={
+        #             'Bucket': bucket_name,
+        #             'Key': thumbspng
+        #         },
+        #         ExpiresIn=3600
+        #     )
+        #     # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
+        #     #     format(uid=uid, channel=channel, time=vod['time'])
+        #     playlist_entries.append({
+        #         'name': response_url,
+        #         'duration': sec,
+        #     })
+        for i in range(7):
+            shift = (i+1)*4
+            duration = (fg >> shift) & 0xf
+            if duration > 0:
+                tsFile = '{uid}/vod{channel}/{time}/ts{i}.ts'. \
+                    format(uid=uid, channel=channel, time=storeTime, i=i)
+                response_url = conn.generate_presigned_url(
+                    'get_object',
+                    Params={
+                        'Bucket': bucket_name,
+                        'Key': tsFile
+                    },
+                    ExpiresIn=3600
+                )
+                # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
+                #     format(uid=uid, channel=channel, time=vod['time'])
+                playlist_entries.append({
+                    'name': response_url,
+                    'duration': duration,
+                })
+
         playlist = PlaylistGenerator(playlist_entries).generate()
         response = HttpResponse(playlist)
         response['Content-Type'] = 'application/octet-stream'
@@ -411,18 +432,18 @@ class CloudStorageView(View):
         endTime = int(request_dict.get('endTime', None))
         uid = request_dict.get('uid', None)
         channel = request_dict.get('channel', None)
+
+        print('开始时间--%d' %(time.time()*1000))
         dv_qs = Device_Info.objects.filter(UID=uid, userID_id=userID, isShare=False)
         if not dv_qs.exists():
             return response.json(12)
         now_time = int(time.time())
+
         vh_qs = VodHlsModel.objects.filter\
-            (uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
+            ( uid=uid, channel=channel, time__range=(startTime, endTime), endTime__gte=now_time). \
             values("time", "sec", "bucket__bucket", "bucket__endpoint", "bucket__region", "bucket__mold")
         vod_play_list = []
-        print("-------------vh_qs")
-        print(vh_qs)
         auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
-        print('--------------bigin')
         print(int(time.time()))
         for vod in vh_qs:
             bucket__mold = vod["bucket__mold"]
@@ -453,7 +474,7 @@ class CloudStorageView(View):
                 #     region_name=bucket__region
                 # )
                 # conn = session.client('s3')
-                # thumbspng = '{uid}/vod{channel}/{time}/thumbs.jpg'. \
+                # thumbspng = '{uid}/vod{channel}/{time}/Thumb.jpeg'. \
                 #     format(uid=uid, channel=channel, time=vod['time'])
                 # response_url = conn.generate_presigned_url(
                 #     'get_object',
@@ -464,18 +485,15 @@ class CloudStorageView(View):
                 #     ExpiresIn=3600
                 # )
                 # thumb_url = response_url
-                # m3u8 = '{uid}/vod{channel}/{time}/{time}.m3u8'. \
-                #     format(uid=uid, channel=channel, time=vod['time'])
-                vod_url = 'http://test.dvema.com/cloudstorage/signplaym3u8?' \
+                vod_url = '{server_domain}/cloudstorage/signplaym3u8?' \
                           'uid={uid}&channel={channel}&time={time}&sign=tktktktk'. \
-                    format(uid=uid, channel=channel, time=vod['time'])
+                    format(server_domain=SERVER_DOMAIN,uid=uid, channel=channel, time=vod['time'])
                 vod_play_list.append({
                     'name': vod['time'],
                     'sign_url': vod_url,
                     # 'thumb': thumb_url,
                     'sec': vod['sec']})
-        print('--------------end')
-        print(int(time.time()))
+        print('结束时间--%d' %(time.time()*1000))
         return response.json(0, vod_play_list)
 
     def do_store_playlist(self, request_dict, response):
@@ -875,7 +893,7 @@ class CloudStorageView(View):
         pay_type = int(request_dict.get('pay_type', None))
         rank = request_dict.get('rank', None)
 
-        if uid == None or channel == None or commodity_code == None or pay_type == None or rank == None:
+        if not uid or not channel or not commodity_code or not rank:
             return response.json(13, '参数有误.')
         dv_qs = Device_Info.objects.filter(userID_id=userID, UID=uid, isShare=False, isExist=1)
         if not dv_qs.exists():

+ 4 - 1
Controller/CloudVod.py

@@ -15,6 +15,9 @@ import json
 import math
 import time
 import urllib
+
+import boto3
+
 from Object.AliPayObject import AliPayObject
 import oss2
 import paypalrestsdk
@@ -28,7 +31,7 @@ from django.views.generic.base import View
 
 from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_ARN, SERVER_DOMAIN, PAYPAL_CRD, \
     SERVER_DOMAIN_SSL
-from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket
+from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.UidTokenObject import UidTokenObject

+ 110 - 0
Controller/EquipmentVersionLimit.py

@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+import time
+
+from django.views import View
+
+from Model.models import EquipmentVersionLimitModel, UidSetModel
+from Object.RedisObject import RedisObject
+from Object.ResponseObject import ResponseObject
+from Object.TokenObject import TokenObject
+
+
+class EquipmentVersionLimitView(View):
+
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation', None)
+        request_dict = request.GET
+        return self.validate(request_dict, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation', None)
+        request_dict = request.POST
+        return self.validate(request_dict, operation)
+
+    def validate(self, request_dict, operation):
+        token = request_dict.get('token', None)
+        token = TokenObject(token)
+        print('ind')
+        response = ResponseObject()
+        if token.code != 0:
+            return response.json(token.code)
+
+        if operation == 'add':
+            return self.do_add(request_dict, response)
+        elif operation == 'update':
+            return self.do_update(request_dict, response)
+        elif operation == 'delete':
+            return self.do_delete(request_dict, response)
+        elif operation == 'uid':
+            return self.do_query(request_dict, response)
+        else:
+            return response.json(404)
+
+    def do_add(self, request_dict, response):
+        type = request_dict.get('type', None)
+        content = request_dict.get('content', None)
+        eid = request_dict.get('eid', None)
+
+        if type and content and eid:
+            now_time = int(time.time())
+            data = EquipmentVersionLimitModel()
+            data.type = type
+            data.content = content
+            data.equipment_version_id = eid
+            data.status = 1
+            data.add_time = now_time
+            data.update_time = now_time
+            data.save()
+            return response.json(0)
+        else:
+            return response.json(444)
+
+    def do_update(self, request_dict, response):
+        print('in ')
+        id = request_dict.get('id', None)
+        content = request_dict.get('content', None)
+        status = request_dict.get('status', None)
+
+        if id is None:
+            return response.json(444)
+
+        update = {}
+        if content:
+            update['content'] = content
+
+        if status:
+            update['status'] = status
+
+        evl_qs = EquipmentVersionLimitModel.objects.filter(id=id)
+        if evl_qs.exists():
+            eid = evl_qs[0].equipment_version_id
+            evl_qs.update(**update)
+            redisObject = RedisObject()
+            redisObject.del_data(key='limit_{eid}'.format(eid=eid))
+        return response.json(0)
+
+    def do_delete(self, request_dict, response):
+        id = request_dict.get('id', None)
+
+        if id is None:
+            return response.json(0)
+
+        evl_qs = EquipmentVersionLimitModel.objects.filter(id=id)
+        if evl_qs.exists():
+            eid = evl_qs[0].equipment_version_id
+            redisObject = RedisObject()
+            redisObject.del_data(key='limit_{eid}'.format(eid=eid))
+            evl_qs.delete()
+        return response.json(0)
+
+    def do_query(self, request_dict, response):
+        uid_qs = UidSetModel.objects.filter()[0:5000].values('uid')
+        data = []
+        for uid in uid_qs:
+            data.append(uid['uid'])
+            data.append(uid['uid'])
+            data.append(uid['uid'])
+        return response.json(0, data)

+ 71 - 5
Controller/FAQController.py

@@ -6,6 +6,7 @@ import shutil
 import time
 import traceback
 
+from django.core import serializers
 from django.http import HttpResponse
 from django.utils.decorators import method_decorator
 from django.views.decorators.csrf import csrf_exempt
@@ -20,7 +21,8 @@ from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from var_dump import var_dump
 
-from Service.ModelService import ModelService
+from Service.CommonService import CommonService
+from Service.ModelService import ModelService, ZositechHelpModel
 
 
 class FAQUploadView(View):
@@ -168,9 +170,9 @@ class FAQView(View):
     def validate(self, request_dict, operation):
         token = TokenObject(request_dict.get('token', None))
         response = ResponseObject()
-        if token.code != 0:
-            return response.json(token.code)
-
+        if operation != 'zositechHelp':
+            if token.code != 0:
+                return response.json(token.code)
         if operation == 'add':
             return self.do_add(token, request_dict, response)
         elif operation == 'query':
@@ -179,6 +181,10 @@ class FAQView(View):
             return self.do_update(token, request_dict, response)
         elif operation == 'delete':
             return self.do_delete(token.userID, request_dict, response)
+        elif operation == 'zositechHelp':
+            return self.do_zositechHelp(request_dict, response)
+        elif operation == 'synZositechHelp':
+            return self.do_synZositechHelp(request_dict, response)
         else:
             return response.json(404)
 
@@ -321,4 +327,64 @@ class FAQView(View):
             else:
                 return response.json(0)
         else:
-            return response.json(444)
+            return response.json(444)
+
+    def do_zositechHelp(self, request_dict, response):
+
+        locale = request_dict.get('locale', None)
+        label_names = request_dict.get('label_names', None)
+        origin = request_dict.get('origin', None)
+        help_qs = None
+        if label_names:
+            help = ZositechHelpModel.objects.filter(locale=locale, label_names__contains=label_names,
+                                                    origin=origin).values()
+        else:
+            help = ZositechHelpModel.objects.filter(locale=locale, origin=origin).values()
+
+        if help.exists():
+            # send_dict = CommonService.qs_to_dict(help)
+            send_dict = list(help)
+
+            return response.json(0, send_dict)
+
+        else:
+            return response.json(444)
+
+    def do_synZositechHelp(self, request_dict, response):
+        zhresults = request_dict.get('zhresults', None).replace("\'", "XX??????XX")
+        #.replace("\"", "XX??????XX").replace("\'", "\"").replace("XX??????XX", "\'")
+        zhresults = json.loads(zhresults)
+
+        enresults = request_dict.get('enresults', None).replace("\'", "XX??????XX")
+        enresults = json.loads(enresults)
+        for data in zhresults['results']:
+            labname = ""
+            if data['label_names']:
+                for lab in data['label_names']:
+                    if lab:
+                        labname += ","
+                    labname = lab
+            if not labname:
+                labname = None
+            ZositechHelpModel.objects.create(**{
+                'locale': data['locale'],
+                'label_names': labname,
+                'origin': 'web_widget',
+                'content': json.dumps(data).replace("\'", "\"").replace("XX??????XX", "\'")
+            })
+        for data in enresults['results']:
+            labname = ""
+            if data['label_names']:
+                for lab in data['label_names']:
+                    if lab:
+                        labname += ","
+                    labname = lab
+            if not labname:
+                labname = None
+            ZositechHelpModel.objects.create(**{
+                'locale': data['locale'],
+                'label_names': labname,
+                'origin': 'web_widget',
+                'content': json.dumps(data).replace("\'", "\"").replace("XX??????XX", "\'")
+            })
+        return response.json(0)

+ 33 - 2
Controller/OTAEquipment.py

@@ -14,8 +14,9 @@ from django.views.generic import TemplateView
 from Ansjer.config import BASE_DIR
 from Ansjer.config import SERVER_DOMAIN
 from Ansjer.config import SERVER_TYPE
-from Model.models import Device_User
+from Model.models import Device_User, EquipmentVersionLimitModel, CountryIPModel
 from Model.models import Equipment_Version
+from Object.RedisObject import RedisObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.UrlTokenObject import UrlTokenObject
@@ -476,6 +477,7 @@ def getNewVerInterface(request):
     token = request_dict.get('token', None)
     lang = request_dict.get('lang', None)
     now_ver = request_dict.get('ver', None)
+    uid = request_dict.get('uid', None)
     if not code or not now_ver:
         return response.json(902, {'param':'code,ver'})
         # return response.json(444, 'code,ver')
@@ -490,9 +492,38 @@ def getNewVerInterface(request):
         equipmentValid = Equipment_Version.objects.filter(code=code, status=1, lang='en').order_by(
             '-data_joined')
 
-    print(equipmentValid)
     if equipmentValid.exists():
         equipment = equipmentValid[0]
+        redisObject = RedisObject()
+        key = 'limit_{eid}'.format(eid=equipment.eid)
+
+        evl_qs = redisObject.get_data(key=key)
+        if evl_qs:
+            evl_qs = json.loads(evl_qs)
+        else:
+            evl_qs = EquipmentVersionLimitModel.objects.filter(equipment_version_id=equipment.eid, status=1).values()
+            if evl_qs.exists():
+                redisObject.set_data(key=key, val=json.dumps(list(evl_qs.values())), expire=600)
+        if evl_qs and len(evl_qs) > 0:
+            evl = evl_qs[0]
+            if evl['type'] == 1: # uid限制
+                uids = json.loads(evl['content'])
+                if not uids.__contains__(uid):
+                    return response.json(902)
+            elif evl['type'] == 2: # user限制
+                users = json.loads(evl['content'])
+                if not users.__contains__(tko.userID):
+                    return response.json(902)
+            elif evl['type'] == 3: # 国家地区限制
+                countries = json.loads(evl['content'])
+                country_ip_qs = CountryIPModel.objects.filter(user_ex__userID=tko.userID)
+                if country_ip_qs.exists():
+                    country = country_ip_qs[0].country
+                else:
+                    country = CommonService.getAddr(CommonService.get_ip_address(request))
+                if not countries.__contains__(country):
+                    return response.json(902)
+
         file_path = equipment.filePath
         ver = equipment.softwareVersion
         max_ver = equipment.max_ver

+ 34 - 7
Controller/UserController.py

@@ -32,7 +32,7 @@ from ratelimit.decorators import ratelimit
 from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN
 from Controller.CheckUserData import DataValid, date_handler, RandomStr
 from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
-    UserAppFrequencyModel
+    UserAppFrequencyModel, CountryIPModel
 from Object.AWS.SesClassObject import SesClassObject
 from Object.AliSmsObject import AliSmsObject
 from Object.RedisObject import RedisObject
@@ -1863,13 +1863,11 @@ class InitInfoView(View):
                     update(**update_dict)
             if appBundleId:
                 user_ex_qs = UserExModel.objects.filter(userID_id=userID)
-                country = CommonService.getAddr(CommonService.get_ip_address(request))
                 if user_ex_qs.exists():
                     update_dict = {
                         'updTime': now_time,
                         'appBundleId': appBundleId,
-                        'region': lang,
-                        'country': country
+                        'region': lang
                     }
                     user_ex_qs.update(**update_dict)
                 else:
@@ -1878,10 +1876,19 @@ class InitInfoView(View):
                         'updTime': now_time,
                         'appBundleId': appBundleId,
                         'userID_id': userID,
-                        'region': lang,
-                        'country': country
+                        'region': lang
                     }
-                    UserExModel.objects.create(**create_dict)
+                    user_ex_qs = UserExModel.objects.create(**create_dict)
+
+                country_ip_qs = CountryIPModel.objects.filter(user_ex_id=user_ex_qs[0].id)
+                if not country_ip_qs.exists():
+                    countryIp = CountryIPModel(
+                        ip=CommonService.get_ip_address(request),
+                        add_time=now_time,
+                        user_ex_id=user_ex_qs[0].id
+                    )
+                    countryIp.save()
+
         # 获取设备是否存在有已被删除
         res = {'usmsg': 0}  # 预留字段, 有版本app该字段去掉会报错
         return response.json(0, res)
@@ -3620,3 +3627,23 @@ def delete_local_account(username):
         if user.is_local:
             user.delete()
             Device_Info.objects.filter(userID__userID=user.userID).delete()
+
+
+def updateUserCountry(request):
+    country_ip_qs = CountryIPModel.objects.filter(status=0)[0: 100]
+    if country_ip_qs.exists():
+        country_ip_qs = country_ip_qs.values()
+        redisObject = RedisObject(db=6)
+        for country_ip in country_ip_qs:
+            key = 'ip_country_{ip}'.format(ip=country_ip['ip'])
+            data = redisObject.get_data(key=key)
+            if data:
+                country = data
+            else:
+                country = CommonService.getAddr(country_ip['ip'])
+                redisObject.set_data(key=key, val=country, expire=3600)
+
+            country_ip['country'] = country
+            CountryIPModel.objects.filter(id=country_ip['id']).update(country=country, status=1)
+    response = ResponseObject()
+    return response.json(0)

+ 51 - 3
Model/models.py

@@ -548,14 +548,14 @@ class Order_Model(models.Model):
 
 class VodHlsModel(models.Model):
     id = models.AutoField(primary_key=True, verbose_name='回放列表主键')
-    uid = models.CharField(max_length=20, verbose_name='设备UID')
+    uid = models.CharField(max_length=20, verbose_name='设备UID', db_index=True)
     channel = models.SmallIntegerField(default=0, verbose_name='通道')
     time = models.IntegerField(verbose_name='播放列表名字时间戳', default=0, db_index=True)
     endTime = models.IntegerField(verbose_name='删除时间', default=0)
     sec = models.IntegerField(verbose_name='秒数', default=0)
     bucket = models.ForeignKey(VodBucketModel, blank=True, to_field='id', on_delete=models.CASCADE, default=1,
                                verbose_name='存储空间')
-    fg = models.SmallIntegerField(default=0,verbose_name='时间片段数') # 0为阿里云存储方案 >0为亚马逊方案
+    fg = models.IntegerField(default=0,verbose_name='时间描述片段数') # 阿里为时间片段数,亚马逊为一个32bit整型,前28bit代表ts文件的时长
 
 
     def __str__(self):
@@ -751,7 +751,6 @@ class UserExModel(models.Model):
     userID = models.ForeignKey(Device_User, to_field='userID', on_delete=models.CASCADE)
     appBundleId = models.CharField(default='', max_length=32, verbose_name=u'appID')
     region = models.CharField(default='', max_length=16, verbose_name='区域语言')
-    country = models.CharField(default='', max_length=100, verbose_name='国家名称')
     addTime = models.IntegerField(verbose_name='添加时间', default=0)
     updTime = models.IntegerField(verbose_name='更新时间', default=0)
 
@@ -1013,6 +1012,55 @@ class EquipmentInfoExStatisticsModel(models.Model):
         verbose_name_plural = verbose_name
 
 
+class CountryIPModel(models.Model):
+    id = models.AutoField(primary_key=True)
+    ip = models.CharField(default='', max_length=32, verbose_name='ip')
+    user_ex = models.ForeignKey(UserExModel, to_field='id', on_delete=models.CASCADE, verbose_name='关联用户扩展信息表id')
+    country = models.CharField(default='', max_length=100, verbose_name='国家')
+    status = models.SmallIntegerField(default=0, verbose_name='是否已经查找,0:否,1:是')
+    add_time = models.IntegerField(default=0, verbose_name='添加时间')
 
+    class Meta:
+        db_table = 'country_ip'
+        verbose_name = 'ip-国家统计表'
+        verbose_name_plural = verbose_name
 
+class ZositechHelpModel(models.Model):
+    id = models.AutoField(primary_key=True)
+    locale = models.CharField(default='', db_index=True, max_length=50, verbose_name='语言')
+    label_names =  models.CharField(default='', db_index=True, max_length=50, verbose_name='标签')
+    origin  =  models.CharField(default='', db_index=True ,max_length=50, verbose_name='来源')
+    # author_id = models.CharField(default='', max_length=50, verbose_name='管理员id')
+    # body = models.TextField(default='', blank=True, verbose_name='内容')
+    # comments_disabled = models.CharField(default='', max_length=10, verbose_name='comments')
+    # created_at = models.CharField(default='', max_length=50, verbose_name='创建时间')
+    # draft = models.CharField(default='', max_length=10, verbose_name='草稿')
+    # edited_at = models.CharField(default='',max_length=50, verbose_name='修改时间')
+    # html_url = models.CharField(default='', blank=True, verbose_name='跳转路径')
+    # body = models.CharField(default='', blank=True, verbose_name='标签')
+    # body = models.CharField(default='', blank=True, verbose_name='标签')
+    # body = models.TextField(default='', blank=True, verbose_name='标签')
+    # body = models.TextField(default='', blank=True, verbose_name='标签')
+    # body = models.CharField(default='', blank=True, verbose_name='标签')
+    # body = models.CharField(default='', blank=True, verbose_name='标签')
+
+    content = models.TextField(blank=True, default='', verbose_name=u'内容')
 
+    class Meta:
+        db_table = 'zositech_help'
+        verbose_name = '周视使用帮助表'
+        verbose_name_plural = verbose_name
+
+class EquipmentVersionLimitModel(models.Model):
+    id = models.AutoField(primary_key=True)
+    type = models.SmallIntegerField(default=0, verbose_name='限制类型')
+    content = models.TextField(default='', verbose_name='限制内容')
+    equipment_version = models.ForeignKey(Equipment_Version, to_field='eid', on_delete=models.CASCADE, verbose_name='关联设备版本信息id')
+    status = models.SmallIntegerField(default=0, verbose_name='是否启用。0:不启用,1:启用')
+    add_time = models.IntegerField(default=0, verbose_name='添加时间')
+    update_time = models.IntegerField(default=0, verbose_name='更新时间')
+
+    class Meta:
+        db_table = 'equipment_version_limit'
+        verbose_name = '设备版本信息限制表'
+        verbose_name_plural = verbose_name