feat: complete huihui square avatar workflows

This commit is contained in:
stefanfeng
2026-07-24 14:04:21 +08:00
parent 2ef58a44b8
commit e3bda469bb
68 changed files with 8062 additions and 132 deletions

View File

@@ -0,0 +1,35 @@
from fastapi import APIRouter, Depends, Body
from sqlalchemy.orm import Session
from database import get_db
from models import Organization
from responses import ok, fail
router = APIRouter(tags=["组织"])
@router.get("/organizations")
def list_orgs(page: int = 1, limit: int = 20, db: Session = Depends(get_db)):
q = db.query(Organization)
total = q.count()
items = (
q.order_by(Organization.created_at.desc())
.offset((page - 1) * limit)
.limit(limit)
.all()
)
return ok({"data": [o.to_dict() for o in items], "total": total})
@router.post("/organizations")
def create_org(payload: dict = Body(...), db: Session = Depends(get_db)):
o = Organization(
name=payload.get("name", "未命名组织"),
description=payload.get("desc", "") or payload.get("description", ""),
emoji=payload.get("emoji", "🏢"),
org_type=payload.get("type", "") or payload.get("orgType", "team"),
)
db.add(o)
db.commit()
db.refresh(o)
return ok(o.to_dict())