def query_condition_acc1(num): datas = [] for i in num: datas.append( commons.all_to_dict( session.query(class_infomodel.StudentGroup).filter( class_infomodel.StudentGroup.num == i).all())) return datas
def query_condition_acc(num): datas = [] for i in num: datas.append( commons.all_to_dict( session.query(infomodel.BBsModel).filter( infomodel.BBsModel.num == i).all())) return datas
def query_condition_opa(): datas = commons.all_to_dict( session.query(infomodel.BBsModel).filter( infomodel.BBsModel.name.like("黄%")).all()) lis = [] for i in datas: if len(i['name']) == 2: lis.append(i) return lis
def get_bbs(cls, **kwargs): # 获得查询参数 name = kwargs.get('name') id = kwargs.get('id') page = int(kwargs.get('page', 1)) size = int(kwargs.get('size', 10)) filter_list = [] # 过滤为空的条件 if name: filter_list.append(cls.name == name) if id: filter_list.append(cls.id == id) # filter_list.append(or_(cls.username == username, cls.content == content)) try: bbs_model = session.query(cls).filter(*filter_list) # 计算应该返回的数据 res = bbs_model.limit(size).offset((page - 1) * size).all() if not res: return {'code': RET.NODATA, 'message': '无数据', 'error': '无数据'} if not res: return {'code': RET.NODATA, 'message': '无数据', 'error': '无数据'} except Exception as e: return { 'code': RET.DBERR, 'message': '数据库异常,查询失败', 'error': str(e) } return { 'code': RET.OK, 'message': 'OK', 'data': commons.all_to_dict(res) }
def query_condition_gen(gender): return commons.all_to_dict( session.query(infomodel.BBsModel).filter( infomodel.BBsModel.gender == gender).all())
def query_condition_notdel(): return commons.all_to_dict( session.query(infomodel.BBsModel).filter( infomodel.BBsModel.isdeleted == 0).all())