将文件夹命名从拼音改为英文,整理了一些代码,将导入语句迁移到了头部

This commit is contained in:
2026-06-14 16:39:09 +08:00
parent 1fd0301e0e
commit 21bb129c5d
178 changed files with 29249 additions and 35862 deletions

39
backend/serializers.py Normal file
View File

@@ -0,0 +1,39 @@
# serializers.py
#小程序弹窗序列化器
from rest_framework import serializers
from config.models import PopupPage, PopupConfig, PopupImage
class PopupImageSerializer(serializers.ModelSerializer):
"""图片序列化器(输出用)"""
class Meta:
model = PopupImage
fields = ['id', 'image_url', 'text', 'sort_order']
class PopupConfigSerializer(serializers.ModelSerializer):
"""弹窗配置序列化器(输出用)"""
images = PopupImageSerializer(many=True, read_only=True)
class Meta:
model = PopupConfig
fields = [
'id', 'popup_id', 'title', 'description',
'strategy_type', 'max_count', 'reset_interval',
'duration', 'force_even_muted', 'sort_order',
'is_active', 'start_time', 'end_time',
'created_at', 'updated_at', 'images'
]
class PopupPageSerializer(serializers.ModelSerializer):
"""页面序列化器(输出用)"""
popups = PopupConfigSerializer(many=True, read_only=True)
class Meta:
model = PopupPage
fields = [
'id', 'page_key', 'name', 'description',
'is_active', 'ignore_user_mute',
'created_at', 'updated_at', 'popups'
]