This commit is contained in:
ymq1 2025-06-28 16:30:10 +08:00
parent a3168d6524
commit 22a028d599

View File

@ -17,22 +17,28 @@ class FileMgr:
async def get_bizinfo_nodes(self, request): async def get_bizinfo_nodes(self, request):
db = DBPools() db = DBPools()
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
return await self.sor_get_bizinfo_nodes(sor, request)
return []
async def sor_get_bizinfo_nodes(self, sor, request):
userinfo = await get_session_userinfo(request)
ns = { ns = {
'orgid':usrinfo.userorgid, 'orgid':usrinfo.userorgid,
'biztype':self.biztype 'biztype':self.biztype
} }
recs = await sor.R('folderinfo', ns) recs = await sor.R('folderinfo', ns)
return recs return recs
return []
async def add_bizinfo_node(self, request, ns): async def add_bizinfo_node(self, request, ns):
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
return await self.sor_add_bizinfo_node(sor,request, ns)
return False
async def sor_add_bizinfo_node(self, sor, request, ns):
userinfo = await get_session_userinfo(request)
ns['orgid'] = userinfo.userorgid, ns['orgid'] = userinfo.userorgid,
ns['biztype'] = self.biztype ns['biztype'] = self.biztype
ns['id'] = getID() ns['id'] = getID()
@ -40,25 +46,31 @@ class FileMgr:
# ns['max_size'] = await get_params(sor, userinfo.userid, 'folder_max_size'); # ns['max_size'] = await get_params(sor, userinfo.userid, 'folder_max_size');
await sor.C('folderinfo', ns) await sor.C('folderinfo', ns)
return True return True
return False
async def delete_bizinfo_node(self, request, ns): async def delete_bizinfo_node(self, request, ns):
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
return await self.sor_delete_bizinfo_node(self, sor, request, ns)
return False
async def sor_delete_bizinfo_node(self, sor, request, ns):
userinfo = await get_session_userinfo(request)
ns1['orgid'] = userinfo.userorgid, ns1['orgid'] = userinfo.userorgid,
ns1['biztype'] = self.biztype ns1['biztype'] = self.biztype
ns1['id'] = ns['id'] ns1['id'] = ns['id']
await sor.D('folderinfo', ns1) await sor.D('folderinfo', ns1)
return True return True
return False
async def update_bizinfo_node(self, request, ns): async def update_bizinfo_node(self, request, ns):
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
return self.sor_update_bizinfo_node(sor, request, ns)
return False
async def sor_update_bizinfo_node(self, sor, request, ns):
userinfo = await get_session_userinfo(request)
ns1['orgid'] = userinfo.userorgid, ns1['orgid'] = userinfo.userorgid,
ns1['biztype'] = self.biztype ns1['biztype'] = self.biztype
ns1['id'] = ns['id'] ns1['id'] = ns['id']
@ -69,30 +81,44 @@ class FileMgr:
return False return False
async def add_folder(self, request, ns): async def add_folder(self, request, ns):
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
return await self.sor_add_folder(sor, request, ns)
return False
async def sor_add_folder(self, sor, request, ns):
userinfo = await get_session_userinfo(request)
ns1['orgid'] = userinfo.userorgid, ns1['orgid'] = userinfo.userorgid,
ns1['biztype'] = self.biztype ns1['biztype'] = self.biztype
ns1['id'] = ns['id'] ns1['id'] = ns['id']
await sor.C('folderinfo', ns1) await sor.C('folderinfo', ns1)
return True return True
return False
async def get_subfolder(self, request, fid, fiid): async def get_subfolder(self, request, fid, fiid):
userinfo = await get_session_userinfo(request) userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
sql = """select a.id as fiid, b.* return await self.sor_get_subfolder(sor, request, fid, fiid)
return []
async def sor_get_subfolder(self, sor, request, fid, fiid):
sql = """select x.*, 'folder' as rtype,
case when y.id is null then 1
else 0 end as is_left
from (select a.id as fiid, b.*
from folderinfo a, folder b from folderinfo a, folder b
where a.id = ${fiid}$ where a.id = ${fiid}$
and b.fiid = a.id and b.fiid = a.id
and b.parentid = ${fid}$ and b.parentid = ${fid}$
and a.orgid = ${orgid}$ and a.orgid = ${orgid}$
and a.biztype = ${biztype}$ and a.biztype = ${biztype}$
order by name""" order by name) as x left join (
select unique a.* from folder a left join folder b on a.id = b.par
entid where b.id is not NULL
) as y
on x.id = y.id
"""
ns = { ns = {
'fid':fid, 'fid':fid,
'fiid':fiid, 'fiid':fiid,
@ -101,14 +127,16 @@ order by name"""
} }
recs = await sor.sqlExe(sql, ns) recs = await sor.sqlExe(sql, ns)
return recs return recs
await sor.D('folderinfo', ns1)
return []
async def get_files(self, request, fid, fiid): async def get_files(self, request, fid, fiid):
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
return await self.sor_get_files(sor, request, fid, fiid)
return []
async def sor_get_files(self, sor, request, fid, fiid):
userinfo = await get_session_userinfo(request)
sql = """select a.id as fiid, b.* sql = """select a.id as fiid, b.*
from folderinfo a, file b from folderinfo a, file b
where a.id = ${fiid}$ where a.id = ${fiid}$
@ -126,9 +154,16 @@ order by name"""
} }
recs = await sor.sqlExe(sql, ns) recs = await sor.sqlExe(sql, ns)
return recs return recs
async def get_folderinfo(self, sor, fiid):
dbname = get_dbname()
db = DBPools()
async with db.sqlorContext(dbname) as sor:
return await self.sor_get_folderinfo(sor, request, fid, fiid)
return [] return []
async def get_folderinfo(self, sor, userinfo, fiid): async def sor_get_folderinfo(self, sor, fiid):
userinfo = await get_session_userinfo(request)
sql = """select * from folderinfo sql = """select * from folderinfo
where id = ${fiid}$ where id = ${fiid}$
and orgid = ${orgid}$ and orgid = ${orgid}$
@ -143,24 +178,15 @@ where id = ${fiid}$
return recs return recs
return None return None
async def add_folder(self, request, ns): async def delete_file(self, request, fid, fiid):
userinfo = await get_session_userinfo(request)
dbname = get_dbname() dbname = get_dbname()
db = DBPools() db = DBPools()
async with db.sqlorContext(dbname) as sor: async with db.sqlorContext(dbname) as sor:
sql = """select * from folder""" return await self.sor_delete_file(self, sor, request, fid, fiid)
ns1['orgid'] = userinfo.userorgid,
ns1['biztype'] = self.biztype
ns1['id'] = ns['id']
await sor.C('folderinfo', ns1)
return True
return False return False
async def delete_file(self, request, fid, fiid): async def sor_delete_file(self, sor, request, fid, fiid):
userinfo = await get_session_userinfo(request) userinfo = await get_session_userinfo(request)
dbname = get_dbname()
db = DBPools()
async with db.sqlorContext(dbname) as sor:
sql = """select a.id as fiid, b.* sql = """select a.id as fiid, b.*
from folderinfo a, file b from folderinfo a, file b
where a.id = ${fiid}$ where a.id = ${fiid}$