fix error
This commit is contained in:
@@ -141,7 +141,6 @@ class ScoreBase(AsyncAttrs, SQLModel, UTCBaseModel):
|
|||||||
if hasattr(v, 'value'):
|
if hasattr(v, 'value'):
|
||||||
return v.value
|
return v.value
|
||||||
return str(v)
|
return str(v)
|
||||||
return v
|
|
||||||
|
|
||||||
# optional
|
# optional
|
||||||
# TODO: current_user_attributes
|
# TODO: current_user_attributes
|
||||||
@@ -276,7 +275,7 @@ class ScoreResp(ScoreBase):
|
|||||||
return converted
|
return converted
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_serializer("statistics", "maximum_statistics", when_used="json")
|
@field_serializer("statistics", when_used="json")
|
||||||
def serialize_statistics_fields(self, v):
|
def serialize_statistics_fields(self, v):
|
||||||
"""序列化统计字段,确保枚举值正确转换为字符串"""
|
"""序列化统计字段,确保枚举值正确转换为字符串"""
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
@@ -291,13 +290,6 @@ class ScoreResp(ScoreBase):
|
|||||||
return serialized
|
return serialized
|
||||||
return v
|
return v
|
||||||
|
|
||||||
@field_serializer("gamemode", when_used="json")
|
|
||||||
def serialize_gamemode(self, v):
|
|
||||||
"""序列化游戏模式,确保枚举值正确转换为字符串"""
|
|
||||||
if hasattr(v, 'value'):
|
|
||||||
return v.value
|
|
||||||
return str(v)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def from_db(cls, session: AsyncSession, score: Score) -> "ScoreResp":
|
async def from_db(cls, session: AsyncSession, score: Score) -> "ScoreResp":
|
||||||
s = cls.model_validate(score.model_dump())
|
s = cls.model_validate(score.model_dump())
|
||||||
|
|||||||
Reference in New Issue
Block a user