from typing import List from sqlalchemy import desc, delete, func, select, update from sqlalchemy.ext.asyncio import AsyncSession from module_admin.entity.vo.user_vo import CurrentUserModel from module_admin.entity.vo.dataint_vo import FccbdPageObject from module_admin.entity.do.dataint_do import SysFccbd from sqlalchemy import select, text, cast, Integer, and_, or_, outerjoin, func, join from utils.page_util import PageUtil class FccbdDao: """ 菜单管理模块数据库操作层 """ @classmethod async def get_fccbd_list(cls, db: AsyncSession, fccbd_query: FccbdPageObject): query = ( select(SysFccbd).where( SysFccbd.pos == fccbd_query.pos if fccbd_query.pos else True, SysFccbd.pos_name == fccbd_query.pos_name if fccbd_query.pos_name else True, SysFccbd.term == fccbd_query.term if fccbd_query.term else True, SysFccbd.status == fccbd_query.status if fccbd_query.status else True ).distinct() ) query_result = await PageUtil.paginate(db, query, fccbd_query.page_num, fccbd_query.page_size, True) return query_result @classmethod async def insert_fccbd(cls, db: AsyncSession, sysFccbd: SysFccbd): db.add(sysFccbd) await db.flush() return sysFccbd @classmethod async def get_fccbd_by_id(cls, db: AsyncSession, onum: str): result = ( ( await db.execute( select(SysFccbd).where(SysFccbd.onum == onum).distinct() ) ).scalars().first() ) return result @classmethod async def update_fccbd(cls, db: AsyncSession, saveObj: dict): await db.execute(update(SysFccbd), [saveObj]) @classmethod async def delete_fccbd(cls, db: AsyncSession, array: List[str]): await db.execute(delete(SysFccbd).where(SysFccbd.onum.in_(array)))