This commit is contained in:
kf_wuhao 2021-01-21 16:30:53 +08:00
parent 7f25572ce8
commit 0a481f8bf7
4 changed files with 54 additions and 27 deletions

11
api.py
View File

@ -5,6 +5,7 @@ from flask_cors import CORS
import pandas as pd import pandas as pd
from handler import * from handler import *
from settings import settings
app = Flask(__name__) app = Flask(__name__)
CORS(app) CORS(app)
@ -13,6 +14,7 @@ api = Api(app)
parser = reqparse.RequestParser() parser = reqparse.RequestParser()
parser.add_argument('st', type=int) parser.add_argument('st', type=int)
parser.add_argument('et', type=int) parser.add_argument('et', type=int)
parser.add_argument('is_dev', type=int)
class Check(Resource): class Check(Resource):
@ -20,13 +22,18 @@ class Check(Resource):
args = parser.parse_args() args = parser.parse_args()
st = args['st'] st = args['st']
et = args['et'] et = args['et']
is_dev = args['is_dev']
if not all(args.values()): if not all(args.values()):
return {'msg': '缺少参数'} return {'msg': '缺少参数'}
date = pd.Timestamp(st, unit='s', tz='Asia/Shanghai').strftime('%Y-%m-%d') date = pd.Timestamp(st, unit='s', tz='Asia/Shanghai').strftime('%Y-%m-%d')
where = { where = {
'_ut': {'$gte': st, '$lte': et} '_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_user = check_data('user', where, factory)
res_paylist = check_data('paylist', where, factory) res_paylist = check_data('paylist', where, factory)
res_event = check_data('event', where, factory) res_event = check_data('event', where, factory)
@ -41,4 +48,4 @@ class Check(Resource):
api.add_resource(Check, '/<string:game>') api.add_resource(Check, '/<string:game>')
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0') app.run(debug=True, host='0.0.0.0', port=5777)

View File

@ -3,14 +3,11 @@ from pydantic import ValidationError
import pandas as pd import pandas as pd
from model import * from model import *
from settings import settings
__all__ = ('select_db', 'check_data') __all__ = ('select_db', 'check_data')
myclient = pymongo.MongoClient(settings.MONGO_URI)
def select_db(game, date, mongo_uri):
def select_db(game, date): myclient = pymongo.MongoClient(mongo_uri)
factory = { factory = {
'user': {'coll': None, 'models': [TUserModel, UserModel]}, 'user': {'coll': None, 'models': [TUserModel, UserModel]},
'paylist': {'coll': None, 'models': [TPaylistModel, PaylistModel]}, 'paylist': {'coll': None, 'models': [TPaylistModel, PaylistModel]},

View File

@ -11,24 +11,39 @@
element-loading-text="拼命加载中" element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading" element-loading-spinner="el-icon-loading"
> >
<el-col :span="3" :offset="1">
<el-select v-model="game" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-col>
<el-select v-model="game" placeholder="请选择"> <el-col :span="5">
<el-option <el-time-picker
v-for="item in options" is-range
:key="item.value" v-model="date"
:label="item.label" range-separator="至"
:value="item.value"> start-placeholder="开始时间"
</el-option> end-placeholder="结束时间"
</el-select> placeholder="选择时间范围">
<el-time-picker </el-time-picker>
is-range </el-col>
v-model="date"
range-separator="至" <el-col :span="1">
start-placeholder="开始时间" <el-button icon="el-icon-search" circle @click="seach()"></el-button>
end-placeholder="结束时间" </el-col>
placeholder="选择时间范围">
</el-time-picker> <el-col :span="2" :offset="10">
<el-button icon="el-icon-search" circle @click="seach()"></el-button> <el-switch
v-model="isDev"
active-text="测试"
inactive-text="生产">
</el-switch>
</el-col>
</el-row> </el-row>
@ -78,12 +93,13 @@
label: '中古战锤' label: '中古战锤'
}], }],
loading: false, loading: false,
game: '', game: 'geshouccs',
cdate: new Date(), cdate: new Date(),
date: [new Date(curTime.setMinutes(curTime.getMinutes() - 10)), new Date()], date: [new Date(curTime.setMinutes(curTime.getMinutes() - 10)), new Date()],
userTable: '', userTable: '',
paylistTable: '', paylistTable: '',
eventTable: '', eventTable: '',
isDev: true,
} }
}, },
@ -91,9 +107,10 @@
seach: function () { seach: function () {
this.loading = true; this.loading = true;
var game = this.game; var game = this.game;
var is_dev = this.isDev==true?1:2;
var st = Date.parse(this.date[0]) / 1000; var st = Date.parse(this.date[0]) / 1000;
var et = Date.parse(this.date[1]) / 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 => { .then(response => {
this.userTable = '<h1>user</h1>' + response.data['user']; this.userTable = '<h1>user</h1>' + response.data['user'];
this.paylistTable = '<h1>paylist</h1>' + response.data['paylist']; this.paylistTable = '<h1>paylist</h1>' + response.data['paylist'];

View File

@ -1,5 +1,11 @@
class Settings: 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 settings = Settings