add user_online interface

This commit is contained in:
pengtao 2020-03-20 14:34:27 +08:00
parent 79247fbaf4
commit 473c466e0d
4 changed files with 75 additions and 0 deletions

View File

@ -17,3 +17,10 @@ else:
if not interface_port:
interface_port = 6500
online_mysql = {
"host": '10.10.3.5',
"user": 'ops',
"pswd": 'deploy2018',
"db": 'user_online'
}

31
expirt_service.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h2>不思议英雄数据清理工具</h2>
<main>
<a href="#"><img src="http://cdn.freecodecamp.cn/relaxing-cat.jpg" alt="不思议英雄数据清理工具"></a>
<p>请输入需要清理的账号名称如6001_3100_xxxx</p>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
function get() {
$.get()
}
</scripttype>
<form action="/submit-cat-photo">
<input type="text" name = "accountid" placeholder="账号ID">
<button type="submit" onclick="get()">提交</button>
</form>
</main>
</body>
</html>

30
online/online_data.py Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/python
# -*- coding:utf-8 _*-
"""
@author: pengtao
@file: online_data.py
@time: 2020/03/20
"""
from config.config import online_mysql
from ops.mmysql import MysqlBase
import datetime
class OnlineData2mysql:
def __init__(self, data):
self.data = data
self.table = 'online_num'
def _insert2mysql(self):
mydb = MysqlBase(**online_mysql)
t_data = {}
t_data['game_id'] = self.data.get('game_id', 0)
t_data['channel_id'] = self.data.get('channel_id', 0)
t_data['zone_id'] = self.data.get('zone_id', 0)
t_data['number'] = self.data.get('number', 0)
t_data['updatetime'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
mydb.insert(self.table, t_data)
def run(self):
self._insert2mysql()

7
web.py
View File

@ -15,6 +15,7 @@ from data_channel.gamelog_external import Build_Gamelog_Config
from data_channel.mp2shushu import Mp2shushu
from deploy.deploy_keys import DeployKeys
from deploy.clear_service_data import ClearService
from online.online_data import OnlineData2mysql
define_logger("/data/logs/myops/ops_interface.log")
log = logging.getLogger(__name__)
@ -31,6 +32,8 @@ class DispatchHandler(tornado.web.RequestHandler):
yield self._selfmp2ss()
elif self.get_query_argument('c') == 'Ops' and self.get_query_argument('a') == 'clear_redis':
yield self._selfclear_redis()
elif self.get_query_argument('c') == 'Ops' and self.get_query_argument('a') == 'user_online':
yield self._user_online()
elif self.get_query_argument('c') == 'Deploy' and self.get_query_argument('a') == 'keys':
yield self._selfdeploykeys()
else:
@ -40,6 +43,10 @@ class DispatchHandler(tornado.web.RequestHandler):
# def post(self):
# if self.get_query_argument('c') == 'Ops' and self.get_query_argument('a') == 'upJumpRecording':
# self._selfupJumpRecording()
def _user_online(self):
data = self.get_query_argument('accountid')
aa = OnlineData2mysql(data)
aa.run()
def _selfdeploykeys(self):
try: