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

33 lines
1.4 KiB

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Date:2022/07/13 17:07:42
'''
import threading
from sqlalchemy import or_, desc
from DataEntity.WarningModels import EntityWarning
from Business.Repository import Repository
# 功能模块
class BllWarning(Repository):
_instance_lock = threading.Lock()
# #实现单例模式
# def __new__(cls, *args, **kwargs):
# if not hasattr(BllWarning, "_instance"):
# with BllWarning._instance_lock:
# if not hasattr(BllWarning, "_instance"):
# BllWarning._instance = object.__new__(cls)
# return BllWarning._instance
def __init__(self, entityType=EntityWarning):
return super().__init__(entityType)
# 定义通过搜索预警对象进行模糊查询
def like_warning_list(self, searchValue, page, limi):
if len(str(page)) == 0 and len(str(limi)) == 0:
return self.findList(or_(EntityWarning.object_name.like('%' + searchValue + '%'), EntityWarning.warning_content.like('%' + searchValue + '%'))).order_by(desc(EntityWarning.warning_date), desc(EntityWarning.is_solve)).all()
return self.findList(or_(EntityWarning.object_name.like('%' + searchValue + '%'), EntityWarning.warning_content.like('%' + searchValue + '%'))).order_by(desc(EntityWarning.warning_date), desc(EntityWarning.is_solve)).offset((page-1)*limi).limit(limi).all()