Prechádzať zdrojové kódy

Merge branch 'master' of 13.56.215.252:/web/rpo/AnsjerFormal

tanghongbin 5 rokov pred
rodič
commit
2034b9e753

+ 6 - 2
Ansjer/urls.py

@@ -11,6 +11,7 @@ from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppIn
     ApplicationController, UserExController, CloudStorage
 
 urlpatterns = [
+
     url(r'^account/authcode$', UserController.authCodeView.as_view()),
     url(r'^v3/account/generatepictureCodeView/$', UserController.generatePictureCodeView.as_view()),
     url(r'^v3/account/imageCodeRegister/$', UserController.Image_Code_RegisterView.as_view()),
@@ -116,6 +117,7 @@ urlpatterns = [
     # 重置密码验证码校验
     url(r'^v2/authcode/verify$', UserController.verifyAuthcode.as_view()),
     url(r'^v2/account/logout$', UserController.V2LogoutView.as_view()),
+    url(r'^v2/account/login$', UserController.v3LoginView.as_view()),
     url(r'^v3/account/login$', UserController.v3LoginView.as_view()),
     # 新增
     url(r'^detect/detect_group_push$',DetectController.NotificationView.detect_group_push),
@@ -194,16 +196,18 @@ urlpatterns = [
     url(r'^v3/account/changePwd$', UserController.v3ChangePwdView.as_view()),
     url(r'^v3/account/resetPwdByCode$', UserController.v3resetPwdByCodeView.as_view()),
     url(r'^v3/account/register$', UserController.v3registerView.as_view()),
+    url(r'^v3/uiduser/add', UidUser.v3addInterface),
+    url(r'^v3/uiduser/query', UidUser.v3queryInterface),
     # 判断节假日接口
     url(r'^date/(?P<operation>.*)$', DateController.DateConView.as_view()),
 
+    url(r'^equipment/flow_test$', EquipmentManager.uid_status_test),
     # app 设备消息模板
     # 路由加参数参考
     # url(r'^(?P<path>.*)/(?P<UID>.*)/lls$', Test.Test.as_view(), name=u'gg'),
     #testing....................
     re_path('(?P<path>.*)', LogManager.errorPath),
-    # test.....
-    # 111111111
+
 
 
 ]

+ 5 - 1
Controller/CloudStorage.py

@@ -217,6 +217,9 @@ class CloudStorageView(View):
             aws_secret_access_key=aws_secret_access_key,
             region_name=bucket__region
         )
+        '''
+            http://test.dvema.com/cloudstorage/signplaym3u8?uid=VVDHCVBYDKFMJRWA111A&channel=1&time=1586940120&sign=tktktktk
+        '''
         conn = session.client('s3')
         playlist_entries = []
         for i in range(fg):
@@ -237,7 +240,8 @@ class CloudStorageView(View):
                 'duration': 10,
             })
         playlist = PlaylistGenerator(playlist_entries).generate()
-        response = HttpResponse(playlist, content_type="application/octet-stream")
+        response = HttpResponse(playlist, content_type="application/vnd.apple.mpegurl")
+        # response = HttpResponse(playlist, content_type="application/octet-stream")
         return response
         return HttpResponse(status=200, content=playlist)
 

+ 1 - 1
Controller/DateController.py

@@ -422,7 +422,7 @@ class DateConView(View):
         {"dayStr": "20201231", "type": "0"}
         ]
 
-        srt=[{"dayStr": h, "type": "该不支持日期,只支持2020年"}]
+        srt=[{"dayStr": h, "type": "该日期不支持,只支持2020年"}]
         for i in day:
             if i['dayStr']==h:
                 print(i)

+ 3 - 0
Controller/DetectController.py

@@ -170,6 +170,9 @@ class DetectControllerView(View):
         lang = request_dict.get('lang', 'en')
         tz = request_dict.get('tz', '0')
         # 消息提醒功能新增
+        # 如果传空上来,就默认为0
+        if tz=='':
+            tz=0
         detect_group = request_dict.get('detect_group', None)
         interval = request_dict.get('interval', None)
         if not status:

+ 55 - 0
Controller/EquipmentManager.py

@@ -808,6 +808,61 @@ def uid_status(request):
     else:
         return response.json(0)
 
