feat: add profile and defalt hospital

This commit is contained in:
2026-06-18 15:21:09 +08:00
parent d92efed6ae
commit e1a5ca2afa
5 changed files with 28 additions and 11 deletions
+10 -1
View File
@@ -25,7 +25,16 @@ class CmsInstitutionSerializer(serializers.ModelSerializer):
'id', 'code', 'name', 'type', 'level',
'province', 'city', 'banner_url', 'created_at', 'updated_at',
]
read_only_fields = ['id', 'created_at', 'updated_at']
# type 不可编辑:新增/编辑均不接收,存库恒为 hospital(见 create/update
read_only_fields = ['id', 'type', 'created_at', 'updated_at']
def create(self, validated_data):
validated_data['type'] = 'hospital'
return super().create(validated_data)
def update(self, instance, validated_data):
validated_data['type'] = 'hospital' # 每次保存都归一为 hospital
return super().update(instance, validated_data)
def to_representation(self, instance):
data = super().to_representation(instance)