contact actions
This commit is contained in:
@@ -63,6 +63,25 @@ class ProductsContacts(db.Model):
|
||||
raise ValueError(f"Database integrity error: {err}")
|
||||
return product_contact_data
|
||||
|
||||
@classmethod
|
||||
def get_all_contacts(cls,member_id, page=1, limit=20):
|
||||
|
||||
query = cls.query
|
||||
logger.info(f"Get all customer back")
|
||||
|
||||
query = query.filter(cls.member_id == member_id)
|
||||
|
||||
# Order by created_at descending (newest first)
|
||||
query = query.order_by(cls.added.desc())
|
||||
|
||||
# Get total count before pagination
|
||||
total_count = query.count()
|
||||
|
||||
# Apply pagination
|
||||
offset = (page - 1) * limit
|
||||
query = query.limit(limit).offset(offset)
|
||||
|
||||
return query.all(), total_count
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
|
||||
Reference in New Issue
Block a user