修改部分问题
This commit is contained in:
@ -44,7 +44,7 @@ def get_img_url(image_id: int, session: Session):
|
||||
|
||||
def get_image_list(project_id: int, session: Session):
|
||||
query = session.query(piModel).filter(piModel.project_id == project_id).order_by(asc(piModel.id))
|
||||
image_list = [ProjectImage.from_orm(image).dict() for image in query.all()]
|
||||
image_list = [ProjectImage.from_orm(image) for image in query.all()]
|
||||
return image_list
|
||||
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
|
||||
@ -8,10 +7,13 @@ class ProjectImage(BaseModel):
|
||||
id: Optional[int] = Field(None, description="id")
|
||||
project_id: Optional[int] = Field(..., description="项目id")
|
||||
file_name: Optional[str] = Field(None, description="文件名称")
|
||||
create_time: Optional[datetime.datetime] = Field(None, description="上传时间")
|
||||
create_time: Optional[datetime] = Field(None, description="上传时间")
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.strftime("%Y-%m-%d %H:%M:%S")
|
||||
}
|
||||
|
||||
|
||||
class ProjectImagePager(BaseModel):
|
||||
|
Reference in New Issue
Block a user