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.
17 lines
805 B
17 lines
805 B
from sqlalchemy import or_
|
|
from models.entity import *
|
|
|
|
from statusCode.responseEntity import SuccessResponse, BadResponse
|
|
from statusCode.resultCode import ResultCode
|
|
|
|
|
|
def get_entry_list(entity, data):
|
|
entityFilter = db.session.query(entity).group_by(entity).distinct()
|
|
if data.get('query') is not None:
|
|
entityFilter = db.session.query(entity).filter(entity.contains(data.get('query'))).distinct()
|
|
entityPaginate = entityFilter.order_by(entity.desc()).paginate(
|
|
int(data.get('pageNumber')), 10,
|
|
error_out=False)
|
|
resultList = [dict(zip(result.keys(), result)) for result in entityPaginate.items]
|
|
return SuccessResponse(ResultCode.SUCCESS, {'totalNumber': entityFilter.count(),
|
|
'list': resultList}, None)
|
|
|