dingdanquanliucheng/backend/app/services/product_service.py
2026-05-14 13:51:06 +08:00

68 lines
1.9 KiB
Python

class ProductService:
def list_categories(self) -> dict:
return {
"total": 2,
"page_no": 1,
"page_size": 20,
"list": [
{"category_id": 1, "category_name": "工业品", "category_code": "industry", "status": 1},
{"category_id": 2, "category_name": "日用品", "category_code": "daily", "status": 1},
],
}
def create_category(self) -> dict:
return {
"category_id": 3,
"category_name": "新分类",
"category_code": "new-category",
"status": 1,
}
def update_category(self, category_id: int) -> dict:
return {"category_id": category_id, "updated": True}
def list_products(self) -> dict:
return {
"total": 1,
"page_no": 1,
"page_size": 20,
"list": [
{
"product_id": 2001,
"product_name": "产品A",
"specification": "10kg",
"unit": "",
"category_id": 1,
"category_name": "工业品",
"cost_price": 60,
"sale_price": 100,
"status": 1,
}
],
}
def create_product(self) -> dict:
return {
"product_id": 2002,
"product_name": "产品B",
"specification": "20kg",
"unit": "",
"status": 1,
}
def get_product(self, product_id: int) -> dict:
return {
"product_id": product_id,
"product_name": "产品A",
"specification": "10kg",
"unit": "",
"category_id": 1,
"category_name": "工业品",
"cost_price": 60,
"sale_price": 100,
"status": 1,
}
product_service = ProductService()