first commit
This commit is contained in:
commit
809ef77898
10
README.md
Normal file
10
README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# appbase
|
||||
基本应用包,主要是提供代码管理和系统参数管理能力
|
||||
|
||||
## 参数管理
|
||||
应用系统的参数集中管理,为系统提供可动态维护的参数
|
||||
业务日期,应用的业务日期存储在参数表中,并提供函数用于获得系统日期和设置心业务日期
|
||||
|
||||
## 代码管理
|
||||
提供系统键值对管理和维护能力
|
||||
|
||||
0
appbase/__init__.py
Normal file
0
appbase/__init__.py
Normal file
47
appbase/businessdate.py
Normal file
47
appbase/businessdate.py
Normal file
@ -0,0 +1,47 @@
|
||||
from sqlor.dbpools import DBPools
|
||||
from ahserver.serverenv import get_serverenv
|
||||
from appPublic.timeUtils import strdate_add
|
||||
|
||||
def get_dbname():
|
||||
f = get_serverenv('get_module_dbname')
|
||||
if f is None:
|
||||
raise Exception('get_module_dbname not found')
|
||||
dbname = f('appbase')
|
||||
|
||||
async def get_business_date(sor=None):
|
||||
async def _f(sor):
|
||||
sql = "select * from params where params_name = 'business_date'"
|
||||
recs = await sor.sqlExe(sql, {})
|
||||
if len(recs) > 0:
|
||||
return recs[0]['params_value']
|
||||
raise Exception('BusinessDateParamsError')
|
||||
|
||||
if sor:
|
||||
return await _f(sor)
|
||||
db = DBPools()
|
||||
dbname = get_dbname()
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
return await _f(sor)
|
||||
|
||||
async def new_business_date(sor=None):
|
||||
async def _f(sor):
|
||||
dat = await get_business_date(sor)
|
||||
new_dat = strdate_add(dat, days=1)
|
||||
sql = "update params set params_value=${new_dat}$ where params_name='business_date'"
|
||||
await sor.sqlExe(sql, {'new_dat':new_dat})
|
||||
|
||||
if sor:
|
||||
return await _f(sor)
|
||||
db = DBPools()
|
||||
dbname = get_dbname()
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
return await _f(sor)
|
||||
|
||||
async def previous_business_date(sor=None):
|
||||
dat = await get_business_date(sor=sor)
|
||||
return strdate_add(dat, days=-1)
|
||||
|
||||
async def next_business_date(sor=None):
|
||||
dat = await get_business_date(sor=sor)
|
||||
return strdate_add(dat, days=1)
|
||||
|
||||
7
appbase/init.py
Normal file
7
appbase/init.py
Normal file
@ -0,0 +1,7 @@
|
||||
from appbase.businessdate import get_business_date, new_business_date
|
||||
from ahserver.serverenv import ServerEnv
|
||||
|
||||
def load_appbase():
|
||||
g = ServerEnv()
|
||||
g.get_business_date = get_business_date
|
||||
g.new_business_date = new_business_date
|
||||
6
appbase/params.py
Normal file
6
appbase/params.py
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
async def _get_params(sor, name):
|
||||
ps = await sor.R('params', {'params_name': name})
|
||||
if len(ps) > 0:
|
||||
return ps[0].params_value
|
||||
|
||||
1
appbase/version.py
Normal file
1
appbase/version.py
Normal file
@ -0,0 +1 @@
|
||||
__version__ = '0.0.1'
|
||||
22
json/appcodes.json
Normal file
22
json/appcodes.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"tblname":"appcodes",
|
||||
"title":"代码管理",
|
||||
"params":{
|
||||
"sortby":"id",
|
||||
"browserfields":{
|
||||
"exclouded":[],
|
||||
"alters":{}
|
||||
},
|
||||
"editexclouded":[],
|
||||
"subtables":[
|
||||
{
|
||||
"title":"代码键值管理",
|
||||
"subtable":"appcodes_kv",
|
||||
"params":{
|
||||
"hierarchy_flg":"${hierarchy_flg}"
|
||||
},
|
||||
"field":"parentid"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
24
json/appcodes_kv.json
Normal file
24
json/appcodes_kv.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"tblname":"appcodes_kv",
|
||||
"title":"代码键值管理",
|
||||
"params":{
|
||||
"sortby":["k", "v"],
|
||||
"browserfields":{
|
||||
"exclouded":["id", "parentid" ],
|
||||
"alters":{}
|
||||
},
|
||||
"editexclouded":["id", "parentid" ],
|
||||
"subtables_condition":" params_kw.hierarchy_flg == '1' ",
|
||||
"subtables":[
|
||||
{
|
||||
"title":"代码键值管理",
|
||||
"params":{
|
||||
"hierarchy_flg":"{{params_kw.hierarchy_flg}}",
|
||||
"parentid":"${id}"
|
||||
},
|
||||
"subtable":"appcodes_kv",
|
||||
"field":"parentid"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
3
json/build.sh
Executable file
3
json/build.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
xls2ui -m ../models -o ../wwwroot appbase *.json
|
||||
39
json/params.json
Normal file
39
json/params.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"tblname":"params",
|
||||
"params":{
|
||||
"title":"参数",
|
||||
"description":"系统参数,可以动态增加修改参数",
|
||||
"sortby":"params_name",
|
||||
"toolbar":{
|
||||
"tools":[
|
||||
{
|
||||
"name":"switch",
|
||||
"icon":"newdate.png",
|
||||
"selected_row": true,
|
||||
"label":"切日"
|
||||
}
|
||||
]
|
||||
},
|
||||
"browserfields":{
|
||||
"exclouded":["id"],
|
||||
"alters":{}
|
||||
},
|
||||
"binds":[
|
||||
{
|
||||
"wid":"self",
|
||||
"event":"row_selected",
|
||||
"actiontype":"script",
|
||||
"target":"self",
|
||||
"script":"console.log('test', params);"
|
||||
},
|
||||
{
|
||||
"wid":"self",
|
||||
"event":"switch",
|
||||
"actiontype":"script",
|
||||
"target":"self",
|
||||
"script":"console.log('swith event', params);"
|
||||
}
|
||||
],
|
||||
"editexclouded":["id"]
|
||||
}
|
||||
}
|
||||
BIN
models/appcodes.xlsx
Normal file
BIN
models/appcodes.xlsx
Normal file
Binary file not shown.
BIN
models/appcodes_kv.xlsx
Normal file
BIN
models/appcodes_kv.xlsx
Normal file
Binary file not shown.
BIN
models/params.xlsx
Normal file
BIN
models/params.xlsx
Normal file
Binary file not shown.
0
requirements.txt
Normal file
0
requirements.txt
Normal file
52
setup.py
Executable file
52
setup.py
Executable file
@ -0,0 +1,52 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from appbase.version import __version__
|
||||
try:
|
||||
from setuptools import setup
|
||||
except ImportError:
|
||||
from distutils.core import setup
|
||||
required = []
|
||||
with open('requirements.txt', 'r') as f:
|
||||
ls = f.read()
|
||||
required = ls.split('\n')
|
||||
|
||||
with open('appbase/version.py', 'r') as f:
|
||||
x = f.read()
|
||||
y = x[x.index("'")+1:]
|
||||
z = y[:y.index("'")]
|
||||
version = z
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
name = "appbase"
|
||||
description = "appbase"
|
||||
author = "yumoqing"
|
||||
email = "yumoqing@gmail.com"
|
||||
|
||||
package_data = {}
|
||||
|
||||
setup(
|
||||
name="appbase",
|
||||
version=version,
|
||||
|
||||
# uncomment the following lines if you fill them out in release.py
|
||||
description=description,
|
||||
author=author,
|
||||
author_email=email,
|
||||
platforms='any',
|
||||
install_requires=required ,
|
||||
packages=[
|
||||
"appbase"
|
||||
],
|
||||
package_data=package_data,
|
||||
keywords = [
|
||||
],
|
||||
url="https://github.com/yumoqing/appbase",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
classifiers = [
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 3',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
],
|
||||
)
|
||||
16
wwwroot/get_appcodes_kv.dspy
Normal file
16
wwwroot/get_appcodes_kv.dspy
Normal file
@ -0,0 +1,16 @@
|
||||
debug(params_kw)
|
||||
ns = params_kw.copy()
|
||||
|
||||
db = DBPools()
|
||||
sql = f"""select id, k as {params_kw.valueField},
|
||||
v as {params_kw.textField}
|
||||
from appcodes_kv where 1=1 """
|
||||
if params_kw.cond:
|
||||
sql += f" and {params_kw.cond} "
|
||||
|
||||
sql += f"order by {params_kw.textField}"
|
||||
|
||||
async with db.sqlorContext(params_kw.dbname) as sor:
|
||||
rs = await sor.sqlExe(sql, ns)
|
||||
return rs
|
||||
return []
|
||||
27
wwwroot/get_code.dspy
Normal file
27
wwwroot/get_code.dspy
Normal file
@ -0,0 +1,27 @@
|
||||
debug(params_kw)
|
||||
ns = params_kw.copy()
|
||||
|
||||
db = DBPools()
|
||||
sql = f"""select {params_kw.tblvalue} as {params_kw.valueField},
|
||||
{params_kw.tbltext} as {params_kw.textField}
|
||||
from {params_kw.table} where 1=1 """
|
||||
if params_kw.cond:
|
||||
sql += f" and {params_kw.cond} "
|
||||
|
||||
sql += f"order by {params_kw.textField}"
|
||||
|
||||
ac = ArgsConvert('[[', ']]')
|
||||
vars = ac.findAllVariables(sql)
|
||||
if 'userid' in vars:
|
||||
ns['userid'] = await get_user()
|
||||
if 'userorgid' in vars:
|
||||
ns['userorgid'] = await get_userorgid()
|
||||
|
||||
NameSpace = {v:'${' + v + '}$' for v in vars}
|
||||
sql = ac.convert(sql, NameSpace)
|
||||
debug(f'/appbase/get_code.dspy: {sql=}')
|
||||
|
||||
async with db.sqlorContext(params_kw.dbname) as sor:
|
||||
rs = await sor.sqlExe(sql, ns)
|
||||
return rs
|
||||
return []
|
||||
17
wwwroot/menu.ui
Normal file
17
wwwroot/menu.ui
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"name":"codemgr",
|
||||
"label":"代码管理",
|
||||
"url":"{{entire_url('/appbase/appcodes')}}"
|
||||
},
|
||||
{
|
||||
"name":"params",
|
||||
"label":"参数管理",
|
||||
"url":"{{entire_url('/appbase/params')}}"
|
||||
},
|
||||
{
|
||||
"name":"jsonhttpapi",
|
||||
"label":"json应用接口",
|
||||
"url":"{{entire_url('/appbase/jsonhttpapi')}}"
|
||||
}
|
||||
]
|
||||
Loading…
x
Reference in New Issue
Block a user