#!/usr/bin/env python3  
# -*- coding: utf-8 -*-  
"""
@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
@AUTHOR: ASJRD018
@NAME: Ansjer
@software: PyCharm
@DATE: 2018/7/3 11:11
@Version: python3.6
@MODIFY DECORD:ansjer dev
@file: TemplateService.py
@Contact: chanjunkai@163.com
"""


class TemplateService:

    @staticmethod
    def log_api():
        apiList = [
            'account/login',
            'account/logout',
            'account/changePwd',
            'account/forget',
            'account/refreshTk',
            'account/showUserMore',
            'account/perfectUserInfo',
            'account/delUser',
            'account/setUserValid',
            'account/unsharedUserEquipment',
            'roles/addNewRole',
            'roles/delRole',
            'roles/modifyRole',
            'perms/addNewPerms',
            'perms/delPerms',
            'perms/modifyPerms',
            'uploads/upgrade',
            # 'appInfo',
            'OTA/getNewVer',
            'v2/account/authcode',
            'v2/account/register',
            'v2/account/forgetCode',
            'v2/account/resetPwdByCode',
            'cloudVod/createOrder',
            'cloudVod/payExecute',
            'cloudVod/status',
            'cloudVod/details',
            'cloudVod/filterVod',
            'cloudVod/findVod',
            'cloudVod/aliPayCreateOrder',
            'cloudVod/aliPayCallback',
            'deviceShare/queryUser',
            'deviceShare/showShareInfo',
            'deviceShare/confirm',
            'deviceShare/deleteUser',
            'deviceShare/deleteUserV2',
            'order/querylist',
            'detect/changeStatus',
            # 'notify/push',
            'wechat/authsign',
            'login/oauth/authorize',
            'login/oauth/access_token',
            'login/oauth/user',
            'v2/account/login',
            'v3/account/login',
            'detect/queryInfo',
            'sysmsg/query',
            'v3/account/register',
            'v3/account/changePwd',
            'v3/account/resetPwdByCode',
            'account/appFrequency',
            'equipment/OTA',
            'equipment/addNewUserEquipment',
            'equipment/delUserEquipment',
            'equipment/modifyUserEquipment',
            'equipment/add',
            'equipment/delete',
            'equipment/query',
            'equipment/flowUpdate',
            'v3/equipment/query',
            'v3/equipment/add',
            'v3/equipment/modify',
            'Cloudsum/cloudservicesum',
            'Cloudsum/userappversion',
            'Cloudsum/usercount',
            'Cloudsum/usercloud',
        ]
        return apiList

    @staticmethod
    def email_message(type, language):
        if language != 'cn':
            language = 'en'
        if type == 'register_code':
            data = {
                'cn': {
                    'title': '注册码获取邮件',
                    'body': """
                    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="content"
     style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
    <h2 style="margin: 30px 0;">Hello, {username}</h2>
    <p style="margin-bottom: 40px;">请输入验证码完成注册,有效期10分钟:</p>
    <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{captcha}</span>
</div>
</body>
</html>
                    """,
                },
                'en': {
                    'title': 'Registration code Email',
                    'body': """
                    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="content"
     style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
    <h2 style="margin: 30px 0;">Hello, {username}</h2>
    <p style="margin-bottom: 40px;">Please input code to reg. only valid in 10 minutes!</p>
    <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{captcha}</span>
</div>
</body>
</html>
"""
                }
            }
        elif type == 'register':
            data = {
                'cn': {
                    'title': '注册激活链接',
                    'body': '<br>尊敬的用户{username},您好!<br>恭喜您已经成功注册珠海安士佳物联网系统的用户，欢迎您使用该系统！<br>为确保您能即时收到本站的各项邮件通知，并及时获取相关信息，请您点击一下连接验证您的邮箱，忘记账号密码时您可使用该邮箱重新找回哟.' +
                            '<br><p>'
                            '<a href="{domain}/account/activate/{token}">{domain}/account/activate/{token}</a>'
                            '<p>'
                },
                'en': {
                    'title': 'Registration activation link',
                    'body': 'Dear user {username}, Hello!' +
                            '<br>' + 'Congratulations, you have successfully registered users of the Zhuhai Internet security system, welcome you to use the system!' +
                            '<br>' + 'In order to ensure that you can receive timely notification of the site, and timely access to relevant information.Please click on the following open link to verify your mailbox, and you can use the mailbox to retrieve it when you forget your account password.' +
                            '<br>' + '<p><a href="{domain}/account/activate/{token}">{domain}/account/activate/{token}</a><p>'
                }
            }
        elif type == 'forget':
            data = {
                'cn': {
                    'title': '重置密码信息',
                    'body': '您好{username}\n' + '您已经请求了重置密码，可以点击下面的链接来重置密码\n' + '<p><a href="{reset_link}">{reset_link}</a></p>\n' + '更改后的密码为: {reset_pwd}\n如果你没有请求重置密码，请忽略这封邮件.\n在你点击上面链接修改密码之前，你的密码将会保持不变\n'
                },
                'en': {
                    'title': 'Reset the password information',
                    'body': 'Hello! Dear {username}.<br>You have asked to reset the password, and you can click the link below to reset the password.<br>' + '<p><a href="{reset_link}">{reset_link}</a></p><br>' + 'The new password is: {reset_pwd}<br>If you do not request to reset the password, please ignore this mail.',
                }
            }
        elif type == 'forgetCode':
            data = {
                'cn': {
                    'title': '重置密码验证码',
                    'body': """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="content"
     style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
    <h2 style="margin: 30px 0;">{userEmail}，您好</h2>
    <p style="margin-bottom: 40px;">请使用下面的验证码重置您的密码，验证码 10 分钟内有效: </p>
    <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{email_valid_code}</span>
</div>
</body>
</html>
"""
                },
                'en': {
                    'title': 'Reset password verification code',
                    'body': """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="content"
     style="overflow: hidden;padding:30px 10% 70px 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;">
    <h2 style="margin: 30px 0;">Hello, {userEmail}</h2>
    <p style="margin-bottom: 40px;">Please reset your password with the following captcha, which is valid for 10 minutes:</p>
    <span style="padding: 10px 20px; font-size: 24px;background-color: #EB6F5A;border-radius:4px;color:#fff;">{email_valid_code}</span>
</div>
</body>
</html>
"""
                }
            }
        return data[language]
