Skip to content

Commit 371041a

Browse files
committed
fix: remove user field from ApplicationApiKey model and update ApplicationKeySerializer
1 parent 18805e5 commit 371041a

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 5.2.11 on 2026-03-18 09:18
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('application', '0011_application_skill_tool_ids'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='applicationapikey',
15+
name='user',
16+
),
17+
]

apps/application/models/application_api_key.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66

77
from application.models import Application
88
from common.mixins.app_model_mixin import AppModelMixin
9-
from users.models import User
109

1110

1211
class ApplicationApiKey(AppModelMixin):
1312
id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
1413
secret_key = models.CharField(max_length=1024, verbose_name="秘钥", unique=True)
15-
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="用户id")
1614
workspace_id = models.CharField(max_length=64, verbose_name="工作空间id", default="default", db_index=True)
1715
application = models.ForeignKey(Application, on_delete=models.CASCADE, verbose_name="应用id")
1816
is_active = models.BooleanField(default=True, verbose_name="是否开启")

apps/application/serializers/application_api_key.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class EditApplicationKeySerializer(serializers.Serializer):
3636
class ApplicationKeySerializer(serializers.Serializer):
3737
workspace_id = serializers.CharField(required=False, allow_null=True, allow_blank=True, label=_("Workspace ID"))
3838
application_id = serializers.UUIDField(required=True, label=_('application id'))
39-
user_id = serializers.CharField(required=False, allow_null=True, allow_blank=True, label=_("User ID"))
4039
order_by = serializers.CharField(required=False, label=_('order by'), allow_null=True, allow_blank=True)
4140

4241
def is_valid(self, *, raise_exception=False):
@@ -55,7 +54,6 @@ def generate(self, with_valid=True):
5554
secret_key = 'agent-' + hashlib.md5(str(uuid.uuid7()).encode()).hexdigest()
5655
application_api_key = ApplicationApiKey(id=uuid.uuid7(),
5756
secret_key=secret_key,
58-
user_id=self.data.get('user_id'),
5957
application_id=application_id)
6058
application_api_key.save()
6159
return ApplicationKeySerializerModel(application_api_key).data

0 commit comments

Comments
 (0)