122 lines
2.6 KiB
Plaintext
122 lines
2.6 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
|
|
|
|
debug(f'get_dda_approval_configs.dspy:{ns=}')
|
|
if not ns.get('page'):
|
|
ns['page'] = 1
|
|
if not ns.get('sort'):
|
|
|
|
|
|
ns['sort'] = ["biz_type"]
|
|
|
|
|
|
|
|
sql = '''select * from dda_approval_configs where 1=1 [[filterstr]]'''
|
|
|
|
filterjson = params_kw.get('data_filter')
|
|
if filterjson and isinstance(filterjson, str):
|
|
try:
|
|
filterjson = json.loads(filterjson)
|
|
except (json.JSONDecodeError, TypeError):
|
|
filterjson = None
|
|
fields_str=r'''[
|
|
{
|
|
"name": "id",
|
|
"title": "主键ID",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "org_id",
|
|
"title": "组织ID",
|
|
"type": "str",
|
|
"length": 32,
|
|
"default": "0"
|
|
},
|
|
{
|
|
"name": "biz_type",
|
|
"title": "业务类型",
|
|
"type": "str",
|
|
"length": 32,
|
|
"nullable": "no"
|
|
},
|
|
{
|
|
"name": "biz_type_title",
|
|
"title": "业务类型名称",
|
|
"type": "str",
|
|
"length": 100
|
|
},
|
|
{
|
|
"name": "process_code",
|
|
"title": "钉钉审批模板编码",
|
|
"type": "str",
|
|
"length": 100
|
|
},
|
|
{
|
|
"name": "agent_id",
|
|
"title": "钉钉应用AgentId",
|
|
"type": "str",
|
|
"length": 100
|
|
},
|
|
{
|
|
"name": "form_config",
|
|
"title": "表单字段配置JSON",
|
|
"type": "text"
|
|
},
|
|
{
|
|
"name": "approvers_config",
|
|
"title": "审批节点链JSON",
|
|
"type": "text"
|
|
},
|
|
{
|
|
"name": "is_active",
|
|
"title": "是否启用(1/0)",
|
|
"type": "str",
|
|
"length": 1,
|
|
"default": "1"
|
|
},
|
|
{
|
|
"name": "created_at",
|
|
"title": "创建时间",
|
|
"type": "timestamp"
|
|
},
|
|
{
|
|
"name": "updated_at",
|
|
"title": "更新时间",
|
|
"type": "timestamp"
|
|
}
|
|
]'''
|
|
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=}')
|
|
db = DBPools()
|
|
dbname = get_module_dbname('dingdingflow')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
r = await sor.sqlPaging(sql, ns)
|
|
return r
|
|
return {
|
|
"total":0,
|
|
"rows":[]
|
|
} |