chore: remove CRUD definition dirs from tracking, add gitignore

This commit is contained in:
yumoqing 2026-05-29 13:18:22 +08:00
parent cc5803d4a7
commit 4892a4e460
21 changed files with 5 additions and 1940 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
# CRUD definition directories (auto-generated by Sage platform)
wwwroot/uapi/
wwwroot/uapiio/
wwwroot/upapp/
wwwroot/upappkey/

View File

@ -1,37 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
ns['id'] = id
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('uapi', ns.copy())
return {
"widgettype":"Message",
"options":{
"cwidth":16,
"cheight":9,
"title":"Add Success",
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,33 +0,0 @@
ns = {
'id':params_kw['id'],
}
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('uapi', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
}

View File

@ -1,155 +0,0 @@
ns = params_kw.copy()
debug_params('get_uapi', ns)
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'name'
sql = '''select a.*, b.httpmethod_text, c.need_auth_text, d.stream_text, e.ioid_text
from (select * from uapi where 1=1 [[filterstr]]) a left join (select k as httpmethod,
v as httpmethod_text from appcodes_kv where parentid='httpmethod') b on a.httpmethod = b.httpmethod left join (select k as need_auth,
v as need_auth_text from appcodes_kv where parentid='yesno') c on a.need_auth = c.need_auth left join (select k as stream,
v as stream_text from appcodes_kv where parentid='resp_mode') d on a.stream = d.stream left join (select id as ioid,
name as ioid_text from uapiio where 1 = 1) e on a.ioid = e.ioid'''
filterjson = params_kw.get('data_filter')
fields_str=r'''[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32
},
{
"name": "upappid",
"title": "上位系统ID",
"type": "str",
"length": 32
},
{
"name": "name",
"title": "api名称",
"type": "str",
"length": 200
},
{
"name": "title",
"title": "API标题",
"type": "str",
"length": 100
},
{
"name": "description",
"title": "接口描述",
"type": "text"
},
{
"name": "need_auth",
"title": "需要鉴权",
"type": "str",
"length": 1,
"default": "0"
},
{
"name": "stream",
"title": "流式输出",
"type": "str",
"length": 20
},
{
"name": "path",
"title": "path",
"type": "str",
"length": 4000
},
{
"name": "httpmethod",
"title": "http方法",
"type": "str",
"length": 20,
"nullable": "yes",
"default": "GET"
},
{
"name": "chunk_match",
"title": "流式匹配串",
"type": "str",
"length": 100
},
{
"name": "headers",
"title": "headers模版",
"type": "text",
"nullable": "yes"
},
{
"name": "params",
"title": "参数模版",
"type": "text",
"nullable": "yes"
},
{
"name": "data",
"title": "数据模版",
"type": "text",
"nullable": "yes"
},
{
"name": "response",
"title": "响应模版",
"type": "text",
"nullable": "yes"
},
{
"name": "ioid",
"title": "输入输出id",
"type": "str",
"length": 32,
"nullable": "yes"
},
{
"name": "callbackurl",
"title": "回调url",
"type": "str",
"length": 1000,
"nullable": "yes"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
filterdic['userorgid'] = '${userorgid}$'
filterdic['userid'] = '${userid}$'
if filterjson:
dbf = DBFilter(filterjson)
conds = dbf.gen(ns)
if conds:
ns.update(dbf.consts)
conds = f' and {conds}'
filterdic['filterstr'] = conds
ac = ArgsConvert('[[', ']]')
vars = ac.findAllVariables(sql)
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
filterdic.update(NameSpace)
sql = ac.convert(sql, filterdic)
debug(f'sql({len(sql)}ch): {sql[:200]}')
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,291 +0,0 @@
{
"id":"uapi_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"API",
"description":"API定义",
"toolbar":{
"tools": [
{
"selected_row": true,
"name": "test",
"icon": "{{entire_url('/imgs/test.svg')}}",
"label": "api测试"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_uapi.dspy')}}",
"delete_data_url":"{{entire_url('delete_uapi.dspy')}}",
"update_data_url":"{{entire_url('update_uapi.dspy')}}"
},
"data_url":"{{entire_url('./get_uapi.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id"
],
"alters": {}
},
"editexclouded":[
"id"
],
"fields":[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "upappid",
"title": "上位系统ID",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "上位系统ID"
},
{
"name": "name",
"title": "api名称",
"type": "str",
"length": 200,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "api名称"
},
{
"name": "title",
"title": "API标题",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "API标题"
},
{
"name": "description",
"title": "接口描述",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "接口描述"
},
{
"name": "need_auth",
"title": "需要鉴权",
"type": "str",
"length": 1,
"default": "0",
"label": "需要鉴权",
"uitype": "code",
"valueField": "need_auth",
"textField": "need_auth_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "need_auth",
"textField": "need_auth_text",
"cond": "parentid='yesno'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "stream",
"title": "流式输出",
"type": "str",
"length": 20,
"label": "流式输出",
"uitype": "code",
"valueField": "stream",
"textField": "stream_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "stream",
"textField": "stream_text",
"cond": "parentid='resp_mode'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "path",
"title": "path",
"type": "str",
"length": 4000,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "path"
},
{
"name": "httpmethod",
"title": "http方法",
"type": "str",
"length": 20,
"nullable": "yes",
"default": "GET",
"label": "http方法",
"uitype": "code",
"valueField": "httpmethod",
"textField": "httpmethod_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "httpmethod",
"textField": "httpmethod_text",
"cond": "parentid='httpmethod'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "chunk_match",
"title": "流式匹配串",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "流式匹配串"
},
{
"name": "headers",
"title": "headers模版",
"type": "text",
"nullable": "yes",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "headers模版"
},
{
"name": "params",
"title": "参数模版",
"type": "text",
"nullable": "yes",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "参数模版"
},
{
"name": "data",
"title": "数据模版",
"type": "text",
"nullable": "yes",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "数据模版"
},
{
"name": "response",
"title": "响应模版",
"type": "text",
"nullable": "yes",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "响应模版"
},
{
"name": "ioid",
"title": "输入输出id",
"type": "str",
"length": 32,
"nullable": "yes",
"label": "输入输出id",
"uitype": "code",
"valueField": "ioid",
"textField": "ioid_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "uapiio",
"tblvalue": "id",
"tbltext": "name",
"valueField": "ioid",
"textField": "ioid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "callbackurl",
"title": "回调url",
"type": "str",
"length": 1000,
"nullable": "yes",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "回调url"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "test",
"actiontype": "urlwidget",
"target": "PopupWindow",
"options": {
"methid": "POST",
"params": {},
"url": "{{entire_url('/uapi/uapi_test.ui')}}"
}
}
]
}

View File

@ -1,36 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('uapi', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,37 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
ns['id'] = id
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('uapiio', ns.copy())
return {
"widgettype":"Message",
"options":{
"cwidth":16,
"cheight":9,
"title":"Add Success",
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,33 +0,0 @@
ns = {
'id':params_kw['id'],
}
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('uapiio', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
}

View File

@ -1,72 +0,0 @@
ns = params_kw.copy()
debug_params('get_uapiio', ns)
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'name'
sql = '''select * from uapiio where 1=1 [[filterstr]]'''
filterjson = params_kw.get('data_filter')
fields_str=r'''[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32
},
{
"name": "name",
"title": "类型名",
"type": "str",
"length": 100
},
{
"name": "description",
"title": "类型说明",
"type": "text"
},
{
"name": "input_fields",
"title": "输入字段",
"type": "text"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
filterdic['userorgid'] = '${userorgid}$'
filterdic['userid'] = '${userid}$'
if filterjson:
dbf = DBFilter(filterjson)
conds = dbf.gen(ns)
if conds:
ns.update(dbf.consts)
conds = f' and {conds}'
filterdic['filterstr'] = conds
ac = ArgsConvert('[[', ']]')
vars = ac.findAllVariables(sql)
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
filterdic.update(NameSpace)
sql = ac.convert(sql, filterdic)
debug(f'sql({len(sql)}ch): {sql[:200]}')
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,103 +0,0 @@
{
"id":"uapiio_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"API输入输出",
"description":"API的输入输出定义",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_uapiio.dspy')}}",
"delete_data_url":"{{entire_url('delete_uapiio.dspy')}}",
"update_data_url":"{{entire_url('update_uapiio.dspy')}}"
},
"data_url":"{{entire_url('./get_uapiio.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id"
],
"alters": {}
},
"editexclouded":[
"id"
],
"fields":[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "name",
"title": "类型名",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "类型名"
},
{
"name": "description",
"title": "类型说明",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "类型说明"
},
{
"name": "input_fields",
"title": "输入字段",
"type": "text",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "输入字段"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}

View File

@ -1,36 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.U('uapiio', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,54 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
ns['id'] = id
if params_kw.get('secretkey'):
ns['secretkey'] = password_encode(params_kw.get('secretkey'))
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('upapp', ns.copy())
return {
"widgettype":"Message",
"options":{
"cwidth":16,
"cheight":9,
"title":"Add Success",
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,47 +0,0 @@
ns = {
'id':params_kw['id'],
}
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userorgid
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('upapp', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
}

View File

@ -1,129 +0,0 @@
ns = params_kw.copy()
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userorgid
ns['userorgid'] = userorgid
debug_params('get_upapp', ns)
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'name'
sql = '''select a.*, b.ownerid_text
from (select * from upapp where 1=1 [[filterstr]]) a left join (select id as ownerid,
orgname as ownerid_text from organization where 1 = 1) b on a.ownerid = b.ownerid'''
filterjson = params_kw.get('data_filter')
fields_str=r'''[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32
},
{
"name": "name",
"title": "上位应用名",
"type": "str",
"length": 200
},
{
"name": "description",
"title": "描述",
"type": "text",
"default": "0"
},
{
"name": "ownerid",
"title": "所属机构",
"type": "str",
"length": 32,
"nullable": "yes"
},
{
"name": "apisetid",
"title": "api集id",
"type": "str",
"length": 32
},
{
"name": "secretkey",
"title": "加密密钥",
"type": "str",
"length": 100
},
{
"name": "baseurl",
"title": "系统url",
"type": "str",
"length": 500
},
{
"name": "myappid",
"title": "我的appid",
"type": "str",
"length": 100
},
{
"name": "dynamic_func",
"title": "动态headers函数",
"type": "str",
"length": 255
},
{
"name": "auth_apiname",
"title": "认证API名",
"type": "str",
"length": 200,
"nullable": "yes"
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
filterdic['userorgid'] = '${userorgid}$'
filterdic['userid'] = '${userid}$'
if filterjson:
dbf = DBFilter(filterjson)
conds = dbf.gen(ns)
if conds:
ns.update(dbf.consts)
conds = f' and {conds}'
filterdic['filterstr'] = conds
ac = ArgsConvert('[[', ']]')
vars = ac.findAllVariables(sql)
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
filterdic.update(NameSpace)
sql = ac.convert(sql, filterdic)
debug(f'sql({len(sql)}ch): {sql[:200]}')
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,258 +0,0 @@
{
"id":"upapp_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"上位系统",
"description":"上位系统",
"toolbar":{
"tools": [
{
"name": "jumpin",
"label": "跳转到",
"selected_data": true
},
{
"selected_row": true,
"name": "upappkey",
"icon": "{{entire_url('/imgs/upappkey.svg')}}",
"label": "APIKEY"
},
{
"selected_row": true,
"name": "uapi",
"icon": "{{entire_url('/imgs/uapi.svg')}}",
"label": "API"
}
]
},
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_upapp.dspy')}}",
"delete_data_url":"{{entire_url('delete_upapp.dspy')}}",
"update_data_url":"{{entire_url('update_upapp.dspy')}}"
},
"data_url":"{{entire_url('./get_upapp.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"ownerid"
],
"alters": {}
},
"editexclouded":[
"ownerid"
],
"fields":[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "name",
"title": "上位应用名",
"type": "str",
"length": 200,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "上位应用名"
},
{
"name": "description",
"title": "描述",
"type": "text",
"default": "0",
"length": 0,
"uitype": "text",
"datatype": "text",
"label": "描述"
},
{
"name": "ownerid",
"title": "所属机构",
"type": "str",
"length": 32,
"nullable": "yes",
"label": "所属机构",
"uitype": "code",
"valueField": "ownerid",
"textField": "ownerid_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "ownerid",
"textField": "ownerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "apisetid",
"title": "api集id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "api集id"
},
{
"name": "secretkey",
"title": "加密密钥",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "password",
"datatype": "str",
"label": "加密密钥"
},
{
"name": "baseurl",
"title": "系统url",
"type": "str",
"length": 500,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "系统url"
},
{
"name": "myappid",
"title": "我的appid",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "我的appid"
},
{
"name": "dynamic_func",
"title": "动态headers函数",
"type": "str",
"length": 255,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "动态headers函数"
},
{
"name": "auth_apiname",
"title": "认证API名",
"type": "str",
"length": 200,
"nullable": "yes",
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "认证API名"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[
{
"wid": "self",
"event": "jumpin",
"actiontype": "urlwidget",
"target": "self",
"options": {
"url": "{{entire_url('/uapi/jump_in.dspy')}}"
}
},
{
"wid": "self",
"event": "upappkey",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "APIKEY",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=upappkey",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "upappid",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('../upappkey')}}"
}
},
{
"wid": "self",
"event": "uapi",
"actiontype": "urlwidget",
"target": "PopupWindow",
"popup_options": {
"title": "API",
"icon": "{{entire_url('/appbase/get_icon.dspy')}}?id=uapi",
"resizable": true,
"height": "70%",
"width": "70%"
},
"params_mapping": {
"mapping": {
"id": "upappid",
"referer_widget": "referer_widget"
},
"need_other": false
},
"options": {
"method": "POST",
"params": {},
"url": "{{entire_url('../uapi')}}"
}
}
]
}

View File

@ -1,73 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userorgid
if params_kw.get('secretkey'):
ns['secretkey'] = password_encode(params_kw.get('secretkey'))
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"ownerid": userorgid,
"id": params_kw.id
}
recs = await sor.R('upapp', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('upapp', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,71 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
id = params_kw.id
if not id or len(id) > 32:
id = uuid()
ns['id'] = id
if params_kw.get('apikey'):
ns['apikey'] = password_encode(params_kw.get('apikey'))
if params_kw.get('apipasswd'):
ns['apipasswd'] = password_encode(params_kw.get('apipasswd'))
userid = await get_user()
if not userid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userid
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['orgid'] = userorgid
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.C('upappkey', ns.copy())
return {
"widgettype":"Message",
"options":{
"cwidth":16,
"cheight":9,
"title":"Add Success",
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Add Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}

View File

@ -1,61 +0,0 @@
ns = {
'id':params_kw['id'],
}
userid = await get_user()
if not userid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userid
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['orgid'] = userorgid
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.D('upappkey', ns)
debug('delete success');
return {
"widgettype":"Message",
"options":{
"title":"Delete Success",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"ok"
}
}
debug('Delete failed');
return {
"widgettype":"Error",
"options":{
"title":"Delete Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"failed"
}
}

View File

@ -1,133 +0,0 @@
ns = params_kw.copy()
userid = await get_user()
if not userid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userid
ns['userid'] = userid
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['orgid'] = userorgid
ns['userorgid'] = userorgid
debug_params('get_upappkey', ns)
if not ns.get('page'):
ns['page'] = 1
if not ns.get('sort'):
ns['sort'] = 'id'
sql = '''select a.*, b.ownerid_text, c.upappid_text, d.orgid_text, e.is_first_text
from (select * from upappkey where 1=1 [[filterstr]]) a left join (select id as ownerid,
username as ownerid_text from users where 1 = 1) b on a.ownerid = b.ownerid left join (select id as upappid,
name as upappid_text from upapp where 1 = 1) c on a.upappid = c.upappid left join (select id as orgid,
orgname as orgid_text from organization where 1 = 1) d on a.orgid = d.orgid left join (select k as is_first,
v as is_first_text from appcodes_kv where parentid='yesno') e on a.is_first = e.is_first'''
filterjson = params_kw.get('data_filter')
fields_str=r'''[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32
},
{
"name": "upappid",
"title": "应用id",
"type": "str",
"length": 32
},
{
"name": "ownerid",
"title": "属主id",
"type": "str",
"length": 32,
"default": "0"
},
{
"name": "apikey",
"title": "api密钥",
"type": "str",
"length": 4000,
"default": "0"
},
{
"name": "apiuser",
"title": "api用户",
"type": "str",
"length": 100
},
{
"name": "apipasswd",
"title": "api密码",
"type": "str",
"length": 100
},
{
"name": "orgid",
"title": "属主机构id",
"type": "str",
"length": 32
},
{
"name": "is_first",
"title": "是否第一用户",
"type": "str",
"length": 1
}
]'''
ori_fields = json.loads(fields_str)
if not filterjson:
fields = [ f['name'] for f in ori_fields ]
filterjson = default_filterjson(fields, ns)
filterdic = ns.copy()
filterdic['filterstr'] = ''
filterdic['userorgid'] = '${userorgid}$'
filterdic['userid'] = '${userid}$'
if filterjson:
dbf = DBFilter(filterjson)
conds = dbf.gen(ns)
if conds:
ns.update(dbf.consts)
conds = f' and {conds}'
filterdic['filterstr'] = conds
ac = ArgsConvert('[[', ']]')
vars = ac.findAllVariables(sql)
NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' }
filterdic.update(NameSpace)
sql = ac.convert(sql, filterdic)
debug(f'sql({len(sql)}ch): {sql[:200]}')
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
r = await sor.sqlPaging(sql, ns)
return r
return {
"total":0,
"rows":[]
}

View File

@ -1,189 +0,0 @@
{
"id":"upappkey_tbl",
"widgettype":"Tabular",
"options":{
"width":"100%",
"height":"100%",
"title":"上位系统密码",
"description":"上位系统密码",
"css":"card",
"editable":{
"new_data_url":"{{entire_url('add_upappkey.dspy')}}",
"delete_data_url":"{{entire_url('delete_upappkey.dspy')}}",
"update_data_url":"{{entire_url('update_upappkey.dspy')}}"
},
"data_url":"{{entire_url('./get_upappkey.dspy')}}",
"data_method":"GET",
"data_params":{{json.dumps(params_kw, indent=4, ensure_ascii=False)}},
"row_options":{
"browserfields": {
"exclouded": [
"id",
"ownerid",
"orgid"
],
"alters": {}
},
"editexclouded":[
"id",
"upappid",
"ownerid",
"orgid"
],
"fields":[
{
"name": "id",
"title": "id",
"type": "str",
"length": 32,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "id"
},
{
"name": "upappid",
"title": "应用id",
"type": "str",
"length": 32,
"label": "应用id",
"uitype": "code",
"valueField": "upappid",
"textField": "upappid_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "upapp",
"tblvalue": "id",
"tbltext": "name",
"valueField": "upappid",
"textField": "upappid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "ownerid",
"title": "属主id",
"type": "str",
"length": 32,
"default": "0",
"label": "属主id",
"uitype": "code",
"valueField": "ownerid",
"textField": "ownerid_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "users",
"tblvalue": "id",
"tbltext": "username",
"valueField": "ownerid",
"textField": "ownerid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "apikey",
"title": "api密钥",
"type": "str",
"length": 4000,
"default": "0",
"cwidth": 18,
"uitype": "password",
"datatype": "str",
"label": "api密钥"
},
{
"name": "apiuser",
"title": "api用户",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "str",
"datatype": "str",
"label": "api用户"
},
{
"name": "apipasswd",
"title": "api密码",
"type": "str",
"length": 100,
"cwidth": 18,
"uitype": "password",
"datatype": "str",
"label": "api密码"
},
{
"name": "orgid",
"title": "属主机构id",
"type": "str",
"length": 32,
"label": "属主机构id",
"uitype": "code",
"valueField": "orgid",
"textField": "orgid_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "organization",
"tblvalue": "id",
"tbltext": "orgname",
"valueField": "orgid",
"textField": "orgid_text"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
},
{
"name": "is_first",
"title": "是否第一用户",
"type": "str",
"length": 1,
"label": "是否第一用户",
"uitype": "code",
"valueField": "is_first",
"textField": "is_first_text",
"params": {
"dbname": "{{get_module_dbname('uapi')}}",
"table": "appcodes_kv",
"tblvalue": "k",
"tbltext": "v",
"valueField": "is_first",
"textField": "is_first_text",
"cond": "parentid='yesno'"
},
"dataurl": "{{entire_url('/appbase/get_code.dspy')}}"
}
]
},
"page_rows":160,
"cache_limit":5
}
,"binds":[]
}

View File

@ -1,92 +0,0 @@
ns = params_kw.copy()
for k,v in ns.items():
if v == 'NaN' or v == 'null':
ns[k] = None
userid = await get_user()
if not userid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['ownerid'] = userid
userorgid = await get_userorgid()
if not userorgid:
return {
"widgettype":"Error",
"options":{
"title":"Authorization Error",
"timeout":3,
"cwidth":16,
"cheight":9,
"message":"Please login"
}
}
ns['orgid'] = userorgid
if params_kw.get('apikey'):
ns['apikey'] = password_encode(params_kw.get('apikey'))
if params_kw.get('apipasswd'):
ns['apipasswd'] = password_encode(params_kw.get('apipasswd'))
db = DBPools()
dbname = get_module_dbname('uapi')
async with db.sqlorContext(dbname) as sor:
ns1 = {
"orgid": userorgid,
"ownerid": userid,
"id": params_kw.id
}
recs = await sor.R('upappkey', ns1)
if len(recs) < 1:
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"Record no exist or with wrong ownership"
}
}
r = await sor.U('upappkey', ns)
debug('update success');
return {
"widgettype":"Message",
"options":{
"title":"Update Success",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"ok"
}
}
return {
"widgettype":"Error",
"options":{
"title":"Update Error",
"cwidth":16,
"cheight":9,
"timeout":3,
"message":"failed"
}
}