69 lines
1.5 KiB
Plaintext
69 lines
1.5 KiB
Plaintext
|
|
ns = params_kw.copy()
|
|
|
|
|
|
debug(f'get_role.dspy:{ns=}')
|
|
if not ns.get('page'):
|
|
ns['page'] = 1
|
|
if not ns.get('sort'):
|
|
|
|
|
|
ns['sort'] = ["orgtypeid","name"]
|
|
|
|
|
|
|
|
sql = '''select a.*, b.orgtypeid_text
|
|
from (select * from role where 1=1 [[filterstr]]) a left join (select k as orgtypeid,
|
|
v as orgtypeid_text from appcodes_kv where parentid='org_type') b on a.orgtypeid = b.orgtypeid'''
|
|
|
|
filterjson = params_kw.get('data_filter')
|
|
if not filterjson:
|
|
fields = [ f['name'] for f in [
|
|
{
|
|
"name": "id",
|
|
"title": "角色id",
|
|
"type": "str",
|
|
"length": 32
|
|
},
|
|
{
|
|
"name": "orgtypeid",
|
|
"title": "机构类型",
|
|
"type": "str",
|
|
"length": 32,
|
|
"default": "0"
|
|
},
|
|
{
|
|
"name": "name",
|
|
"title": "角色名称",
|
|
"type": "str",
|
|
"length": 100
|
|
}
|
|
] ]
|
|
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('rbac')
|
|
async with db.sqlorContext(dbname) as sor:
|
|
r = await sor.sqlPaging(sql, ns)
|
|
return r
|
|
return {
|
|
"total":0,
|
|
"rows":[]
|
|
} |