You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
862 B
Python

from sqlalchemy import delete
from app.core.base_crud import CRUDBase
from app.core.base_schema import AuthSchema
from app.core.exceptions import CustomException
from .model import EnergyReportVariableModel
class VariableCRUD(CRUDBase[EnergyReportVariableModel, dict, dict]):
"""能源报告变量关联数据层。"""
def __init__(self, auth: AuthSchema) -> None:
super().__init__(model=EnergyReportVariableModel, auth=auth)
async def hard_delete(self, ids: list[int]) -> None:
try:
pk = self._get_pk_col()
sql = self._tenant_dml_where(delete(self.model).where(pk.in_(ids)))
await self.db.execute(sql)
await self.db.flush()
except CustomException:
raise
except Exception as e:
raise CustomException(msg=f"删除变量关联失败: {e!s}")