From f46a0da04009bf102ed387102f0398476a1f844b Mon Sep 17 00:00:00 2001 From: 18610128193 <10574456+chenweiqiang-123@user.noreply.gitee.com> Date: Wed, 10 Jun 2026 16:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BA=94=E7=94=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=88=E6=9D=83=E9=93=BE=E6=8E=A5=EF=BC=8C=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E5=85=AC=E5=8F=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...auth表新增归属公司应用_新增授权链接字段.py | 31 +++++++++++++++++++ video-gen-api/app/api/v1/user_oauth_app.py | 4 +-- video-gen-api/app/models/user_oauth_app.py | 6 ++++ video-gen-api/app/schemas/user_oauth_app.py | 6 ++++ .../app/services/user_oauth_app_service.py | 10 ++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 video-gen-api/alembic/versions/6101ba8d5761_user_oauth表新增归属公司应用_新增授权链接字段.py diff --git a/video-gen-api/alembic/versions/6101ba8d5761_user_oauth表新增归属公司应用_新增授权链接字段.py b/video-gen-api/alembic/versions/6101ba8d5761_user_oauth表新增归属公司应用_新增授权链接字段.py new file mode 100644 index 00000000..fa9449f5 --- /dev/null +++ b/video-gen-api/alembic/versions/6101ba8d5761_user_oauth表新增归属公司应用_新增授权链接字段.py @@ -0,0 +1,31 @@ +"""user_oauth表新增归属公司应用,新增授权链接字段 + +Revision ID: 6101ba8d5761 +Revises: 9ac2212e1b8e +Create Date: 2026-06-10 16:34:38.842582 +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '6101ba8d5761' +down_revision: Union[str, None] = '9ac2212e1b8e' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('user_oauth_app', sa.Column('auth_url', sa.String(length=256), nullable=True, comment='应用授权链接')) + op.add_column('user_oauth_app', sa.Column('company', sa.String(length=256), nullable=True, comment='应用归属公司名称')) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('user_oauth_app', 'company') + op.drop_column('user_oauth_app', 'auth_url') + # ### end Alembic commands ### 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 b772a293..6f9bfbb2 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, req.count) + app = await create_user_oauth_app(db, req.app_id, req.secret, req.open_type, admin.id, req.count, req.auth_url, req.company) 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, req.count, admin.id) + app = await update_user_oauth_app(db, id, req.secret, req.open_type, req.status, req.count, req.auth_url, req.company, 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 d69358f0..377a6361 100644 --- a/video-gen-api/app/models/user_oauth_app.py +++ b/video-gen-api/app/models/user_oauth_app.py @@ -22,6 +22,12 @@ class UserOAuthApp(Base, TimestampMixin, SoftDeleteMixin): count: Mapped[int] = mapped_column( BigInteger, nullable=False, default=100, comment="应用最大可以授权多少个用户" ) + auth_url: Mapped[str] = mapped_column( + String(256), nullable=True, comment="应用授权链接" + ) + company: Mapped[str] = mapped_column( + String(256), nullable=True, 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 7a130142..3c574e46 100644 --- a/video-gen-api/app/schemas/user_oauth_app.py +++ b/video-gen-api/app/schemas/user_oauth_app.py @@ -13,6 +13,8 @@ class UserOAuthAppCreate(BaseModel): description="开户方式(1=千川,2=广告,3=本地推,4=星图,5=快手代理商,6=巨量星图,7=巨量服务单,8=腾讯服务单,9=腾讯营销K2,10=腾讯营销K3)", ) count: int = Field(100, ge=1, description="应用最大可以授权多少个用户") + auth_url: str | None = Field(None, max_length=256, description="应用授权链接") + company: str | None = Field(None, max_length=256, description="应用归属公司名称") class UserOAuthAppUpdate(BaseModel): @@ -25,6 +27,8 @@ class UserOAuthAppUpdate(BaseModel): ) status: int | None = Field(None, ge=1, le=2, description="应用状态(1=正常,2=禁用)") count: int | None = Field(None, ge=1, description="应用最大可以授权多少个用户") + auth_url: str | None = Field(None, max_length=256, description="应用授权链接") + company: str | None = Field(None, max_length=256, description="应用归属公司名称") class UserOAuthAppOut(BaseModel): @@ -34,6 +38,8 @@ class UserOAuthAppOut(BaseModel): status: int = Field(..., description="状态,1=正常,2=禁用") count: int = Field(..., description="应用最大可以授权多少个用户") open_type: int = Field(..., description="开户方式") + auth_url: str | None = Field(None, description="应用授权链接") + company: str | None = Field(None, description="应用归属公司名称") create_by: str | None = Field(None, description="创建者") created_at: NaiveDatetime = Field(..., description="创建时间") updated_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 9e307f72..5841de08 100644 --- a/video-gen-api/app/services/user_oauth_app_service.py +++ b/video-gen-api/app/services/user_oauth_app_service.py @@ -63,6 +63,8 @@ async def create_user_oauth_app( open_type: int, create_by: str | None = None, count: int = 100, + auth_url: str | None = None, + company: str | None = None, ) -> UserOAuthApp: existing = await get_user_oauth_app_by_app_id(db, app_id) if existing: @@ -74,6 +76,8 @@ async def create_user_oauth_app( secret=secret, open_type=open_type, count=count, + auth_url=auth_url, + company=company, create_by=create_by, ) db.add(app) @@ -90,6 +94,8 @@ async def update_user_oauth_app( open_type: int | None = None, status: int | None = None, count: int | None = None, + auth_url: str | None = None, + company: str | None = None, create_by: str | None = None, ) -> UserOAuthApp | None: app = await get_user_oauth_app_by_id(db, id) @@ -104,6 +110,10 @@ async def update_user_oauth_app( app.status = status if count is not None: app.count = count + if auth_url is not None: + app.auth_url = auth_url + if company is not None: + app.company = company if create_by is not None: app.create_by = create_by