+def uid_status_test(request):
+    request.encoding = 'utf-8'
+    response = ResponseObject()
+    if request.method == 'POST':
+        request_dict = request.POST
+    elif request.method == 'GET':
+        request_dict = request.GET
+    else:
+        return response.json(444)
+    token = request_dict.get('token', None)
+    uid = request_dict.get('uid', None)
+    tko = TokenObject(token)
+    response.lang = tko.lang
+    if tko.code != 0:
+        return response.json(tko.code)
+    userID = tko.userID
+    # 判断用户是否绑定设备
+    print(000000000000000)
+    qs = UidSetModel.objects.filter(uid=uid).values('uid', 'detect_status', 'detect_interval', 'version', 'ucode',
+                                                    'p2p_region', 'tz', 'video_code', 'channel', 'cloud_vod', 'id',
+                                                    'detect_group', 'is_alexa', 'region_alexa')
+    # 判断uid配置表信息是否存在
+    if qs.exists():
+        # 获取uid推送是否添加过
+        print(1111111111111)
+        us_id = qs[0]['id']
+        if UidPushModel.objects.filter(uid_set_id=us_id, userID_id=userID).exists():
+            detect_status = qs[0]['detect_status']
+        else:
+            detect_status = 0
+        data = {
+            'push_status': detect_status,  # 推送状态
+            'push_interval': qs[0]['detect_interval'],  # 推送间隔
+            'ucode': qs[0]['ucode'],
+            'version': qs[0]['version'],
+            'p2p_region': qs[0]['p2p_region'],
+            'tz': qs[0]['tz'],
+            'video_code': qs[0]['video_code'],
+            'channel': qs[0]['channel'],
+            'cloud_vod': qs[0]['cloud_vod'],
+            'detect_group': qs[0]['detect_group'],  # 推送组
+            'is_alexa': qs[0]['is_alexa'],  # 推送组
+            'region_alexa': qs[0]['region_alexa'],  # 推送组
+        }
+        print(22222222222)
+        # 查询云存储相关信息
+        ubqs = UID_Bucket.objects.filter(uid=uid). \
+            values('bucket__content', 'status', 'channel', 'endTime', 'uid')
+        nowTime = int(time.time())
+        if ubqs.exists():
+            if ubqs[0]['endTime'] > nowTime:
+                data['vod'] = list(ubqs)
+        return response.json(0, data)
+    else:
+        return response.json(0)
 
 def update_uid_set(request):
     request.encoding = 'utf-8'

+ 198 - 0
Controller/UidUser.py

@@ -28,6 +28,8 @@ from Object.TokenObject import TokenObject
 from Service.CommonService import CommonService
 from Service.ModelService import ModelService
 from Object.RedisObject import RedisObject
