most plugins have same response schema
This commit is contained in:
parent
3dd905d3d5
commit
1a1dc17648
17 changed files with 293 additions and 470 deletions
|
|
@ -152,7 +152,10 @@ class MQTTHelperBot:
|
||||||
assert self._client is not None
|
assert self._client is not None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
topic = f"iot/p2p/{cmdjson['cmdName']}/helperbot/bumper/helperbot/{cmdjson['toId']}/{cmdjson['toType']}/{cmdjson['toRes']}/q/{request_id}/{cmdjson['payloadType']}"
|
topic = (
|
||||||
|
f"iot/p2p/{cmdjson['cmdName']}/helperbot/bumper/helperbot/{cmdjson['toId']}/"
|
||||||
|
f"{cmdjson['toType']}/{cmdjson['toRes']}/q/{request_id}/{cmdjson['payloadType']}"
|
||||||
|
)
|
||||||
command_dto = CommandDto(cmdjson["payloadType"])
|
command_dto = CommandDto(cmdjson["payloadType"])
|
||||||
self._commands[request_id] = command_dto
|
self._commands[request_id] = command_dto
|
||||||
|
|
||||||
|
|
|
||||||
18
bumper/web/images/__init__.py
Normal file
18
bumper/web/images/__init__.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
|
from aiohttp.web_exceptions import HTTPInternalServerError
|
||||||
|
from aiohttp.web_fileresponse import FileResponse
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
|
||||||
|
|
||||||
|
async def get_bot_image(_: Request) -> FileResponse:
|
||||||
|
"""Return image of bot."""
|
||||||
|
try:
|
||||||
|
return FileResponse(
|
||||||
|
os.path.join(os.path.dirname(__file__), "robotvac_image.jpg")
|
||||||
|
)
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
logging.error("Unexpected exception occurred", exc_info=True)
|
||||||
|
|
||||||
|
raise HTTPInternalServerError
|
||||||
|
|
@ -5,11 +5,15 @@ from abc import abstractmethod
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from os.path import dirname, isfile, join
|
from os.path import dirname, isfile, join
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Iterable
|
from typing import Any, Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
|
from bumper.models import RETURN_API_SUCCESS
|
||||||
|
from bumper.util import get_current_time_as_millis
|
||||||
|
|
||||||
|
|
||||||
class WebserverPlugin:
|
class WebserverPlugin:
|
||||||
"""Abstract webserver plugin."""
|
"""Abstract webserver plugin."""
|
||||||
|
|
@ -70,3 +74,15 @@ def add_plugins(app: web.Application) -> None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_add_routes(app, obj, plugin_module_name)
|
_add_routes(app, obj, plugin_module_name)
|
||||||
|
|
||||||
|
|
||||||
|
def get_success_response(data: Any) -> Response:
|
||||||
|
body = {
|
||||||
|
"code": RETURN_API_SUCCESS,
|
||||||
|
"data": data,
|
||||||
|
"msg": "操作成功",
|
||||||
|
"success": True,
|
||||||
|
"time": get_current_time_as_millis(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return web.json_response(body)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
"""Pim plugin module."""
|
"""Pim plugin module."""
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper import bumper_dir
|
|
||||||
from bumper.models import RETURN_API_SUCCESS, EcoVacsHomeProducts
|
from bumper.models import RETURN_API_SUCCESS, EcoVacsHomeProducts
|
||||||
|
|
||||||
|
from ...images import get_bot_image
|
||||||
from .. import WebserverPlugin
|
from .. import WebserverPlugin
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,7 +27,7 @@ class PimPlugin(WebserverPlugin):
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/pim/file/get/{id}",
|
"/pim/file/get/{id}",
|
||||||
self.handle_pimFile,
|
get_bot_image,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
|
|
@ -63,19 +62,6 @@ class PimPlugin(WebserverPlugin):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(f"{e}")
|
logging.exception(f"{e}")
|
||||||
|
|
||||||
async def handle_pimFile(self, request):
|
|
||||||
try:
|
|
||||||
fileID = request.match_info.get("id", "")
|
|
||||||
|
|
||||||
return web.FileResponse(
|
|
||||||
os.path.join(
|
|
||||||
bumper_dir, "bumper", "web", "images", "robotvac_image.jpg"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
||||||
async def handle_getConfignetAll(self, request):
|
async def handle_getConfignetAll(self, request):
|
||||||
try:
|
try:
|
||||||
body = confignetAllResponse
|
body = confignetAllResponse
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,14 @@
|
||||||
"""Global plugin module."""
|
"""Global plugin module."""
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
from aiohttp.web_exceptions import HTTPInternalServerError
|
|
||||||
from aiohttp.web_request import Request
|
|
||||||
from aiohttp.web_response import StreamResponse
|
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper import bumper_dir
|
from bumper.web.images import get_bot_image
|
||||||
|
|
||||||
from .. import WebserverPlugin
|
from .. import WebserverPlugin
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
|
||||||
class GlobalPlugin(WebserverPlugin):
|
class GlobalPlugin(WebserverPlugin):
|
||||||
"""Global plugin."""
|
"""Global plugin."""
|
||||||
|
|
||||||
|
|
@ -24,19 +18,7 @@ class GlobalPlugin(WebserverPlugin):
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/global/{year}/{month}/{day}/{fileid}",
|
"/global/{year}/{month}/{day}/{id}",
|
||||||
self._handle_upload_global_file,
|
get_bot_image,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
async def _handle_upload_global_file(self, _: Request) -> StreamResponse:
|
|
||||||
try:
|
|
||||||
return web.FileResponse(
|
|
||||||
os.path.join(
|
|
||||||
bumper_dir, "bumper", "web", "images", "robotvac_image.jpg"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except Exception: # pylint: disable=broad-except
|
|
||||||
logging.error("Unexpected exception occurred", exc_info=True)
|
|
||||||
|
|
||||||
raise HTTPInternalServerError
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
"""Private plugins module."""
|
"""Private plugins module."""
|
||||||
|
|
||||||
|
BASE_URL = "/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/"
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
"""Ad plugin module."""
|
"""Ad plugin module."""
|
||||||
import logging
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
from ... import WebserverPlugin, get_success_response
|
||||||
from bumper.util import get_current_time_as_millis
|
from . import BASE_URL
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
|
||||||
|
|
||||||
|
|
||||||
class AdPlugin(WebserverPlugin):
|
class AdPlugin(WebserverPlugin):
|
||||||
|
|
@ -20,42 +19,16 @@ class AdPlugin(WebserverPlugin):
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/ad/getAdByPositionType",
|
f"{BASE_URL}ad/getAdByPositionType",
|
||||||
self.handle_getAdByPositionType,
|
_handle,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/ad/getBootScreen",
|
f"{BASE_URL}ad/getBootScreen",
|
||||||
self.handle_getBootScreen,
|
_handle,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
async def handle_getAdByPositionType(self, request): # EcoVacs Home
|
|
||||||
try:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": None,
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
async def _handle(_: Request) -> Response:
|
||||||
|
return get_success_response(None)
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
||||||
async def handle_getBootScreen(self, request): # EcoVacs Home
|
|
||||||
try:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": None,
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
"""Campaign plugin module."""
|
"""Campaign plugin module."""
|
||||||
import logging
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
|
||||||
from bumper.util import convert_to_millis, get_current_time_as_millis
|
from bumper.util import convert_to_millis, get_current_time_as_millis
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
from ... import WebserverPlugin, get_success_response
|
||||||
|
from . import BASE_URL
|
||||||
|
|
||||||
|
|
||||||
class CampaignPlugin(WebserverPlugin):
|
class CampaignPlugin(WebserverPlugin):
|
||||||
|
|
@ -21,33 +22,21 @@ class CampaignPlugin(WebserverPlugin):
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/campaign/homePageAlert",
|
f"{BASE_URL}campaign/homePageAlert",
|
||||||
self.handle_homePageAlert,
|
_handle_home_page_alert,
|
||||||
name="v1_campaign_homePageAlert",
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
async def handle_homePageAlert(self, request):
|
|
||||||
try:
|
|
||||||
nextAlert = convert_to_millis(
|
|
||||||
(datetime.now() + timedelta(hours=12)).timestamp()
|
|
||||||
)
|
|
||||||
|
|
||||||
body = {
|
async def _handle_home_page_alert(_: Request) -> Response:
|
||||||
"code": RETURN_API_SUCCESS,
|
nextAlert = convert_to_millis((datetime.now() + timedelta(hours=12)).timestamp())
|
||||||
"data": {
|
return get_success_response(
|
||||||
"clickSchemeUrl": None,
|
{
|
||||||
"clickWebUrl": None,
|
"clickSchemeUrl": None,
|
||||||
"hasCampaign": "N",
|
"clickWebUrl": None,
|
||||||
"imageUrl": None,
|
"hasCampaign": "N",
|
||||||
"nextAlertTime": nextAlert,
|
"imageUrl": None,
|
||||||
"serverTime": get_current_time_as_millis(),
|
"nextAlertTime": nextAlert,
|
||||||
},
|
"serverTime": get_current_time_as_millis(),
|
||||||
"msg": "操作成功",
|
}
|
||||||
"time": get_current_time_as_millis(),
|
)
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ from aiohttp.web_request import Request
|
||||||
from aiohttp.web_response import Response
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
|
||||||
from bumper.util import get_current_time_as_millis
|
from bumper.util import get_current_time_as_millis
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
from ... import WebserverPlugin, get_success_response
|
||||||
|
from . import BASE_URL
|
||||||
|
|
||||||
|
|
||||||
class CommonPlugin(WebserverPlugin):
|
class CommonPlugin(WebserverPlugin):
|
||||||
|
|
@ -22,55 +22,53 @@ class CommonPlugin(WebserverPlugin):
|
||||||
@property
|
@property
|
||||||
def routes(self) -> Iterable[AbstractRouteDef]:
|
def routes(self) -> Iterable[AbstractRouteDef]:
|
||||||
"""Plugin routes."""
|
"""Plugin routes."""
|
||||||
base_url = "/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/common/"
|
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}checkAPPVersion",
|
f"{BASE_URL}common/checkAPPVersion",
|
||||||
_handle_check_app_version,
|
_handle_check_app_version,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}checkVersion",
|
f"{BASE_URL}common/checkVersion",
|
||||||
_handle_check_version,
|
_handle_check_version,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}uploadDeviceInfo",
|
f"{BASE_URL}common/uploadDeviceInfo",
|
||||||
_handle_upload_device_info,
|
_handle_upload_device_info,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}getSystemReminder",
|
f"{BASE_URL}common/getSystemReminder",
|
||||||
_handle_get_system_reminder,
|
_handle_get_system_reminder,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}getConfig",
|
f"{BASE_URL}common/getConfig",
|
||||||
_handle_get_config,
|
_handle_get_config,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}getAreas",
|
f"{BASE_URL}common/getAreas",
|
||||||
_handle_get_areas,
|
_handle_get_areas,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}getAgreementURLBatch",
|
f"{BASE_URL}common/getAgreementURLBatch",
|
||||||
_handle_get_agreement_url_batch,
|
_handle_get_agreement_url_batch,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
f"{base_url}getTimestamp",
|
f"{BASE_URL}common/getTimestamp",
|
||||||
_handle_get_timestamp,
|
_handle_get_timestamp,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
async def _handle_check_version(_: Request) -> Response:
|
async def _handle_check_version(_: Request) -> Response:
|
||||||
body = {
|
return get_success_response(
|
||||||
"code": RETURN_API_SUCCESS,
|
{
|
||||||
"data": {
|
|
||||||
"c": None,
|
"c": None,
|
||||||
"img": None,
|
"img": None,
|
||||||
"r": 0,
|
"r": 0,
|
||||||
|
|
@ -78,18 +76,13 @@ async def _handle_check_version(_: Request) -> Response:
|
||||||
"u": None,
|
"u": None,
|
||||||
"ut": 0,
|
"ut": 0,
|
||||||
"v": None,
|
"v": None,
|
||||||
},
|
}
|
||||||
"msg": "操作成功",
|
)
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
|
|
||||||
async def _handle_check_app_version(_: Request) -> Response:
|
async def _handle_check_app_version(_: Request) -> Response:
|
||||||
body = {
|
return get_success_response(
|
||||||
"code": RETURN_API_SUCCESS,
|
{
|
||||||
"data": {
|
|
||||||
"c": None,
|
"c": None,
|
||||||
"downPageUrl": None,
|
"downPageUrl": None,
|
||||||
"img": None,
|
"img": None,
|
||||||
|
|
@ -99,44 +92,25 @@ async def _handle_check_app_version(_: Request) -> Response:
|
||||||
"u": None,
|
"u": None,
|
||||||
"ut": 0,
|
"ut": 0,
|
||||||
"v": None,
|
"v": None,
|
||||||
},
|
}
|
||||||
"msg": "操作成功",
|
)
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
|
|
||||||
async def _handle_upload_device_info(_: Request) -> Response:
|
async def _handle_upload_device_info(_: Request) -> Response:
|
||||||
body = {
|
return get_success_response(None)
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": None,
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
|
|
||||||
async def _handle_get_system_reminder(_: Request) -> Response:
|
async def _handle_get_system_reminder(_: Request) -> Response:
|
||||||
body = {
|
return get_success_response(
|
||||||
"code": RETURN_API_SUCCESS,
|
{
|
||||||
"data": {
|
|
||||||
"iosGradeTime": {"iodGradeFlag": "N"},
|
"iosGradeTime": {"iodGradeFlag": "N"},
|
||||||
"openNotification": {
|
"openNotification": {
|
||||||
"openNotificationContent": None,
|
"openNotificationContent": None,
|
||||||
"openNotificationFlag": "N",
|
"openNotificationFlag": "N",
|
||||||
"openNotificationTitle": None,
|
"openNotificationTitle": None,
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
"msg": "操作成功",
|
)
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
|
|
||||||
async def _handle_get_config(request: Request) -> Response:
|
async def _handle_get_config(request: Request) -> Response:
|
||||||
|
|
@ -145,15 +119,7 @@ async def _handle_get_config(request: Request) -> Response:
|
||||||
for key in request.query["keys"].split(","):
|
for key in request.query["keys"].split(","):
|
||||||
data.append({"key": key, "value": "Y"})
|
data.append({"key": key, "value": "Y"})
|
||||||
|
|
||||||
body = {
|
return get_success_response(data)
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": data,
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
logging.error("Unexpected exception occurred", exc_info=True)
|
logging.error("Unexpected exception occurred", exc_info=True)
|
||||||
|
|
||||||
|
|
@ -162,16 +128,11 @@ async def _handle_get_config(request: Request) -> Response:
|
||||||
|
|
||||||
async def _handle_get_areas(_: Request) -> Response:
|
async def _handle_get_areas(_: Request) -> Response:
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(os.path.dirname(__file__), "area.json")) as file:
|
with open(
|
||||||
body = {
|
os.path.join(os.path.dirname(__file__), "common_area.json"),
|
||||||
"code": RETURN_API_SUCCESS,
|
encoding="utf-8",
|
||||||
"data": json.load(file),
|
) as file:
|
||||||
"msg": "操作成功",
|
return get_success_response(json.load(file))
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
logging.error("Unexpected exception occurred", exc_info=True)
|
logging.error("Unexpected exception occurred", exc_info=True)
|
||||||
|
|
||||||
|
|
@ -179,9 +140,8 @@ async def _handle_get_areas(_: Request) -> Response:
|
||||||
|
|
||||||
|
|
||||||
async def _handle_get_agreement_url_batch(_: Request) -> Response:
|
async def _handle_get_agreement_url_batch(_: Request) -> Response:
|
||||||
body = {
|
return get_success_response(
|
||||||
"code": RETURN_API_SUCCESS,
|
[
|
||||||
"data": [
|
|
||||||
{
|
{
|
||||||
"acceptTime": None,
|
"acceptTime": None,
|
||||||
"force": None,
|
"force": None,
|
||||||
|
|
@ -198,23 +158,9 @@ async def _handle_get_agreement_url_batch(_: Request) -> Response:
|
||||||
"url": "https://gl-eu-wap.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN",
|
"url": "https://gl-eu-wap.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN",
|
||||||
"version": "1.03",
|
"version": "1.03",
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
"msg": "操作成功",
|
)
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
|
|
||||||
async def _handle_get_timestamp(_: Request) -> Response:
|
async def _handle_get_timestamp(_: Request) -> Response:
|
||||||
time = get_current_time_as_millis()
|
return get_success_response({"timestamp": get_current_time_as_millis()})
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": {"timestamp": time},
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": time,
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
import logging
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
from ... import WebserverPlugin, get_success_response
|
||||||
from bumper.util import get_current_time_as_millis
|
from . import BASE_URL
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
|
||||||
|
|
||||||
|
|
||||||
class MessagePlugin(WebserverPlugin):
|
class MessagePlugin(WebserverPlugin):
|
||||||
|
|
@ -19,42 +18,20 @@ class MessagePlugin(WebserverPlugin):
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/message/hasUnreadMsg",
|
f"{BASE_URL}message/hasUnreadMsg",
|
||||||
self.handle_hasUnreadMessage,
|
_handle_has_unread_message,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/message/getMsgList",
|
f"{BASE_URL}message/getMsgList",
|
||||||
self.handle_getMsgList,
|
_handle_get_msg_list,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
async def handle_hasUnreadMessage(self, request): # EcoVacs Home
|
|
||||||
try:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": "N",
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
async def _handle_has_unread_message(_: Request) -> Response:
|
||||||
|
return get_success_response("N")
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
||||||
async def handle_getMsgList(self, request): # EcoVacs Home
|
async def _handle_get_msg_list(_: Request) -> Response:
|
||||||
try:
|
return get_success_response({"hasNextPage": 0, "items": []})
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": {"hasNextPage": 0, "items": []},
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
"""Shop plugin module."""
|
"""Shop plugin module."""
|
||||||
import logging
|
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
from ... import WebserverPlugin, get_success_response
|
||||||
from bumper.util import get_current_time_as_millis
|
from . import BASE_URL
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
|
||||||
|
|
||||||
|
|
||||||
class ShopPlugin(WebserverPlugin):
|
class ShopPlugin(WebserverPlugin):
|
||||||
|
|
@ -20,27 +19,18 @@ class ShopPlugin(WebserverPlugin):
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/shop/getCnWapShopConfig",
|
f"{BASE_URL}shop/getCnWapShopConfig",
|
||||||
self.handle_getCnWapShopConfig,
|
_handle_get_cn_wap_shop_config,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
async def handle_getCnWapShopConfig(self, request): # EcoVacs Home
|
|
||||||
try:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": {
|
|
||||||
"myShopShowFlag": "N",
|
|
||||||
"myShopUrl": "",
|
|
||||||
"shopIndexShowFlag": "N",
|
|
||||||
"shopIndexUrl": "",
|
|
||||||
},
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
async def _handle_get_cn_wap_shop_config(_: Request) -> Response:
|
||||||
|
return get_success_response(
|
||||||
except Exception as e:
|
{
|
||||||
logging.exception(f"{e}")
|
"myShopShowFlag": "N",
|
||||||
|
"myShopUrl": "",
|
||||||
|
"shopIndexShowFlag": "N",
|
||||||
|
"shopIndexUrl": "",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
import logging
|
"""User plugin module."""
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
from aiohttp.web_response import Response
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
|
||||||
from bumper.util import get_current_time_as_millis
|
|
||||||
from bumper.web import auth_util
|
from bumper.web import auth_util
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
from ... import WebserverPlugin, get_success_response
|
||||||
|
from . import BASE_URL
|
||||||
|
|
||||||
|
|
||||||
class UserPlugin(WebserverPlugin):
|
class UserPlugin(WebserverPlugin):
|
||||||
|
|
@ -20,199 +21,148 @@ class UserPlugin(WebserverPlugin):
|
||||||
return [
|
return [
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/login",
|
f"{BASE_URL}user/login",
|
||||||
auth_util.login,
|
auth_util.login,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkLogin",
|
f"{BASE_URL}user/checkLogin",
|
||||||
auth_util.login,
|
auth_util.login,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getAuthCode",
|
f"{BASE_URL}user/getAuthCode",
|
||||||
auth_util.get_authcode,
|
auth_util.get_authcode,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/logout",
|
f"{BASE_URL}user/logout",
|
||||||
auth_util.logout,
|
auth_util.logout,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkAgreement",
|
f"{BASE_URL}user/checkAgreement",
|
||||||
self.handle_checkAgreement,
|
_handle_check_agreement,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/checkAgreementBatch",
|
f"{BASE_URL}user/checkAgreementBatch",
|
||||||
self.handle_checkAgreement,
|
_handle_check_agreement,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getUserAccountInfo",
|
f"{BASE_URL}user/getUserAccountInfo",
|
||||||
auth_util.get_user_account_info,
|
auth_util.get_user_account_info,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/getUserMenuInfo",
|
f"{BASE_URL}user/getUserMenuInfo",
|
||||||
self.handle_getUserMenuInfo,
|
_handle_get_user_menu_info,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/changeArea",
|
f"{BASE_URL}user/changeArea",
|
||||||
self.handle_changeArea,
|
_handle_change_area,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/queryChangeArea",
|
f"{BASE_URL}user/queryChangeArea",
|
||||||
self.handle_changeArea,
|
_handle_change_area,
|
||||||
),
|
),
|
||||||
web.route(
|
web.route(
|
||||||
"*",
|
"*",
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/acceptAgreementBatch",
|
f"{BASE_URL}user/acceptAgreementBatch",
|
||||||
self.handle_acceptAgreementBatch,
|
_handle_accept_agreement_batch,
|
||||||
),
|
),
|
||||||
# Direct register from app:
|
|
||||||
# /{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/user/directRegister
|
|
||||||
# Register by email
|
|
||||||
# /registerByEmail
|
|
||||||
]
|
]
|
||||||
|
|
||||||
async def handle_checkAgreement(self, request):
|
|
||||||
try:
|
|
||||||
apptype = request.match_info.get("apptype", "")
|
|
||||||
if "global_" in apptype:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": [
|
|
||||||
{
|
|
||||||
"force": "N",
|
|
||||||
"id": "20180804040641_7d746faf18b8cb22a50d145598fe4c90",
|
|
||||||
"type": "USER",
|
|
||||||
"url": "https://bumper.ecovacs.com/content/agreement?id=20180804040641_7d746faf18b8cb22a50d145598fe4c90&language=EN", # "https://gl-us-wap.ecovacs.com/content/agreement?id=20180804040641_7d746faf18b8cb22a50d145598fe4c90&language=EN
|
|
||||||
"version": "1.01",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"force": "N",
|
|
||||||
"id": "20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac",
|
|
||||||
"type": "PRIVACY",
|
|
||||||
"url": "https://bumper.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN", # "https://gl-us-wap.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN"
|
|
||||||
"version": "1.01",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": [],
|
|
||||||
"msg": "操作成功",
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
async def _handle_check_agreement(request: Request) -> Response:
|
||||||
|
apptype = request.match_info.get("apptype", "")
|
||||||
|
data = []
|
||||||
|
if "global_" in apptype:
|
||||||
|
data = [
|
||||||
|
{
|
||||||
|
"force": "N",
|
||||||
|
"id": "20180804040641_7d746faf18b8cb22a50d145598fe4c90",
|
||||||
|
"type": "USER",
|
||||||
|
"url": "https://bumper.ecovacs.com/content/agreement?id=20180804040641_7d746faf18b8cb22a50d145598fe4c90&language=EN", # "https://gl-us-wap.ecovacs.com/content/agreement?id=20180804040641_7d746faf18b8cb22a50d145598fe4c90&language=EN
|
||||||
|
"version": "1.01",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"force": "N",
|
||||||
|
"id": "20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac",
|
||||||
|
"type": "PRIVACY",
|
||||||
|
"url": "https://bumper.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN", # "https://gl-us-wap.ecovacs.com/content/agreement?id=20180804040245_4e7c56dfb7ebd3b81b1f2747d0859fac&language=EN"
|
||||||
|
"version": "1.01",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
except Exception as e:
|
return get_success_response(data)
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
||||||
async def handle_getUserMenuInfo(self, request):
|
|
||||||
try:
|
async def _handle_get_user_menu_info(_: Request) -> Response:
|
||||||
apptype = request.match_info.get("apptype", "")
|
return get_success_response(
|
||||||
body = {
|
[
|
||||||
"code": "0000",
|
{
|
||||||
"data": [
|
"menuItems": [
|
||||||
{
|
{
|
||||||
"menuItems": [
|
"clickAction": 1,
|
||||||
{
|
"clickUri": "https://ecovacs.zendesk.com/hc/en-us",
|
||||||
"clickAction": 1,
|
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/2019121603180741b73907046e742b80e8fe4a90fe2498.png",
|
||||||
"clickUri": "https://ecovacs.zendesk.com/hc/en-us",
|
"menuId": "20191216031849_4d744630f7ad2f5208a4b8051be61d10",
|
||||||
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/2019121603180741b73907046e742b80e8fe4a90fe2498.png",
|
"menuName": "Help & Feedback",
|
||||||
"menuId": "20191216031849_4d744630f7ad2f5208a4b8051be61d10",
|
"paramsJson": "",
|
||||||
"menuName": "Help & Feedback",
|
}
|
||||||
"paramsJson": "",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"menuPositionKey": "A_FIRST",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"menuItems": [
|
|
||||||
{
|
|
||||||
"clickAction": 3,
|
|
||||||
"clickUri": "robotShare",
|
|
||||||
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/2019121603284185e632ec6c5da10bd82119d7047a1f9e.png",
|
|
||||||
"menuId": "20191216032853_5fac4cc9cbd0e166dfa951485d1d8cc4",
|
|
||||||
"menuName": "Share Robot",
|
|
||||||
"paramsJson": "",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"menuPositionKey": "B_SECOND",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"menuItems": [
|
|
||||||
{
|
|
||||||
"clickAction": 3,
|
|
||||||
"clickUri": "config",
|
|
||||||
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/201912160325324068da4e4a09b8c3973db162e84784d5.png",
|
|
||||||
"menuId": "20191216032545_ebea0fbb4cb02d9c2fec5bdf3371bc2d",
|
|
||||||
"menuName": "Settings",
|
|
||||||
"paramsJson": "",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"menuPositionKey": "C_THIRD",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"menuItems": [
|
|
||||||
{
|
|
||||||
"clickAction": 1,
|
|
||||||
"clickUri": "https://bumper.ecovacs.com/",
|
|
||||||
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/201912160325324068da4e4a09b8c3973db162e84784d5.png",
|
|
||||||
"menuId": "20191216032545_ebea0fbb4cb02d9c2fec5bdf3371bc2c",
|
|
||||||
"menuName": "Bumper Status",
|
|
||||||
"paramsJson": "",
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"menuPositionKey": "D_FOURTH",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
"msg": "操作成功",
|
"menuPositionKey": "A_FIRST",
|
||||||
"success": True,
|
},
|
||||||
"time": get_current_time_as_millis(),
|
{
|
||||||
}
|
"menuItems": [
|
||||||
|
{
|
||||||
|
"clickAction": 3,
|
||||||
|
"clickUri": "robotShare",
|
||||||
|
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/2019121603284185e632ec6c5da10bd82119d7047a1f9e.png",
|
||||||
|
"menuId": "20191216032853_5fac4cc9cbd0e166dfa951485d1d8cc4",
|
||||||
|
"menuName": "Share Robot",
|
||||||
|
"paramsJson": "",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"menuPositionKey": "B_SECOND",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"menuItems": [
|
||||||
|
{
|
||||||
|
"clickAction": 3,
|
||||||
|
"clickUri": "config",
|
||||||
|
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/201912160325324068da4e4a09b8c3973db162e84784d5.png",
|
||||||
|
"menuId": "20191216032545_ebea0fbb4cb02d9c2fec5bdf3371bc2d",
|
||||||
|
"menuName": "Settings",
|
||||||
|
"paramsJson": "",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"menuPositionKey": "C_THIRD",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"menuItems": [
|
||||||
|
{
|
||||||
|
"clickAction": 1,
|
||||||
|
"clickUri": "https://bumper.ecovacs.com/",
|
||||||
|
"menuIconUrl": "https://gl-us-pub.ecovacs.com/upload/global/2019/12/16/201912160325324068da4e4a09b8c3973db162e84784d5.png",
|
||||||
|
"menuId": "20191216032545_ebea0fbb4cb02d9c2fec5bdf3371bc2c",
|
||||||
|
"menuName": "Bumper Status",
|
||||||
|
"paramsJson": "",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"menuPositionKey": "D_FOURTH",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
except Exception as e:
|
async def _handle_change_area(_: Request) -> Response:
|
||||||
logging.exception(f"{e}")
|
return get_success_response({"isNeedReLogin": "N"})
|
||||||
|
|
||||||
async def handle_changeArea(self, request):
|
|
||||||
try:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": {"isNeedReLogin": "N"},
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
async def _handle_accept_agreement_batch(_: Request) -> Response:
|
||||||
|
return get_success_response(None)
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
||||||
async def handle_acceptAgreementBatch(self, request):
|
|
||||||
try:
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": None,
|
|
||||||
"msg": "操作成功",
|
|
||||||
"success": True,
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
|
||||||
51
bumper/web/plugins/v1/private/user_setting.py
Normal file
51
bumper/web/plugins/v1/private/user_setting.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
"""User setting plugin module."""
|
||||||
|
|
||||||
|
from typing import Iterable
|
||||||
|
|
||||||
|
from aiohttp import web
|
||||||
|
from aiohttp.web_request import Request
|
||||||
|
from aiohttp.web_response import Response
|
||||||
|
from aiohttp.web_routedef import AbstractRouteDef
|
||||||
|
|
||||||
|
from ... import WebserverPlugin, get_success_response
|
||||||
|
from . import BASE_URL
|
||||||
|
|
||||||
|
|
||||||
|
class UserSettingPlugin(WebserverPlugin):
|
||||||
|
"""User setting plugin."""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def routes(self) -> Iterable[AbstractRouteDef]:
|
||||||
|
"""Plugin routes."""
|
||||||
|
return [
|
||||||
|
web.route(
|
||||||
|
"*",
|
||||||
|
f"{BASE_URL}userSetting/getSuggestionSetting",
|
||||||
|
_handle_get_suggestion_setting,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def _handle_get_suggestion_setting(_: Request) -> Response:
|
||||||
|
return get_success_response(
|
||||||
|
{
|
||||||
|
"acceptSuggestion": "Y",
|
||||||
|
"itemList": [
|
||||||
|
{
|
||||||
|
"name": "Aktionen/Angebote/Ereignisse",
|
||||||
|
"settingKey": "MARKETING",
|
||||||
|
"val": "Y",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Benutzerbefragung",
|
||||||
|
"settingKey": "QUESTIONNAIRE",
|
||||||
|
"val": "Y",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Produkt-Upgrade/Hilfe für Benutzer",
|
||||||
|
"settingKey": "INTRODUCTION",
|
||||||
|
"val": "Y",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
"""user setting plugin module."""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
from typing import Iterable
|
|
||||||
|
|
||||||
from aiohttp import web
|
|
||||||
from aiohttp.web_routedef import AbstractRouteDef
|
|
||||||
|
|
||||||
from bumper.models import RETURN_API_SUCCESS
|
|
||||||
from bumper.util import get_current_time_as_millis
|
|
||||||
|
|
||||||
from ... import WebserverPlugin
|
|
||||||
|
|
||||||
|
|
||||||
class UserSettingPlugin(WebserverPlugin):
|
|
||||||
"""User setting plugin."""
|
|
||||||
|
|
||||||
@property
|
|
||||||
def routes(self) -> Iterable[AbstractRouteDef]:
|
|
||||||
"""Plugin routes."""
|
|
||||||
return [
|
|
||||||
web.route(
|
|
||||||
"*",
|
|
||||||
"/{country}/{language}/{devid}/{apptype}/{appversion}/{devtype}/{aid}/userSetting/getSuggestionSetting",
|
|
||||||
self.handle_getSuggestionSetting,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
|
|
||||||
async def handle_getSuggestionSetting(self, request):
|
|
||||||
try:
|
|
||||||
|
|
||||||
body = {
|
|
||||||
"code": RETURN_API_SUCCESS,
|
|
||||||
"data": {
|
|
||||||
"acceptSuggestion": "Y",
|
|
||||||
"itemList": [
|
|
||||||
{
|
|
||||||
"name": "Aktionen/Angebote/Ereignisse",
|
|
||||||
"settingKey": "MARKETING",
|
|
||||||
"val": "Y",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Benutzerbefragung",
|
|
||||||
"settingKey": "QUESTIONNAIRE",
|
|
||||||
"val": "Y",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Produkt-Upgrade/Hilfe für Benutzer",
|
|
||||||
"settingKey": "INTRODUCTION",
|
|
||||||
"val": "Y",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"msg": "操作成功",
|
|
||||||
"time": get_current_time_as_millis(),
|
|
||||||
}
|
|
||||||
|
|
||||||
return web.json_response(body)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception(f"{e}")
|
|
||||||
|
|
@ -21,7 +21,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- ./nginx/:/etc/nginx:ro # See config file below
|
- ./nginx/:/etc/nginx:ro # See config file below
|
||||||
|
|
||||||
bumper:
|
bumper:
|
||||||
image: bmartin5692/bumper
|
image: bmartin5692/bumper
|
||||||
|
|
@ -33,7 +33,7 @@ services:
|
||||||
PUID: 1000
|
PUID: 1000
|
||||||
PGID: 1000
|
PGID: 1000
|
||||||
TZ: Europe/Rome
|
TZ: Europe/Rome
|
||||||
BUMPER_ANNOUNCE_IP: XXX # Insert your IP
|
BUMPER_ANNOUNCE_IP: XXX # Insert your IP
|
||||||
BUMPER_LISTEN: 0.0.0.0
|
BUMPER_LISTEN: 0.0.0.0
|
||||||
# BUMPER_DEBUG: "true"
|
# BUMPER_DEBUG: "true"
|
||||||
LOG_TO_STDOUT: "true"
|
LOG_TO_STDOUT: "true"
|
||||||
|
|
|
||||||
|
|
@ -496,7 +496,8 @@ async def test_getProductIotMap(webserver_client):
|
||||||
jsonresp = json.loads(text)
|
jsonresp = json.loads(text)
|
||||||
assert jsonresp["code"] == RETURN_API_SUCCESS
|
assert jsonresp["code"] == RETURN_API_SUCCESS
|
||||||
|
|
||||||
# Test getPimFile
|
|
||||||
|
async def test_pim_file(webserver_client):
|
||||||
resp = await webserver_client.get("/api/pim/file/get/123")
|
resp = await webserver_client.get("/api/pim/file/get/123")
|
||||||
assert resp.status == 200
|
assert resp.status == 200
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue