This commit is contained in:
yumoqing 2025-07-30 11:04:16 +08:00
parent ac94d76bcd
commit 33e47f232f
3 changed files with 17 additions and 11 deletions

View File

@ -75,16 +75,18 @@ where id=${folderid}$"""
return True
return False
async def get_subfolder(self, request, fid, fiid):
async def get_subs(self, request, params):
id = params.id
userinfo = await get_session_userinfo(request)
dbname = get_dbname()
db = DBPools()
async with db.sqlorContext(dbname) as sor:
return await self.sor_get_subfolder(sor, request, fid, fiid)
return await self.sor_get_subfile(sor, request, fid, fiid)
ret = await self.sor_get_subfolder(sor, request, fid)
ret += await self.sor_get_subfile(sor, request, fid)
return ret
return []
async def sor_get_subfolder(self, sor, request, fid, fiid):
async def sor_get_subfolder(self, sor, request, fid):
sql = """select x.*, 'folder' as filetype,
case when y.id is null then 1
else 0 end as is_left
@ -96,21 +98,19 @@ where b.id is not null or c.id is n
ot null;
) as y
on x.id = y.id
where x.parentid = ${fid}$ and fiid=${fiid}$
where x.parentid = ${fid}$
"""
ns = {
'fid':fid,
'fiid':fiid
'fid':fid
}
recs = await sor.sqlExe(sql, ns)
return recs
async def sor_get_subfile(self, sor, request, fid, fiid):
async def sor_get_subfile(self, sor, request, fid):
userinfo = await get_session_userinfo(request)
sql = """select a.*, 1 as is_leaf from file where folderid=${fid}$ and fiid=${fiid}"""
sql = """select a.*, 1 as is_leaf from file where folderid=${fid}$"""
ns = {
'fid':fid,
'fiid':fiid
'fid':fid
}
recs = await sor.sqlExe(sql, ns)
return recs

View File

@ -11,6 +11,7 @@
"alter":{}
},
"edit_exclouded_fields":["id", "fiid" ],
"get_data_url":"{{entire_url('/filemgr/get_folder_subs.dspy",
"params":{
"id":"{{params_kw.id or '' }}"
},

View File

@ -0,0 +1,5 @@
#
debug(f'{params_kw=}')
filemgr = FileMgr()
f = await filemgr.get_subs(request, params_kw)
return f