增加右下角联系我们整体功能
This commit is contained in:
@@ -25,6 +25,7 @@ from app.api.v1.pre_test_template import router as pre_test_template_router
|
||||
from app.api.v1.material_consumption import router as material_consumption_router
|
||||
from app.api.v1.open_type import router as open_type_router
|
||||
from app.api.v1.resources_material import router as resources_material_router
|
||||
from app.api.v1.contact import router as contact_router
|
||||
from app.api.admin import router as admin_module_router
|
||||
|
||||
api_router = APIRouter()
|
||||
@@ -53,4 +54,5 @@ api_router.include_router(pre_test_template_router)
|
||||
api_router.include_router(material_consumption_router)
|
||||
api_router.include_router(open_type_router)
|
||||
api_router.include_router(resources_material_router)
|
||||
api_router.include_router(contact_router)
|
||||
api_router.include_router(admin_module_router)
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
from datetime import datetime, timezone, timedelta
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy import func, select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.dependencies import get_db, get_current_user
|
||||
from app.models.contact_request import ContactRequest
|
||||
from app.models.user import User
|
||||
from app.schemas.contact import ContactRequestCreate, ContactRequestListOut, ContactRequestOut
|
||||
from app.utils.id_gen import generate_id
|
||||
|
||||
router = APIRouter(prefix="/contact", tags=["contact"])
|
||||
|
||||
|
||||
@router.post("/request", summary="提交联系请求", status_code=status.HTTP_201_CREATED)
|
||||
async def create_contact_request(
|
||||
request: ContactRequestCreate,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
today_start = datetime.now(timezone.utc).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
today_end = today_start + timedelta(days=1)
|
||||
|
||||
count = await db.execute(
|
||||
select(func.count(ContactRequest.id))
|
||||
.where(ContactRequest.user_id == user.id)
|
||||
.where(ContactRequest.created_at >= today_start)
|
||||
.where(ContactRequest.created_at < today_end)
|
||||
)
|
||||
daily_count = count.scalar_one()
|
||||
|
||||
if daily_count >= 1:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
|
||||
detail="每个账号每天只能提交一次联系请求"
|
||||
)
|
||||
|
||||
contact_request = ContactRequest(
|
||||
id=generate_id(),
|
||||
user_id=user.id,
|
||||
phone=request.phone,
|
||||
company_name=request.company_name,
|
||||
industry=request.industry,
|
||||
name=request.name,
|
||||
message=request.message,
|
||||
)
|
||||
|
||||
db.add(contact_request)
|
||||
await db.commit()
|
||||
await db.refresh(contact_request)
|
||||
|
||||
return {"message": "提交成功,我们会尽快与您联系"}
|
||||
|
||||
|
||||
@router.get("/requests", summary="获取联系请求列表", response_model=ContactRequestListOut)
|
||||
async def get_contact_requests(
|
||||
page: int = 1,
|
||||
page_size: int = 20,
|
||||
is_handled: bool | None = None,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
if not user.is_admin:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="无权限")
|
||||
|
||||
query = select(ContactRequest).order_by(ContactRequest.created_at.desc())
|
||||
|
||||
if is_handled is not None:
|
||||
query = query.where(ContactRequest.is_handled == is_handled)
|
||||
|
||||
offset = (page - 1) * page_size
|
||||
result = await db.execute(query.offset(offset).limit(page_size))
|
||||
items = result.scalars().all()
|
||||
|
||||
count_result = await db.execute(select(func.count(ContactRequest.id)))
|
||||
total = count_result.scalar_one()
|
||||
|
||||
return {"items": items, "total": total}
|
||||
|
||||
|
||||
@router.get("/requests/{request_id}", summary="获取联系请求详情", response_model=ContactRequestOut)
|
||||
async def get_contact_request(
|
||||
request_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
if not user.is_admin:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="无权限")
|
||||
|
||||
result = await db.execute(select(ContactRequest).where(ContactRequest.id == request_id))
|
||||
contact_request = result.scalar_one_or_none()
|
||||
|
||||
if not contact_request:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="记录不存在")
|
||||
|
||||
return contact_request
|
||||
|
||||
|
||||
@router.put("/requests/{request_id}/handle", summary="标记为已处理")
|
||||
async def mark_as_handled(
|
||||
request_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
if not user.is_admin:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="无权限")
|
||||
|
||||
result = await db.execute(select(ContactRequest).where(ContactRequest.id == request_id))
|
||||
contact_request = result.scalar_one_or_none()
|
||||
|
||||
if not contact_request:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="记录不存在")
|
||||
|
||||
contact_request.is_handled = True
|
||||
await db.commit()
|
||||
await db.refresh(contact_request)
|
||||
|
||||
return {"message": "已标记为处理"}
|
||||
|
||||
|
||||
@router.delete("/requests/{request_id}", summary="删除联系请求")
|
||||
async def delete_contact_request(
|
||||
request_id: str,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
user: User = Depends(get_current_user),
|
||||
):
|
||||
if not user.is_admin:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="无权限")
|
||||
|
||||
result = await db.execute(select(ContactRequest).where(ContactRequest.id == request_id))
|
||||
contact_request = result.scalar_one_or_none()
|
||||
|
||||
if not contact_request:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="记录不存在")
|
||||
|
||||
await db.delete(contact_request)
|
||||
await db.commit()
|
||||
|
||||
return {"message": "删除成功"}
|
||||
@@ -424,6 +424,7 @@ async def _seed_data():
|
||||
("/settings", "系统设置", "SettingOutlined", 4, "系统设置"),
|
||||
("/operation-logs", "操作日志", "DatabaseOutlined", 5, "系统设置"),
|
||||
("/oauthapp-list", "授权应用", "MenuOutlined", 28, "系统设置"),
|
||||
("/contact-requests", "联系请求", "MessageCircleOutlined", 29, "系统设置"),
|
||||
]
|
||||
for path, label, icon, order, parent_group in admin_pages:
|
||||
db.add(
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy import Boolean, ForeignKey, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base, TimestampMixin
|
||||
|
||||
|
||||
class ContactRequest(Base, TimestampMixin):
|
||||
__tablename__ = "contact_requests"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(32), primary_key=True)
|
||||
user_id: Mapped[str] = mapped_column(String(32), ForeignKey("users.id"), index=True)
|
||||
phone: Mapped[str] = mapped_column(String(20), index=True)
|
||||
company_name: Mapped[str] = mapped_column(String(128))
|
||||
industry: Mapped[str] = mapped_column(String(64))
|
||||
name: Mapped[str] = mapped_column(String(64))
|
||||
message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
is_handled: Mapped[bool] = mapped_column(Boolean, default=False)
|
||||
@@ -0,0 +1,31 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class ContactRequestCreate(BaseModel):
|
||||
phone: str = Field(..., description="手机号")
|
||||
company_name: str = Field(..., description="公司名称")
|
||||
industry: str = Field(..., description="行业")
|
||||
name: str = Field(..., description="姓名")
|
||||
message: str | None = Field(None, description="留言")
|
||||
|
||||
|
||||
class ContactRequestOut(BaseModel):
|
||||
id: str
|
||||
user_id: str
|
||||
phone: str
|
||||
company_name: str
|
||||
industry: str
|
||||
name: str
|
||||
message: str | None
|
||||
is_handled: bool
|
||||
created_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class ContactRequestListOut(BaseModel):
|
||||
items: list[ContactRequestOut]
|
||||
total: int
|
||||
@@ -11,7 +11,7 @@ Requires-Dist: alembic>=1.14.0
|
||||
Requires-Dist: pydantic>=2.10.0
|
||||
Requires-Dist: pydantic-settings>=2.6.0
|
||||
Requires-Dist: pyjwt>=2.10.0
|
||||
Requires-Dist: passlib[bcrypt]>=1.7.4
|
||||
Requires-Dist: bcrypt>=4.0.0
|
||||
Requires-Dist: httpx>=0.28.0
|
||||
Requires-Dist: python-multipart>=0.0.17
|
||||
Requires-Dist: cryptography>=44.0.0
|
||||
@@ -22,6 +22,12 @@ Requires-Dist: redis>=5.2.0; extra == "redis"
|
||||
Provides-Extra: celery
|
||||
Requires-Dist: celery>=5.4.0; extra == "celery"
|
||||
Requires-Dist: redis>=5.2.0; extra == "celery"
|
||||
Provides-Extra: alipay
|
||||
Requires-Dist: alipay-sdk-python>=3.7.1160; extra == "alipay"
|
||||
Provides-Extra: wxpay
|
||||
Requires-Dist: wechatpayv3>=2.0.2; extra == "wxpay"
|
||||
Provides-Extra: volc
|
||||
Requires-Dist: volcengine-python-sdk>=1.1.0; extra == "volc"
|
||||
Provides-Extra: dev
|
||||
Requires-Dist: pytest>=8.3.0; extra == "dev"
|
||||
Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
|
||||
|
||||
@@ -4,56 +4,196 @@ app/config.py
|
||||
app/dependencies.py
|
||||
app/main.py
|
||||
app/api/__init__.py
|
||||
app/api/admin/__init__.py
|
||||
app/api/admin/video_prompt_schema_config.py
|
||||
app/api/v1/__init__.py
|
||||
app/api/v1/admin.py
|
||||
app/api/v1/auth.py
|
||||
app/api/v1/captcha.py
|
||||
app/api/v1/contact.py
|
||||
app/api/v1/credits.py
|
||||
app/api/v1/generation.py
|
||||
app/api/v1/generation_ai.py
|
||||
app/api/v1/hot_opening_replicate.py
|
||||
app/api/v1/image_engines.py
|
||||
app/api/v1/industries.py
|
||||
app/api/v1/material_consumption.py
|
||||
app/api/v1/menu_configs.py
|
||||
app/api/v1/notifications.py
|
||||
app/api/v1/open_type.py
|
||||
app/api/v1/payments.py
|
||||
app/api/v1/pre_test_template.py
|
||||
app/api/v1/projects.py
|
||||
app/api/v1/recharge_packages.py
|
||||
app/api/v1/resources_material.py
|
||||
app/api/v1/shot_replicate.py
|
||||
app/api/v1/sms.py
|
||||
app/api/v1/test.py
|
||||
app/api/v1/upload_material.py
|
||||
app/api/v1/user_oauth.py
|
||||
app/api/v1/user_oauth_app.py
|
||||
app/api/v1/video_engines.py
|
||||
app/enums/__init__.py
|
||||
app/enums/common.py
|
||||
app/enums/credit_record.py
|
||||
app/enums/hot_opening_replicate.py
|
||||
app/enums/module_generation_flow.py
|
||||
app/enums/shot_replicate.py
|
||||
app/enums/token_usage.py
|
||||
app/enums/user.py
|
||||
app/enums/video_prompt_schema.py
|
||||
app/middleware/__init__.py
|
||||
app/middleware/anti_crawler.py
|
||||
app/middleware/logging.py
|
||||
app/middleware/rate_limit.py
|
||||
app/middleware/request_encrypt.py
|
||||
app/models/__init__.py
|
||||
app/models/base.py
|
||||
app/models/chat_generation_task.py
|
||||
app/models/chat_generation_task_event.py
|
||||
app/models/chat_provider_call_log.py
|
||||
app/models/contact_request.py
|
||||
app/models/credit_ratio.py
|
||||
app/models/credit_record.py
|
||||
app/models/generated_resource.py
|
||||
app/models/generation_record.py
|
||||
app/models/image_engine.py
|
||||
app/models/industry_config.py
|
||||
app/models/material_cost.py
|
||||
app/models/menu_config.py
|
||||
app/models/model_config.py
|
||||
app/models/module_generation_project.py
|
||||
app/models/module_generation_step.py
|
||||
app/models/notification.py
|
||||
app/models/notification_read.py
|
||||
app/models/open_type.py
|
||||
app/models/operation_log.py
|
||||
app/models/payment_order.py
|
||||
app/models/pre_test_template.py
|
||||
app/models/project.py
|
||||
app/models/recharge_package.py
|
||||
app/models/resources_material.py
|
||||
app/models/shot_replicate_segment.py
|
||||
app/models/shot_replicate_task_set.py
|
||||
app/models/system_config.py
|
||||
app/models/token_usage.py
|
||||
app/models/upload_task.py
|
||||
app/models/user.py
|
||||
app/models/user_oauth.py
|
||||
app/models/user_oauth_account.py
|
||||
app/models/user_oauth_app.py
|
||||
app/models/user_resource_month_stat.py
|
||||
app/models/user_resource_total_stat.py
|
||||
app/models/video_engine.py
|
||||
app/schemas/__init__.py
|
||||
app/schemas/admin.py
|
||||
app/schemas/auth.py
|
||||
app/schemas/captcha.py
|
||||
app/schemas/common.py
|
||||
app/schemas/contact.py
|
||||
app/schemas/credit.py
|
||||
app/schemas/credit_ratio.py
|
||||
app/schemas/generation.py
|
||||
app/schemas/generation_ai.py
|
||||
app/schemas/hot_opening_replicate.py
|
||||
app/schemas/image_engine.py
|
||||
app/schemas/industry.py
|
||||
app/schemas/menu.py
|
||||
app/schemas/notification.py
|
||||
app/schemas/open_type.py
|
||||
app/schemas/payment.py
|
||||
app/schemas/pre_test_template.py
|
||||
app/schemas/project.py
|
||||
app/schemas/recharge_package.py
|
||||
app/schemas/resources_material.py
|
||||
app/schemas/shot_replicate.py
|
||||
app/schemas/sms.py
|
||||
app/schemas/user.py
|
||||
app/schemas/user_oauth.py
|
||||
app/schemas/user_oauth_app.py
|
||||
app/schemas/video_engine.py
|
||||
app/schemas/video_prompt_schema_config.py
|
||||
app/services/__init__.py
|
||||
app/services/admin_credit_record_service.py
|
||||
app/services/auth.py
|
||||
app/services/captcha.py
|
||||
app/services/celery_download_recovery_service.py
|
||||
app/services/credit_ratio_service.py
|
||||
app/services/credit_record_meta_service.py
|
||||
app/services/credits.py
|
||||
app/services/error_codes.py
|
||||
app/services/generation_ai_service.py
|
||||
app/services/generation_billing_service.py
|
||||
app/services/generation_download_service.py
|
||||
app/services/generation_log_service.py
|
||||
app/services/generation_module_hook_service.py
|
||||
app/services/generation_prompt_service.py
|
||||
app/services/generation_provider_service.py
|
||||
app/services/generation_provider_types.py
|
||||
app/services/generation_recovery_service.py
|
||||
app/services/generation_refund_service.py
|
||||
app/services/generation_task_factory_service.py
|
||||
app/services/hot_opening_replicate_service.py
|
||||
app/services/hot_opening_video_prompt_service.py
|
||||
app/services/image_gen.py
|
||||
app/services/llm.py
|
||||
app/services/log_config.py
|
||||
app/services/material_consumption_queue.py
|
||||
app/services/material_consumption_service.py
|
||||
app/services/module_async_recovery_service.py
|
||||
app/services/module_generation_flow_base_service.py
|
||||
app/services/module_generation_log_service.py
|
||||
app/services/module_generation_step_common_service.py
|
||||
app/services/module_generation_step_update_service.py
|
||||
app/services/notification.py
|
||||
app/services/operation_log.py
|
||||
app/services/payment.py
|
||||
app/services/pre_test_template_service.py
|
||||
app/services/provider_limit.py
|
||||
app/services/redis_registry_service.py
|
||||
app/services/resource_accounting_service.py
|
||||
app/services/resource_signed_url_service.py
|
||||
app/services/resources_material_service.py
|
||||
app/services/shot_replicate_flow_service.py
|
||||
app/services/shot_replicate_recovery_service.py
|
||||
app/services/shot_replicate_taskset_service.py
|
||||
app/services/shot_video_analysis_service.py
|
||||
app/services/shot_video_split_service.py
|
||||
app/services/sms.py
|
||||
app/services/upload_material_service.py
|
||||
app/services/upload_queue.py
|
||||
app/services/upload_video_asset_service.py
|
||||
app/services/user_oauth_app_service.py
|
||||
app/services/user_oauth_service.py
|
||||
app/services/video_cover_service.py
|
||||
app/services/video_gen.py
|
||||
app/services/video_prompt_schema_config_service.py
|
||||
app/services/video_queue.py
|
||||
app/services/video_url.py
|
||||
app/tasks/__init__.py
|
||||
app/tasks/async_runner.py
|
||||
app/tasks/celery_app.py
|
||||
app/tasks/cleanup.py
|
||||
app/tasks/generation_create_tasks.py
|
||||
app/tasks/generation_download_tasks.py
|
||||
app/tasks/generation_poll_tasks.py
|
||||
app/tasks/generation_recovery_tasks.py
|
||||
app/tasks/hot_opening_replicate_tasks.py
|
||||
app/tasks/material_consumption_task.py
|
||||
app/tasks/module_async_recovery_tasks.py
|
||||
app/tasks/pre_test_result_task.py
|
||||
app/tasks/shot_replicate_flow_tasks.py
|
||||
app/tasks/shot_replicate_tasks.py
|
||||
app/tasks/token_refresh_task.py
|
||||
app/tasks/user_oauth_tasks.py
|
||||
app/tasks/video_generation.py
|
||||
app/utils/__init__.py
|
||||
app/utils/area.py
|
||||
app/utils/douyinApi.py
|
||||
app/utils/douyinRequest.py
|
||||
app/utils/exceptions.py
|
||||
app/utils/id_gen.py
|
||||
app/utils/logger.py
|
||||
app/utils/redis.py
|
||||
app/utils/security.py
|
||||
videogen_api.egg-info/PKG-INFO
|
||||
|
||||
@@ -6,11 +6,14 @@ alembic>=1.14.0
|
||||
pydantic>=2.10.0
|
||||
pydantic-settings>=2.6.0
|
||||
pyjwt>=2.10.0
|
||||
passlib[bcrypt]>=1.7.4
|
||||
bcrypt>=4.0.0
|
||||
httpx>=0.28.0
|
||||
python-multipart>=0.0.17
|
||||
cryptography>=44.0.0
|
||||
|
||||
[alipay]
|
||||
alipay-sdk-python>=3.7.1160
|
||||
|
||||
[celery]
|
||||
celery>=5.4.0
|
||||
redis>=5.2.0
|
||||
@@ -25,3 +28,9 @@ asyncpg>=0.30.0
|
||||
|
||||
[redis]
|
||||
redis>=5.2.0
|
||||
|
||||
[volc]
|
||||
volcengine-python-sdk>=1.1.0
|
||||
|
||||
[wxpay]
|
||||
wechatpayv3>=2.0.2
|
||||
|
||||
Reference in New Issue
Block a user