diff --git a/pol/api/v0/models/__init__.py b/pol/api/v0/models/__init__.py index 6df5847ff..be01c88a6 100644 --- a/pol/api/v0/models/__init__.py +++ b/pol/api/v0/models/__init__.py @@ -5,7 +5,7 @@ import pydantic from pydantic import Field, BaseModel -from pol.db.const import BloodType, PersonType +from pol.db.const import BloodType, PersonType, CharacterType from .base import Paged __all__ = [ @@ -113,7 +113,7 @@ class PersonDetail(BasePerson): class BaseCharacter(BaseModel): id: int name: str - type: PersonType = Field(description="角色,机体,组织...") + type: CharacterType = Field(description="角色,机体,舰船,组织...") images: Optional[PersonImages] = Field( description="object with some size of images, this object maybe `null`" ) diff --git a/pol/db/const.py b/pol/db/const.py index 2b85e128d..a9f7fab9f 100644 --- a/pol/db/const.py +++ b/pol/db/const.py @@ -20,6 +20,16 @@ def translate(self, _escape_table): return self.value +class CharacterType(enum.IntEnum): + person = 1 + airframe = 2 + ship = 3 + organization = 4 + + def translate(self, _escape_table): + return self.value + + class PersonType(enum.IntEnum): person = 1 company = 2