+import base64
+from Controller.CheckUserData import RandomStr
 '''
 http://192.168.136.40:8077/uiduser/add?token=local&UID=z123asdfqwerzxcvqw12&NickName=xxoxox&View_Account=user&View_Password=password&ChannelIndex=8&is_ap=1&Type=5&NickName=1234zcxv
 http://192.168.136.40:8077/uiduser/query?token=local&page=1&line=10&is_ap=1&NickName=1234zcxv&uid=zxcvasdfqwerzxcvqwer
@@ -362,3 +364,199 @@ class UidUserView(View):
         else:
             return response.json(404)
 
+
+
+
+# v3添加设备字段
+def v3addInterface(request):
+    request.encoding = 'utf-8'
+    response = ResponseObject()
+    if request.method == 'POST':
+        request_dict = request.POST
+    elif request.method == 'GET':
+        request_dict = request.GET
+    else:
+        return response.json(444)
+    token = request_dict.get('token', None)
+    UID = request_dict.get('UID', None)
+    NickName = request_dict.get('NickName', None)
+    View_Account = request_dict.get('View_Account', None)
+    View_Password = request_dict.get('View_Password', '')
+    Type = request_dict.get('Type', None)
+    ChannelIndex = request_dict.get('ChannelIndex', None)
+    is_ap = request_dict.get('is_ap', None)
+    try:
+        for i in range(1, 4):
+            if i == 1:
+                View_Password = base64.b64decode(View_Password)
+                View_Password = View_Password.decode('utf-8')
+                View_Password = View_Password[1:-1]
+            if i == 2:
+                View_Password = base64.b64decode(View_Password)
+                View_Password = View_Password.decode('utf-8')
+                View_Password = View_Password[2:-2]
+            if i == 3:
+                View_Password = base64.b64decode(View_Password)
+                View_Password = View_Password.decode('utf-8')
+                View_Password = View_Password[3:-3]
+        print(View_Password)
+    except Exception as e:
+        return response.json(111)
+    if not View_Password:
+        return response.json(424)
+    if all([UID, NickName, View_Account, Type, ChannelIndex]):
+        tko = TokenObject(token)
+        response.lang = tko.lang
+        if tko.code == 0:
+            userID = tko.userID
+            re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
+            if re_uid.match(UID):
+                is_ap = int(is_ap)
+                is_exist = UidUserModel.objects.filter(UID=UID, userID_id=userID, is_ap=is_ap)
+                if is_exist:
+                    return response.json(174)
+                else:
+                    try:
+                        pk = CommonService.getUserID(getUser=False)
+                        create_data = {
+                            'id': pk, 'userID_id': userID, 'UID': UID,
+                            'NickName': NickName, 'View_Account': View_Account,
+                            'View_Password': View_Password, 'Type': Type, 'ChannelIndex': ChannelIndex
+                        }
+                        UidUserModel.objects.create(**create_data)
+                        # 判断影子信息
+                        nowTime = int(time.time())
+                        us_qs = UidSetModel.objects.filter(uid=UID)
+                        if not us_qs.exists():
+                            uid_set_create_dict = {
+                                'uid': UID,
+                                'addTime': nowTime,
+                                'updTime': nowTime,
+                                'ip': CommonService.get_ip_address(request),
+                                'channel': ChannelIndex,
+                                'nickname': NickName}
+                            UidSetModel.objects.create(**uid_set_create_dict)
+                    except Exception as e:
+                        return response.json(10, repr(e))
+                    else:
+                        uid_user_qs = UidUserModel.objects.filter(id=pk). \
+                            values('id', 'userID', 'NickName', 'UID', 'View_Account', 'View_Password',
+                                   'ChannelIndex', 'Type', 'isShare', 'primaryUserID', 'primaryMaster',
+                                   'data_joined', 'version', 'isVod', 'isExist','is_ap')
+                        uid_user_ql = CommonService.qs_to_list(uid_user_qs)
+                        ubqs = UID_Bucket.objects.filter(uid=UID). \
+                            values('bucket__content', 'status', 'channel', 'endTime', 'uid')
+                        res = uid_user_ql[0]
+                        res['vod'] = list(ubqs)
+                        return response.json(0, res)
+            else:
+                return response.json(444, {'param': 'UID'})
+        else:
+            return response.json(tko.code)
+    else:
+        return response.json(444, {'param': 'UID,NickName,View_Account,View_Password,Type,ChannelIndex'})
+
+
+# v3新查询设备字段
+def v3queryInterface(request):
+    request.encoding = 'utf-8'
+    response = ResponseObject()
+    if request.method == 'POST':
+        request_dict = request.POST
+    elif request.method == 'GET':
+        request_dict = request.GET
+    else:
+        return response.json(444)
+    token = request_dict.get('token', None)
+    page = request_dict.get('page', None)
+    line = request_dict.get('line', None)
+    NickName = request_dict.get('NickName', None)
+    uid = request_dict.get('uid', None)
+    is_ap = request_dict.get('is_ap', None)
+    page = int(page)
+    line = int(line)
+    tko = TokenObject(token)
+    response.lang = tko.lang
+    if page <= 0:
+        return response.json(0)
+    if tko.code == 0:
+        userID = tko.userID
+        redisObj = RedisObject(db=8)
+        redisObj.del_data(key='uid_qs_' + userID)
+        uid_user_qs = UidUserModel.objects.filter(userID_id=userID)
+        if is_ap:
+            is_ap = int(is_ap)
+            uid_user_qs = uid_user_qs.filter(is_ap=is_ap)
+        if NickName:
+            uid_user_qs = uid_user_qs.filter(NickName__icontains=NickName)
+        if uid:
+            uid_user_qs = uid_user_qs.filter(UID=uid)
+        uid_user_ql = uid_user_qs[(page - 1) * line:page * line]. \
+            values('id', 'userID', 'NickName', 'UID', 'View_Account',
+                   'View_Password', 'ChannelIndex', 'Type', 'isShare',
+                   'primaryUserID', 'primaryMaster', 'data_joined', 'version',
+                   'isVod', 'isExist', 'NotificationMode','is_ap')
+        uid_user_ls = CommonService.qs_to_list(uid_user_ql)
+        uid_list = []
+        for uid_user in uid_user_ls:
+            uid_list.append(uid_user['UID'])
+        ubqs = UID_Bucket.objects.filter(uid__in=uid_list). \
+            values('bucket__content', 'status', 'channel', 'endTime', 'uid')
+        upqs = UID_Preview.objects.filter(uid__in=uid_list).order_by('channel').values('id', 'uid', 'channel')
+        auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+        bucket = oss2.Bucket(auth, 'oss-cn-hongkong.aliyuncs.com', 'statres')
+        nowTime = int(time.time())
+        data = []
+        # 设备拓展信息表
+        us_qs = UidSetModel.objects.filter(uid__in=uid_list).values('uid', 'version', 'nickname')
+        uv_dict = {}
+        for us in us_qs:
+            uv_dict[us['uid']] = {'version': us['version'], 'nickname': us['nickname']}
+        for p in uid_user_ls:
+            p['vod'] = []
+            for dm in ubqs:
+                if p['UID'] == dm['uid']:
+                    if dm['endTime'] > nowTime:
+                        p['vod'].append(dm)
+            p['preview'] = []
+            p['View_Password'] = encrypt_pwd(p['View_Password'])
+            for up in upqs:
+                if p['UID'] == up['uid']:
+                    obj = 'uid_preview/{uid}/channel_{channel}.png'.format(uid=up['uid'], channel=up['channel'])
+                    img_sign = bucket.sign_url('GET', obj, 300)
+                    p['preview'].append(img_sign)
+            p_uid = p['UID']
+            if p_uid in uv_dict:
+                # 设备版本号
+                p['uid_version'] = uv_dict[p_uid]['version']
+                # 设备昵称
+                if uv_dict[p_uid]['nickname']:
+                    p['NickName'] = uv_dict[p_uid]['nickname']
+            else:
+                # 设备版本号
+                p['uid_version'] = ''
+            data.append(p)
+        return response.json(0, data)
+    else:
+        return response.json(tko.code)
+
+# #加密
+def encrypt_pwd(userPwd):
+    for i in range(1, 4):
+        if i == 1:
+            userPwd = RandomStr(3, False)+userPwd+RandomStr(3, False)
+            userPwd = base64.b64encode(str(userPwd).encode("utf-8")).decode('utf8')
+        if i == 2:
+            userPwd = RandomStr(2, False)+str(userPwd)+RandomStr(2, False)
+            userPwd = base64.b64encode(str(userPwd).encode("utf-8")).decode('utf8')
+        if i == 3:
+            userPwd = RandomStr(1, False)+str(userPwd)+RandomStr(1, False)
+            userPwd = base64.b64encode(str(userPwd).encode("utf-8")).decode('utf8')
+    return userPwd
+
+
+
+
+
+
+

+ 7 - 4
Controller/UserController.py

@@ -2626,12 +2626,16 @@ class alexaUidView(TemplateView):
             uid_dict = {}
             uid_list = []
             for uid_q in uid_qs:
+                #追加
                 uid_list.append(uid_q['UID'])
+                #给uid_q['UID']赋值
                 uid_dict[uid_q['UID']] = {'nick': uid_q['NickName'], 'password': uid_q['View_Password']}
-            us_qs = UidSetModel.objects.filter(uid__in=uid_list, is_alexa=2).values('uid', 'region_alexa')
+            us_qs = UidSetModel.objects.filter(uid__in=uid_list, is_alexa=1).values('uid', 'region_alexa')
+            # uid,password,region的列表
             uid_arr = []
             for us in us_qs:
                 uid = us['uid']
+                #设备alexa区域
                 region_alexa = us['region_alexa']
                 if region_alexa == '':
                     region_alexa = "en"
@@ -2639,9 +2643,8 @@ class alexaUidView(TemplateView):
                 uid_arr.append({'uid': uid, 'nick': uid_dict[uid]['nick'], 'password': uid_dict[uid]['password'],
                                 'region': region_alexa})
             res = {
-                'uid_arr': uid_arr,
-                'uid_qs':uid_qs,
-                'us_qs':us_qs
+                'uid_arr': uid_arr
+
             }
             return response.json(0, res)
         else:

+ 2 - 0
Object/ResponseObject.py

@@ -143,6 +143,8 @@ class ResponseObject(object):
             message = msg[code]
         except Exception as e:
             message = '系统错误,code不存在'
+        print(self.lang == 'cn')
+        print(msg)
         return {'result_code': code, 'reason': message, 'result': res, 'error_code': code}
 
     def formal(self, code, res={}):