diff --git a/video-gen-api/app/api/v1/user_oauth_app.py b/video-gen-api/app/api/v1/user_oauth_app.py index 1aa946a6..b772a293 100644 --- a/video-gen-api/app/api/v1/user_oauth_app.py +++ b/video-gen-api/app/api/v1/user_oauth_app.py @@ -41,7 +41,7 @@ async def create_app( db: AsyncSession = Depends(get_db), ): try: - app = await create_user_oauth_app(db, req.app_id, req.secret, req.open_type, admin.id) + app = await create_user_oauth_app(db, req.app_id, req.secret, req.open_type, admin.id, req.count) return UserOAuthAppOut.model_validate(app) except ValueError as e: raise HTTPException( @@ -72,7 +72,7 @@ async def update_app( admin: User = Depends(get_admin_user), db: AsyncSession = Depends(get_db), ): - app = await update_user_oauth_app(db, id, req.secret, req.open_type, req.status, admin.id) + app = await update_user_oauth_app(db, id, req.secret, req.open_type, req.status, req.count, admin.id) if not app: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, diff --git a/video-gen-api/app/models/user_oauth_app.py b/video-gen-api/app/models/user_oauth_app.py index c71b9850..d69358f0 100644 --- a/video-gen-api/app/models/user_oauth_app.py +++ b/video-gen-api/app/models/user_oauth_app.py @@ -19,6 +19,9 @@ class UserOAuthApp(Base, TimestampMixin, SoftDeleteMixin): status: Mapped[int] = mapped_column( BigInteger, nullable=False, default=1, comment="状态,1=正常,2=禁用" ) + count: Mapped[int] = mapped_column( + BigInteger, nullable=False, default=100, comment="应用最大可以授权多少个用户" + ) open_type: Mapped[int] = mapped_column( BigInteger, nullable=False, index=True, comment="开户方式(1=千川,2=广告,3=本地推,4=星图,5=快手代理商,6=巨量星图,7=巨量服务单,8=腾讯服务单,9=腾讯营销K2,10=腾讯营销K3)" ) diff --git a/video-gen-api/app/schemas/user_oauth_app.py b/video-gen-api/app/schemas/user_oauth_app.py index 534eddba..7a130142 100644 --- a/video-gen-api/app/schemas/user_oauth_app.py +++ b/video-gen-api/app/schemas/user_oauth_app.py @@ -12,6 +12,7 @@ class UserOAuthAppCreate(BaseModel): le=10, description="开户方式(1=千川,2=广告,3=本地推,4=星图,5=快手代理商,6=巨量星图,7=巨量服务单,8=腾讯服务单,9=腾讯营销K2,10=腾讯营销K3)", ) + count: int = Field(100, ge=1, description="应用最大可以授权多少个用户") class UserOAuthAppUpdate(BaseModel): @@ -23,6 +24,7 @@ class UserOAuthAppUpdate(BaseModel): description="开户方式(1=千川,2=广告,3=本地推,4=星图,5=快手代理商,6=巨量星图,7=巨量服务单,8=腾讯服务单,9=腾讯营销K2,10=腾讯营销K3)", ) status: int | None = Field(None, ge=1, le=2, description="应用状态(1=正常,2=禁用)") + count: int | None = Field(None, ge=1, description="应用最大可以授权多少个用户") class UserOAuthAppOut(BaseModel): @@ -30,6 +32,7 @@ class UserOAuthAppOut(BaseModel): app_id: str = Field(..., description="应用id") secret: str = Field(..., description="应用密钥") status: int = Field(..., description="状态,1=正常,2=禁用") + count: int = Field(..., description="应用最大可以授权多少个用户") open_type: int = Field(..., description="开户方式") create_by: str | None = Field(None, description="创建者") created_at: NaiveDatetime = Field(..., description="创建时间") diff --git a/video-gen-api/app/services/user_oauth_app_service.py b/video-gen-api/app/services/user_oauth_app_service.py index 88e791b9..9e307f72 100644 --- a/video-gen-api/app/services/user_oauth_app_service.py +++ b/video-gen-api/app/services/user_oauth_app_service.py @@ -62,6 +62,7 @@ async def create_user_oauth_app( secret: str, open_type: int, create_by: str | None = None, + count: int = 100, ) -> UserOAuthApp: existing = await get_user_oauth_app_by_app_id(db, app_id) if existing: @@ -72,6 +73,7 @@ async def create_user_oauth_app( app_id=app_id, secret=secret, open_type=open_type, + count=count, create_by=create_by, ) db.add(app) @@ -87,6 +89,7 @@ async def update_user_oauth_app( secret: str | None = None, open_type: int | None = None, status: int | None = None, + count: int | None = None, create_by: str | None = None, ) -> UserOAuthApp | None: app = await get_user_oauth_app_by_id(db, id) @@ -99,6 +102,8 @@ async def update_user_oauth_app( app.open_type = open_type if status is not None: app.status = status + if count is not None: + app.count = count if create_by is not None: app.create_by = create_by