Merge branch 'main' of git.opencomputing.cn:yumoqing/dapi
This commit is contained in:
commit
cc817377c9
0
dapi/__init__.py
Normal file
0
dapi/__init__.py
Normal file
@ -4,20 +4,12 @@
|
|||||||
"params": {
|
"params": {
|
||||||
"sortby":"id",
|
"sortby":"id",
|
||||||
"confidential_fields":["secretkey"],
|
"confidential_fields":["secretkey"],
|
||||||
"noedit":true,
|
|
||||||
"browserfields": {
|
"browserfields": {
|
||||||
"exclouded": ["id", "secretkey" ],
|
"exclouded": ["id", "secretkey", "orgid" ],
|
||||||
"alters": {}
|
"alters": {}
|
||||||
},
|
},
|
||||||
"editexclouded": [
|
"editexclouded": [
|
||||||
|
"id", "secretkey", "orgid"
|
||||||
],
|
|
||||||
"subtables": [
|
|
||||||
{
|
|
||||||
"field":"appid",
|
|
||||||
"title":"apikey",
|
|
||||||
"subtable":"downapikey"
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"toolbar":{
|
"toolbar":{
|
||||||
"tools":[
|
"tools":[
|
||||||
@ -29,6 +21,7 @@
|
|||||||
{
|
{
|
||||||
"name":"copy_apikey",
|
"name":"copy_apikey",
|
||||||
"label":"复制apikey",
|
"label":"复制apikey",
|
||||||
|
"selected_row":true,
|
||||||
"icon":"{{entire_url('/imgs/copy.svg')}}"
|
"icon":"{{entire_url('/imgs/copy.svg')}}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -59,9 +52,10 @@
|
|||||||
"archor":"cr"
|
"archor":"cr"
|
||||||
},
|
},
|
||||||
"options":{
|
"options":{
|
||||||
"url":"{{entire_url('/dapi/copy_apikey.ui')}}"
|
"url":"{{entire_url('/dapi/copy_apikey.dspy')}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name=kyapikeyclient
|
name=dapi
|
||||||
version = 0.0.2
|
version = 0.0.2
|
||||||
description = Your project description
|
description = Your project description
|
||||||
author = "yu moqing"
|
author = "yu moqing"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
debug(f'{params_kw=}')
|
debug(f'{params_kw=}')
|
||||||
dbname = get_module_dbname()
|
dbname = get_module_dbname('dapi')
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
orgid = await get_userorgid()
|
orgid = await get_userorgid()
|
||||||
@ -7,7 +7,7 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
ns = {
|
ns = {
|
||||||
"id": params_kw.id,
|
"id": params_kw.id,
|
||||||
"orgid":orgid,
|
"orgid":orgid,
|
||||||
"userid":"userid
|
"userid":userid
|
||||||
}
|
}
|
||||||
sql = """select a.*,
|
sql = """select a.*,
|
||||||
b.apikey
|
b.apikey
|
||||||
@ -19,5 +19,42 @@ where a.id = b.dappid
|
|||||||
recs = await sor.sqlExe(sql, ns)
|
recs = await sor.sqlExe(sql, ns)
|
||||||
if len(recs):
|
if len(recs):
|
||||||
r = recs[0]
|
r = recs[0]
|
||||||
return UiMessage(title="copy apikey", message=f'appid={r.id}, apikey={r.apikey} secretkey={r.secretkey}')
|
return {
|
||||||
return UiError(title='copy apikey', message='copy apikey error')
|
"widgettype":"VBox",
|
||||||
|
"options":{
|
||||||
|
"height":"100%",
|
||||||
|
"width":"100%"
|
||||||
|
},
|
||||||
|
"subwidgets":[
|
||||||
|
{
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"wrap":True,
|
||||||
|
"halign":"left",
|
||||||
|
"text":f"appid={r.dappid}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"wrap":True,
|
||||||
|
"halign":"left",
|
||||||
|
"text":f"apikey={r.apikey}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"wrap":True,
|
||||||
|
"halign":"left",
|
||||||
|
"text":f"secretkey={r.secretkey}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"widgettype":"Text",
|
||||||
|
"options":{
|
||||||
|
"text":'copy apikey error'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
debug(f'{params_kw=}')
|
debug(f'{params_kw=}')
|
||||||
dbname = get_module_dbname()
|
dbname = get_module_dbname('dapi')
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
orgid = await get_userorgid()
|
orgid = await get_userorgid()
|
||||||
userid = await get_user()
|
userid = await get_user()
|
||||||
ns = {
|
ns = {
|
||||||
"id": uuid(),
|
"id": uuid(),
|
||||||
"name": params_kw.name,
|
"name": params_kw.appname,
|
||||||
"description": params_kw.description,
|
"description": params_kw.description,
|
||||||
"secretkey": uuid(),
|
"secretkey": uuid(),
|
||||||
"allowedips": params_kw.allowips,
|
"allowedips": params_kw.allowedips,
|
||||||
"orgid": orgid
|
"orgid": orgid
|
||||||
}
|
}
|
||||||
await sor.C('downapp', ns)
|
await sor.C('downapp', ns)
|
||||||
ns1 = {
|
ns1 = {
|
||||||
"id": uuid()
|
"id": uuid(),
|
||||||
"dappid": ns['id'],
|
"dappid": ns['id'],
|
||||||
"userid": userid,
|
"userid": userid,
|
||||||
"apikey": uuid(),
|
"apikey": uuid(),
|
||||||
@ -22,5 +22,5 @@ async with db.sqlorContext(dbname) as sor:
|
|||||||
"expired_date": '9999-12-31'
|
"expired_date": '9999-12-31'
|
||||||
}
|
}
|
||||||
await sor.C('downapikey', ns1)
|
await sor.C('downapikey', ns1)
|
||||||
return UiMessage(title="create apikey", message=f'appid={ns['id']}, apikey={ns1['apikey']}, secretkey={ns['secretkey'}')
|
return UiMessage(title="create apikey", message=f"appid={ns['id']}, apikey={ns1['apikey']}, secretkey={ns['secretkey']}")
|
||||||
return UiError(title='create apikey', message='add apikey error')
|
return UiError(title='create apikey', message='add apikey error')
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"options":{
|
"options":{
|
||||||
"title":"创建用户apikey",
|
"title":"创建用户apikey",
|
||||||
"dscription":"下位系统要免密登录本系统,需要设置apikey和secretkey",
|
"dscription":"下位系统要免密登录本系统,需要设置apikey和secretkey",
|
||||||
"field":[
|
"fields":[
|
||||||
{
|
{
|
||||||
"name":"appname",
|
"name":"appname",
|
||||||
"label":"应用名",
|
"label":"应用名",
|
||||||
@ -25,7 +25,7 @@
|
|||||||
"binds":[
|
"binds":[
|
||||||
{
|
{
|
||||||
"wid":"self",
|
"wid":"self",
|
||||||
"evnet":"submit",
|
"event":"submit",
|
||||||
"actiontype":"urlwidget",
|
"actiontype":"urlwidget",
|
||||||
"target":"self",
|
"target":"self",
|
||||||
"options":{
|
"options":{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user