Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/web/thisdb/app.py

65 lines
2.0 KiB

6 months ago
# coding:utf-8
# ---------------------------------------------------------------------------------
# MW-Linux面板
# ---------------------------------------------------------------------------------
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
# ---------------------------------------------------------------------------------
# Author: midoks <midoks@163.com>
# ---------------------------------------------------------------------------------
import core.mw as mw
6 months ago
__FIELD = 'id,app_id,app_secret,white_list,status,add_time,update_time'
6 months ago
6 months ago
def addApp(app_id,app_secret,white_list):
6 months ago
now_time = mw.getDateFromNow()
6 months ago
add_data = {
'app_id': app_id,
'app_secret': app_secret,
'status': 1,
6 months ago
'white_list':white_list,
6 months ago
'add_time': now_time,
'update_time': now_time
}
return mw.M('app').insert(add_data)
5 months ago
def getAppList(page=1,size=10):
6 months ago
m = mw.M('app').field(__FIELD)
6 months ago
6 months ago
start = (int(page) - 1) * (int(size))
6 months ago
limit = str(start) + ',' +str(size)
6 months ago
app_list = m.limit(limit).order('id desc').select()
count = m.count()
6 months ago
6 months ago
data = {}
6 months ago
data['list'] = app_list
data['count'] = count
return data
def getAppById(aid):
6 months ago
return mw.M('app').field(__FIELD).where("id=?", (aid,)).find()
6 months ago
5 months ago
def getAppByAppId(app_id):
return mw.M('app').field(__FIELD).where("app_id=?", (app_id,)).find()
6 months ago
def deleteAppById(aid):
return mw.M('app').where("id=?", (aid,)).delete()
6 months ago
def toggleAppStatus(aid):
info = mw.M('app').field(__FIELD).where("id=?", (aid,)).find()
if info['status'] == 1:
return mw.M('app').where('id=?',(aid,)).update({'status':0})
return mw.M('app').where('id=?',(aid,)).update({'status':1})
5 months ago
def setAppData(aid, status=None, app_id=None, app_secret=None):
6 months ago
up_data = {}
if status is not None:
up_data['status'] = status
if app_id is not None:
up_data['app_id'] = app_id
if app_secret is not None:
up_data['app_secret'] = app_secret
return mw.M('app').where('id=?',(aid,)).update(up_data)