cm-wisdom-cube/backend/app/utils/common_util.py
2025-03-14 16:57:26 +08:00

32 lines
776 B
Python

class Success:
def __init__(self, msg: str):
self.code = 0
self.status = "success"
self.msg = msg
class SuccessData:
def __init__(self, data: any):
self.code = 0
self.status = "success"
self.data = data
class SuccessListPage:
def __init__(self, page: int, total: int, total_page: int, data_list: list):
self.code = 0
self.status = "success"
self.page = page
self.total = total
self.total_page = total_page
self.data_list = data_list
# 获取页数
def get_total_page(total: int, page_size: int):
return total / page_size if total % page_size == 0 else int(total / page_size) + 1
def get_offset(page: int, page_size: int):
return (page - 1) * page_size