diff --git a/api.py b/api.py index 1087808..595b669 100644 --- a/api.py +++ b/api.py @@ -5,6 +5,7 @@ from flask_cors import CORS import pandas as pd from handler import * +from settings import settings app = Flask(__name__) CORS(app) @@ -13,6 +14,7 @@ api = Api(app) parser = reqparse.RequestParser() parser.add_argument('st', type=int) parser.add_argument('et', type=int) +parser.add_argument('is_dev', type=int) class Check(Resource): @@ -20,13 +22,18 @@ class Check(Resource): args = parser.parse_args() st = args['st'] et = args['et'] + is_dev = args['is_dev'] if not all(args.values()): return {'msg': '缺少参数'} date = pd.Timestamp(st, unit='s', tz='Asia/Shanghai').strftime('%Y-%m-%d') where = { '_ut': {'$gte': st, '$lte': et} } - factory = select_db(game, date) + mongo_uri = 'mongodb://root:iamciniao@10.0.0.7:27017' + if is_dev != 1: + mongo_uri = settings.mongo_uri_dict[game] + + factory = select_db(game, date, mongo_uri) res_user = check_data('user', where, factory) res_paylist = check_data('paylist', where, factory) res_event = check_data('event', where, factory) @@ -41,4 +48,4 @@ class Check(Resource): api.add_resource(Check, '/') if __name__ == '__main__': - app.run(debug=True, host='0.0.0.0') + app.run(debug=True, host='0.0.0.0', port=5777) diff --git a/handler.py b/handler.py index 7a09950..200ee06 100644 --- a/handler.py +++ b/handler.py @@ -3,14 +3,11 @@ from pydantic import ValidationError import pandas as pd from model import * -from settings import settings - __all__ = ('select_db', 'check_data') -myclient = pymongo.MongoClient(settings.MONGO_URI) - -def select_db(game, date): +def select_db(game, date, mongo_uri): + myclient = pymongo.MongoClient(mongo_uri) factory = { 'user': {'coll': None, 'models': [TUserModel, UserModel]}, 'paylist': {'coll': None, 'models': [TPaylistModel, PaylistModel]}, diff --git a/index.html b/index.html index b7833c6..3614d1a 100644 --- a/index.html +++ b/index.html @@ -11,24 +11,39 @@ element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" > + + + + + + - - - - - - - + + + + + + + + + + + + + @@ -78,12 +93,13 @@ label: '中古战锤' }], loading: false, - game: '', + game: 'geshouccs', cdate: new Date(), date: [new Date(curTime.setMinutes(curTime.getMinutes() - 10)), new Date()], userTable: '', paylistTable: '', eventTable: '', + isDev: true, } }, @@ -91,9 +107,10 @@ seach: function () { this.loading = true; var game = this.game; + var is_dev = this.isDev==true?1:2; var st = Date.parse(this.date[0]) / 1000; var et = Date.parse(this.date[1]) / 1000; - axios.get('http://10.0.0.7:5777/' + game, {params: {'st': st, 'et': et}}) + axios.get('http://10.0.0.107:5777/' + game, {params: {'st': st, 'et': et,'is_dev':is_dev}}) .then(response => { this.userTable = '

user

' + response.data['user']; this.paylistTable = '

paylist

' + response.data['paylist']; diff --git a/settings.py b/settings.py index b108475..8b50201 100644 --- a/settings.py +++ b/settings.py @@ -1,5 +1,11 @@ class Settings: - MONGO_URI = 'mongodb://root:iamciniao@10.0.0.7:27017' + mongo_uri_dict = { + 'fengbaoqibing':'mongodb://root:iamciniao@8.129.233.127:27017', + 'geshouccs':'mongodb://root:iamciniao@119.29.176.224:27017', + 'shenghuajiyuan':'mongodb://root:iamciniao@42.194.225.107:27017', + 'xinyaoling':'mongodb://root:iamciniao@39.104.90.204:27017', + 'zgzhanchui':'mongodb://root:iamciniao@119.29.35.35:27017', + } settings = Settings