|
- from flask_restful import Resource, reqparse
- from flask import jsonify,request,json
- from common import redis_helper,utils
- from wechat import gewe_chat
-
-
-
- class GetWxchatConfigResource(Resource):
- def __init__(self):
- self.parser = reqparse.RequestParser()
- self.wxchat = gewe_chat.wxchat
-
- def post(self):
- req = request.get_json()
- wxid = req.get("wxid")
- config=self.wxchat.get_wxchat_config_from_cache(wxid)
- return jsonify(config)
-
-
-
- class SaveWxchatConfigResource(Resource):
- def __init__(self):
- self.parser = reqparse.RequestParser()
- self.wxchat = gewe_chat.wxchat
-
- def post(self):
- req = request.get_json()
- wxid = req.get("wxid")
- data = req.get("data")
- # hash_key="__AI_OPS_WX__:WXCHAT_CONFIG"
- # redis_helper.redis_helper.update_hash_field(hash_key, wxid, json.dumps(data,ensure_ascii=False))
- self.wxchat.save_wxchat_config(wxid, data)
- return jsonify({'wxid': wxid, 'config': data})
|