提交现有代码

This commit is contained in:
2026-06-21 17:13:18 +08:00
commit a42c074c16
26 changed files with 5449 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
from models import Product, Session
import uuid
class ProductManager:
def __init__(self, parent=None):
super().__init__()
def create(self, info):
data = {
"id": str(uuid.uuid4()),
"info": info
}
ok, res = Session.addByClass(Product, data)
if ok:
return str(res["id"])
return ""
def update(self, id, info):
data = {"info": info}
ok,res = Session.updateById(Product, id, data)
return ok
def delete(self, id):
if isinstance(id, str):
ok,res = Session.deleteById(Product, id)
return ok
else:
ok,res = Session.deleteByIds(Product, id)
return ok
def getInfos(self, ids):
ok,res = Session.queryByIds(Product, ids)
if ok:
return res
else:
return []
def getInfo(self, id = "all"):
if id == "all":
ok,res = Session.queryByAll(Product)
if ok:
return res
else:
return []
else:
ok,res = Session.queryById(Product, id)
if ok:
return res
else:
return None
productManager = ProductManager()