feat: base wxmp, wx无需显示在conf指定
This commit is contained in:
parent
3e56fa7390
commit
e0d4c4beff
|
@ -22,11 +22,12 @@ class WxClient:
|
||||||
微信公众号相关
|
微信公众号相关
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, app_id=settings.WX_APPID,
|
def __init__(self, app_id='',
|
||||||
app_secret=settings.WX_APPSECRET) -> None:
|
app_secret='') -> None:
|
||||||
if settings.WX_ENABLED:
|
self.wx_enabled = getattr(settings, 'WX_ENABLED', False)
|
||||||
self.app_id = app_id
|
if self.wx_enabled:
|
||||||
self.app_secret = app_secret
|
self.app_id = app_id if app_id else getattr(settings, 'WX_APPID', False)
|
||||||
|
self.app_secret = app_secret if app_id else getattr(settings, 'WX_APPSECRET', False)
|
||||||
self.isRuning = True
|
self.isRuning = True
|
||||||
self.token = None # 普通token
|
self.token = None # 普通token
|
||||||
self.t = None # 线程
|
self.t = None # 线程
|
||||||
|
@ -58,7 +59,7 @@ class WxClient:
|
||||||
|
|
||||||
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=10,
|
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=10,
|
||||||
file_path_rela=None, raise_exception=True):
|
file_path_rela=None, raise_exception=True):
|
||||||
if not settings.WX_ENABLED:
|
if not self.wx_enabled:
|
||||||
raise ParseError('微信公众号未启用')
|
raise ParseError('微信公众号未启用')
|
||||||
self.log = {"requested_at": now(), "id": uuid.uuid4(), "path": url, "method": method,
|
self.log = {"requested_at": now(), "id": uuid.uuid4(), "path": url, "method": method,
|
||||||
"params": params, "body": json, "target": "wx", "result": 10}
|
"params": params, "body": json, "target": "wx", "result": 10}
|
||||||
|
|
|
@ -20,17 +20,17 @@ class WxmpClient:
|
||||||
微信小程序相关
|
微信小程序相关
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, app_id=settings.WXMP_APPID,
|
def __init__(self, app_id='', app_secret='') -> None:
|
||||||
app_secret=settings.WXMP_APPSECRET) -> None:
|
self.wxmp_enabled = getattr(settings, 'WXMP_ENABLED', False)
|
||||||
self.app_id, self.app_secret = None, None
|
self.app_id, self.app_secret = None, None
|
||||||
if settings.WXMP_ENABLED:
|
if self.wxmp_enabled:
|
||||||
self.app_id = app_id
|
self.app_id = app_id if app_id else getattr(settings, 'WXMP_APPID', False)
|
||||||
self.app_secret = app_secret
|
self.app_secret = app_secret if app_secret else getattr(settings, 'WXMP_APPSECRET', False)
|
||||||
self.log = {}
|
self.log = {}
|
||||||
|
|
||||||
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=10,
|
def request(self, url: str, method: str, params=dict(), json=dict(), timeout=10,
|
||||||
file_path_rela=None, raise_exception=True):
|
file_path_rela=None, raise_exception=True):
|
||||||
if not settings.WX_ENABLED:
|
if not self.wxmp_enabled:
|
||||||
raise ParseError('微信小程序未启用')
|
raise ParseError('微信小程序未启用')
|
||||||
self.log = {"requested_at": now(), "id": uuid.uuid4(), "path": url, "method": method,
|
self.log = {"requested_at": now(), "id": uuid.uuid4(), "path": url, "method": method,
|
||||||
"params": params, "body": json, "target": "wx", "result": 10}
|
"params": params, "body": json, "target": "wx", "result": 10}
|
||||||
|
|
Loading…
Reference in New Issue