from django.contrib import admin
from django.conf.urls import url
from django.urls import path, re_path

from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppInfo, \
    AccessLog, DynamoDBLog, Test, MealManage, DeviceManage, EquipmentStatus, SysManage, DeviceLog, LogAccess, \
    AppColophon, DateController, \
    EquipmentManager, LogManager, PermissionManager, OTAEquipment, shareUserPermission, UidSetController, \
    UserManger, CheckUserData, \
    UserController, CloudVod, OrderContrller, VodBucket, DetectController, DeviceShare, UserBrandController, \
    StsOssController, UIDPreview, OssCrd, SysMsg, UidUser, EquipmentManagerV2, EquipmentManagerV3, PushDeploy, \
    AppSetController, \
    ApplicationController, UserExController, CloudStorage, TestApi, UserBrandControllerV2, \
    StatisticsController, Alexa, FAQController, AppLogController, EquipmentVersionLimit, VoicePromptController, \
    CDKController, \
    DeviceTypeController, CloudTransfer, Cloudsum, IotCoreController, OperatingLogs, ProcessInfo, \
    RegionCountryController, \
    VerifyCodeController, FileController, UIDController, LogController, SalesController, \
    OrderTaskController, HistoryUIDController, UIDManageUserController, SerialNumberController, CompanyController, \
    RegionController, VPGController, LanguageController, TestController, DeviceConfirmRegion, S3GetStsController, \
    DetectControllerV2, ShadowController, TestDetectController

urlpatterns = [
    url(r'^testApi/(?P<operation>.*)$', TestApi.testView.as_view()),
    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()),
    url(r'^account/register$', UserController.registerView.as_view()),
    url(r'^account/login$', UserController.v2LoginView.as_view()),
    url(r'^account/logout$', UserController.LogoutView.as_view()),
    url(r'^account/changePwd$', UserController.ChangePwdView.as_view()),
    url(r'^account/forget$', UserController.ForgetPwdView.as_view()),
    url(r'^account/email-re-pwd$', UserController.EmailResetPwdView.as_view()),
    url(r'^account/refreshTk$', UserController.refreshTokenView.as_view()),
    url(r'^favicon.ico$', UserManger.success, name=u'favicon.ico'),
    url(r'^account/showUserMore$', UserManger.showUserMoreView.as_view()),
    url(r'^account/perfectUserInfo$', UserManger.perfectUserInfoView.as_view()),
    url(r'^account/getAvatar/(?P<filePath>.*)$', UserManger.getAvatarView.as_view()),
    url(r'^account/delUser$', UserManger.delUserInterface),
    url(r'^account/setUserValid$', UserManger.setUserValidView.as_view()),
    url(r'^account/showAllUser$', UserManger.showAllUserInterface),
    url(r'^account/help$', LogManager.HelpView.as_view()),
    url(r'^account/searchUser$', shareUserPermission.searchUserView.as_view()),
    path('accounts', AdminManage.search_user_by_content),  # 多条件搜索用户信息admin
    url(r'^account/shareUserEquipment$', shareUserPermission.shareUserEquipmentView.as_view()),
    url(r'^account/unsharedUserEquipment$', shareUserPermission.unsharedUserEquipmentView.as_view()),
    url(r'^response/success$', UserManger.success),
    url(r'^equipment/queryUserEquipment$', EquipmentManager.queryUserEquipmentInterface),
    url(r'^equipment/addNewUserEquipment$', EquipmentManager.addNewUserEquipmentInterface),
    url(r'^equipment/delUserEquipment$', EquipmentManager.delUserEquipmentInterface),
    url(r'^equipment/modifyUserEquipment$', EquipmentManager.modifyUserEquipmentInterface),
    url(r'^equipment/showAllUserEquipment$', EquipmentManager.showAllUserEquipmentInterface),
    url(r'^equipment/findEquipmentInfo$', EquipmentManager.findEquipmentInfoInterface),
    # 新删除设备接口
    url(r'^equipment/delete', EquipmentManager.deleteInterface),
    url(r'^equipment/add', EquipmentManager.addInterface),
    url(r'^equipment/admin_add', EquipmentManager.admin_addInterface),
    url(r'^equipment/admin_modify', EquipmentManager.admin_modifyInterface),

    url(r'^equipment/query', EquipmentManager.queryInterface),
    # 获取设备影子信息接口
    url(r'^equipment/flow$', EquipmentManager.uid_status),

    url(r'^OTA/uploads$', OTAEquipment.getUploadFiletoDirView.as_view()),
    url(r'^OTA/download$', OTAEquipment.downloadUpdataFileUrl),
    url(r'^OTA/downloads/(\w+)/(\w+[\w+]*.+[^_w]*.\w+)$', OTAEquipment.downloadUpdataFileUrlInterface),
    url(r'^OTA/getEquipmentVersion$', OTAEquipment.getEquipmentVersionInterface),
    url(r'^OTA/getUpdataFileUrl$', OTAEquipment.getUpdataFileUrlInterface),
    url(r'^OTA/addNewEquipmentVersion$', OTAEquipment.addNewEquipmentVersionInterface),

    url(r'^roles/addNewRole$', PermissionManager.addNewRoleView.as_view()),
    url(r'^roles/queryRole$', PermissionManager.queryRoleView.as_view()),
    url(r'^roles/delRole$', PermissionManager.delRoleView.as_view()),
    url(r'^roles/modifyRole$', PermissionManager.modifyRoleView.as_view()),
    url(r'^perms/addNewPerms$', PermissionManager.addNewPermsView.as_view()),
    url(r'^perms/delPerms$', PermissionManager.delPermsView.as_view()),
    url(r'^perms/queryPerms$', PermissionManager.queryPermsView.as_view()),
    url(r'^perms/modifyPerms$', PermissionManager.modifyPermsView.as_view()),
    url(r'^permsManager/queryRolePerms$', PermissionManager.queryRolePermsView.as_view()),
    url(r'^uploads/upgrade$', OTAEquipment.getUploadFiletoDirView.as_view()),
    url(r'^upgrade/download/(\w+.[^_w]*\w+.\w+)$', CheckUserData.download_file),
    url(r'^downloads/upgrade/(\w+)/(\w+.[^_w]*\w+.\w+)$', OTAEquipment.downloadUpdataFileUrlInterface),
    url(r'^getOTAurl/getUpdataFileUrl$', OTAEquipment.getUpdataFileUrlInterface),
    url(r'^equipment/info', EquipmentInfo.EquipmentInfo.as_view()),
    url(r'^adminManage/manage', AdminManage.AdminManage.as_view()),  # 管理员专属view
    url(r'^equipment/OTA', EquipmentOTA.EquipmentOTA.as_view()),  # OTA重构类
    url(r'^userbrandinfo/(?P<operation>.*)$', UserBrandController.UserBrandInfo.as_view()),  # 用户登录的手机端品牌记录统计信息表

    url(r'^uidset/(?P<operation>.*)$', UidSetController.UidSetView.as_view()),
    url(r'^appInfo', AppInfo.AppInfo.as_view()),  # app版本信息
    url(r'^accesslog', AccessLog.AccessLog.as_view()),
    url(r'^dynamoDBLog/(?P<operation>.*)$', DynamoDBLog.DynamoDBLog.as_view()),

    url(r'^meal/manage', MealManage.MealManage.as_view()),
    url(r'^device/manage$', DeviceManage.DeviceManage.as_view()),
    # 设备在线
    url(r'^device/online$', EquipmentStatus.EquipmentOnline),
    # 设备离线
    url(r'^device/offline$', EquipmentStatus.EquipmentOffline),
    # 设备离线
    url(r'^device/updateIP$', EquipmentStatus.updateIP),
    # 系统ctr
    url(r'^sys/updateLog', SysManage.updateLog),
    url(r'^devices/(\w+)/logs$', DeviceLog.DeviceLog),
    url(r'^devices/(\w+)$', DeviceManage.Devices),
    # 访问日志 mongodb版
    url(r'^LogAccess$', LogAccess.LogAccess),
    # 上传操作文档
    url(r'^HelpCHM/upload$', LogManager.upload_help_chm),
    url(r'^admin/userIDs$', AdminManage.getUserIds),
    # 统计访问日志路径
    path('access/staticPath/', AccessLog.statisticsPath),
    path('access/deleteSn/', AccessLog.deleteSn),
    path('eq/delById', EquipmentInfo.deleteExpireEquipmentInfoById),
    # 新需求ota接口
    url(r'^OTA/getNewVer', OTAEquipment.getNewVerInterface),
    url(r'^OTA/uploadsPack$', OTAEquipment.uploadOTAInterfaceView.as_view()),
    url(r'^OTA/downloadsPack/(?P<fullPath>[0-9\w/.\-]+)', OTAEquipment.downloadOTAInterface),
    url(r'^dlotapack/(?P<fullPath>[0-9\w/.\-]+)', OTAEquipment.downloadOTAInterfaceV2),
    url(r'^OTA/getDownLoadOTApackUrl$', OTAEquipment.getDownLoadOTApackUrl),
    url(r'^OTA/checkMaxVersion$', OTAEquipment.checkMaxVersion),

    # h获取验证码    # v2接口
    url(r'^v2/account/authcode$', UserController.v2authCodeView.as_view()),
    url(r'^v2/account/register$', UserController.v2registerView.as_view()),
    url(r'^v2/account/forgetCode$', UserController.v2forgetPwdCodeView.as_view()),
    url(r'^v2/account/resetPwdByCode$', UserController.v2resetPwdByCodeView.as_view()),

    # 重置密码验证码校验
    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'^account/loginCode$', UserController.loginCodeView.as_view()),
    url(r'^v3/account/loginByCode$', UserController.v3LoginByCodeView.as_view()),

    # 指纹登录
    url(r'^v3/account/loginByFingerprint$', UserController.v3LoginByFingerprintView.as_view()),
    url(r'^v3/account/setFingerprint$', UserController.v3SetFingerprintView.as_view()),

    url(r'^detect/detect_group_push$',DetectController.NotificationView.detect_group_push),
    url(r'^detect/add$', DetectController.PushNotificationView.as_view()),
    # 推送项目接口
    url(r'^detect/(?P<operation>.*)$', DetectController.DetectControllerView.as_view()),
    url(r'^notify/push$', DetectController.NotificationView.as_view()),
    url(r'^detectV2/(?P<operation>.*)$', DetectControllerV2.DetectControllerViewV2.as_view()),
    url(r'^notifyV2/push$', DetectControllerV2.NotificationView.as_view()),
    url(r'^deviceShadow/update$', ShadowController.update_device_shadow),
    url(r'^deviceShadow/generateUTK$', ShadowController.generate_utk),
    url(r'^test/notify/push$', TestDetectController.NotificationView.as_view()),
    url(r'^eq/del$', EquipmentInfo.deleteExpireEquipmentInfo),
    # 新增
    url(r'^cloudVod/(?P<operation>.*)$', CloudVod.CloudVodView.as_view()),
    url(r'^meal/(?P<operation>.*)$', MealManage.MealView.as_view()),
    url(r'^order/(?P<operation>.*)$', OrderContrller.OrderView.as_view()),
    url(r'^appCol/(?P<operation>.*)$', AppColophon.AppColView.as_view()),
    url(r'^vodBucket/(?P<operation>.*)$', VodBucket.VodBucketView.as_view()),
    url(r'^UIDBucket/(?P<operation>.*)$', VodBucket.UidBucketView.as_view()),
    url(r'^EquipmentVersion/(?P<operation>.*)$', EquipmentOTA.EquipmentVersionView.as_view()),

    url(r'^deviceShare/(?P<operation>.*)$', DeviceShare.DeviceShareView.as_view()),
    url(r'^appVer/views$', AppInfo.AppVersionView.as_view()),

    # 屏蔽
    url(r'^user/initInfo$', UserController.InitInfoView.as_view()),
    url(r'^user/information/(?P<operation>.*)$', UserController.InitUserInformationView.as_view()),
    # 获取时区相关信息
    url(r'^getTZ$', EquipmentStatus.getTZ),

    # oss授权
    url(r'^stsOss/(?P<operation>.*)$', StsOssController.StsOssView.as_view()),

    # 用户反馈信息
    url(r'^feedback/(?P<operation>.*)$', FeedBack.FeedBackView.as_view()),
    url(r'^uidpreview/(?P<operation>.*)$', UIDPreview.UIDPreview.as_view()),
    url(r'^sysmsg/(?P<operation>.*)$', SysMsg.SysMsgView.as_view()),
    url(r'^sysfile/(?P<filePath>.*)$', SysManage.getStatView.as_view()),

    url(r'^equipment/flowUpdate', EquipmentManager.update_uid_set),

    url(r'^deviceShadow/update', EquipmentManager.update_device_shadow),

    url(r'^log/getUploadUrl', EquipmentStatus.getUploadLogUrl),
    url(r'^app/getIdData', AppInfo.AppIdDataView.as_view()),
    url(r'^wechat/authsign', UserController.wxAuthSignView.as_view()),
    url(r'^wechat/perfect', UserController.wxPerfectView.as_view()),
    # 分区分流
    path('Test', Test.Test.as_view()),
    # 微信绑定的用户获取验证码
    url(r'^oauth/authcode', UserController.OauthAuthCodeView.as_view()),
    url(r'^oauth/perfect', UserController.OauthPerfectView.as_view()),
    url(r'^oauth/unbunding', UserController.UnbundingWXView.as_view()),

    # 删除云存视频
    # path('cv/del', CloudVod.deleteVodHls),
    path('cv/del', CloudStorage.deleteVodHls),
    path('cv/updateExpiredUidBucket', CloudStorage.updateExpiredUidBucket),
    path('cv/updateUnusedUidBucket', CloudStorage.updateUnusedUidBucket),
    url(r'^equipment/judge', EquipmentManager.judgeInterface),

    # ap模式，新增设备表
    url(r'^uiduser/add', UidUser.addInterface),
    url(r'^uiduser/query', UidUser.queryInterface),
    url(r'^uiduser/update', UidUser.updateInterface),
    url(r'^uiduser/delete', UidUser.deleteInterface),
    url(r'^uid_user/(?P<operation>.*)$', UidUser.UidUserView.as_view()),
    # add query update delete
    url(r'^v2/equipment/(?P<operation>.*)$', EquipmentManagerV2.EquipmentManagerV2.as_view()),

    url(r'^msg/init', SysManage.initMsgFunc),

    url(r'^oss_crd/(?P<operation>.*)$', OssCrd.OssCrdView.as_view()),
    url(r'^push_deploy/(?P<operation>.*)$', PushDeploy.PushDeployView.as_view()),
    url(r'^oalexa/auth', UserController.alexaAuthView.as_view()),
    url(r'^oalexa/discoveryuid', UserController.alexaUidView.as_view()),

    url(r'^appset/(?P<operation>.*)$', AppSetController.AppSetView.as_view()),
    url(r'^application/(?P<operation>.*)$', ApplicationController.ApplicationView.as_view()),
    url(r'^login/oauth/(?P<operation>.*)$', ApplicationController.AuthView.as_view()),
    url(r'^grant/code/(?P<operation>.*)$', ApplicationController.GrantCodeView.as_view()),
    url(r'^user/ex/(?P<operation>.*)$', UserExController.UserExView.as_view()),
	url(r'^v3/equipment/(?P<operation>.*)$', EquipmentManagerV3.EquipmentManagerV3.as_view()),
	url(r'^cloudstorage/(?P<operation>.*)$', CloudStorage.CloudStorageView.as_view()),

    #新增解密的接口
    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),
    url(r'^account/appFrequency/(?P<operation>.*)$', UserController.UserAppFrequencyView.as_view()),
    url(r'^v2/userbrand/(?P<operation>.*)$', UserBrandControllerV2.UserBrandV2.as_view()),
    url(r'^statistcs/appFrequencyMonth$', StatisticsController.statistcsAppFrequency),
    url(r'^statistcs/appFrequencyYear$', StatisticsController.statistcsAppFrequencyYear),
    url(r'^statistcs/pushDay$', StatisticsController.statistcsPushDay),
    url(r'^statistcs/pushMonth$', StatisticsController.statistcsPushMonth),

    #统计alexa连接数
    url(r'^alexa/(?P<operation>.*)$', Alexa.AlexaConnectNum.as_view()),

    # FAQ
    url(r'^faq/upload', FAQController.FAQUploadView.as_view()),
    url(r'^faq/image/(?P<filePath>.*)$', FAQController.getFAQImage.as_view()),
    url(r'^faq/(?P<operation>.*)$', FAQController.FAQView.as_view()),

    # 苹果登录
    url(r'^ios/authsign', UserController.AppleAuthLogin.as_view()),
    url(r'^appLog/(?P<operation>.*)$', AppLogController.AppLogView.as_view()),

    # 本地登录接口
    url(r'^local/(?P<operation>.*)$', UserController.LocalUserView.as_view()),

    url(r'^account/updateUserCountry', UserController.updateUserCountry),
    url(r'^equipmentVersionLimit/(?P<operation>.*)$', EquipmentVersionLimit.EquipmentVersionLimitView.as_view()),

    # 订阅邮件
    url(r'^account/subscribe$', UserController.SubscribeEmailView.as_view()),
    url(r'^account/subscribe/download$', UserController.SubscribeEmailView.as_view()),

    # 语音提示
    url(r'^voicePrompt/(?P<operation>.*)$', VoicePromptController.VoicePromptView.as_view()),
    # 设备类型
    url(r'^deviceType/(?P<operation>.*)$', DeviceTypeController.DeviceTypeView.as_view()),

    # cdk(激活码)
    url(r'^cdk/(?P<operation>.*)$', CDKController.CDKView.as_view()),
    # 云存转移功能
    url(r'^cloudTransfer/(?P<operation>.*)$', CloudTransfer.cloudTestView.as_view()),

    # app 设备消息模板
    # 路由加参数参考
    # url(r'^(?P<path>.*)/(?P<UID>.*)/lls$', Test.Test.as_view(), name=u'gg'),
    #testing....................

    #云存服务统计
    url(r'^Cloudsum/(?P<operation>.*)$', Cloudsum.Cloudsum.as_view()),

    #Iot Core
    url(r'iot/(?P<operation>.*)$', IotCoreController.IotCoreView.as_view()),

    #S3预签名
    url(r's3_getsts/(?P<operation>.*)$', S3GetStsController.S3GetStsView.as_view()),

    # 云分配UID
    path('admin/', admin.site.urls),
    re_path('user/(?P<operation>.*)', UIDManageUserController.UserView.as_view()),
    re_path('uid/(?P<operation>.*)', UIDController.UIDView.as_view()),
    re_path('history/(?P<operation>.*)', HistoryUIDController.HistoryUIDView.as_view()),
    re_path('log/(?P<operation>.*)', LogController.LogView.as_view()),
    re_path('orderTask/(?P<operation>.*)', OrderTaskController.OrderTaskView.as_view()),
    path('upload', FileController.UploadUIDFileView.as_view()),
    path('download', FileController.DownloadUIDFileView.as_view()),
    path('sales', SalesController.SalesView.as_view()),
    path('device/online', SalesController.DeviceOnlineView.as_view()),
    re_path('serialNumber/(?P<operation>.*)', SerialNumberController.SerialNumberView.as_view()),
    re_path('company/(?P<operation>.*)', CompanyController.CompanyView.as_view()),
    re_path('region/(?P<operation>.*)', RegionController.RegionView.as_view()),
    re_path('vpg/(?P<operation>.*)', VPGController.VPGView.as_view()),
    path('vpgUid/uid', VPGController.do_upload_uid),
    re_path('language/(?P<operation>.*)', LanguageController.LanguageView.as_view()),


    re_path('test/(?P<operation>.*)', TestController.TestView.as_view()),
    # 日志管理系统
    url(r'^OperatingLogs/(?P<operation>.*)$', OperatingLogs.OperatingLogsView.as_view()),
    url(r'^ProcessInfo/(?P<operation>.*)$', ProcessInfo.ProcessInfoView.as_view()),
    url(r'^Cloudsum/(?P<operation>.*)$', Cloudsum.Cloudsum.as_view()),

    url(r'regionCountry/(?P<operation>.*$)', RegionCountryController.RegionCountryView.as_view()),

    # 验证验证码
    url(r'verifyCode/(?P<operation>.*$)', VerifyCodeController.VerifyCodeView.as_view()),

    #设备确定分配地区
    url(r'^device/confirmRegion$', DeviceConfirmRegion.ConfirmRegion.as_view()),

    re_path('(?P<path>.*)', LogManager.errorPath),



]
