update
This commit is contained in:
parent
c86bf3b9a3
commit
36450d0d6f
@ -100,7 +100,7 @@ async def delete_category(
|
||||
return StandardResponse(code=200, data=db_category)
|
||||
|
||||
# 衣服API
|
||||
@router.post("/", tags=["clothing"])
|
||||
@router.post("", tags=["clothing"])
|
||||
async def create_clothing(
|
||||
clothing: ClothingCreate,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
@ -121,7 +121,7 @@ async def create_clothing(
|
||||
# 手动返回标准响应格式
|
||||
return StandardResponse(code=200, data=result)
|
||||
|
||||
@router.get("/", tags=["clothing"])
|
||||
@router.get("", tags=["clothing"])
|
||||
async def read_clothes(
|
||||
skip: int = Query(0, ge=0),
|
||||
limit: int = Query(100, ge=1, le=100),
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
from app.db.database import Base
|
||||
|
||||
@ -10,4 +11,7 @@ class PersonImage(Base):
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
||||
image_url = Column(String(255), nullable=False)
|
||||
is_default = Column(Boolean, default=False)
|
||||
create_time = Column(DateTime(timezone=True), server_default=func.now())
|
||||
create_time = Column(DateTime, default=func.now(), comment="创建时间")
|
||||
|
||||
# 关系
|
||||
user = relationship("User", back_populates="person_images")
|
||||
@ -4,6 +4,7 @@ from sqlalchemy.orm import relationship
|
||||
from app.db.database import Base
|
||||
|
||||
class User(Base):
|
||||
"""用户数据模型"""
|
||||
__tablename__ = "users"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True, index=True)
|
||||
@ -14,7 +15,7 @@ class User(Base):
|
||||
create_time = Column(DateTime, default=func.now(), comment="创建时间")
|
||||
|
||||
# 关系
|
||||
images = relationship("UserImage", back_populates="user", cascade="all, delete-orphan")
|
||||
person_images = relationship("PersonImage", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<User(id={self.id}, nickname={self.nickname})>"
|
||||
@ -1,6 +1,6 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.future import select
|
||||
from sqlalchemy import update, delete
|
||||
from sqlalchemy import update, delete, func
|
||||
from typing import List, Optional
|
||||
|
||||
from app.models.clothing import Clothing, ClothingCategory
|
||||
|
||||
@ -6,7 +6,7 @@ from dashscope import Generation
|
||||
from typing import List, Dict, Any, Optional
|
||||
import asyncio
|
||||
import httpx
|
||||
from app.utils.config import get_settings
|
||||
from app.core.config import settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -14,8 +14,7 @@ class DashScopeService:
|
||||
"""DashScope服务类,提供对DashScope API的调用封装"""
|
||||
|
||||
def __init__(self):
|
||||
settings = get_settings()
|
||||
self.api_key = settings.dashscope_api_key
|
||||
self.api_key = settings.DASHSCOPE_API_KEY
|
||||
# 配置DashScope
|
||||
dashscope.api_key = self.api_key
|
||||
# 配置API URL
|
||||
|
||||
Loading…
Reference in New Issue
Block a user