resource_mapping.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. # coding=utf-8
  2. """
  3. @project: MaxKB
  4. @Author:虎虎
  5. @file: resource_mapping.py
  6. @date:2025/12/19 15:41
  7. @desc:
  8. """
  9. from django.db import models
  10. import uuid_utils.compat as uuid
  11. from common.constants.permission_constants import Group
  12. from common.mixins.app_model_mixin import AppModelMixin
  13. class ResourceType(models.TextChoices):
  14. KNOWLEDGE = Group.KNOWLEDGE.value, '知识库'
  15. APPLICATION = Group.APPLICATION.value, '应用'
  16. TOOL = Group.TOOL.value, '工具'
  17. MODEL = Group.MODEL.value, '模型'
  18. class ResourceMapping(AppModelMixin):
  19. id = models.UUIDField(primary_key=True, max_length=128, default=uuid.uuid7, editable=False, verbose_name="主键id")
  20. source_type = models.CharField(verbose_name="关联资源类型", choices=ResourceType.choices, db_index=True)
  21. target_type = models.CharField(verbose_name="被关联资源类型", choices=ResourceType.choices, db_index=True)
  22. source_id = models.CharField(max_length=128, verbose_name="关联资源id", db_index=True)
  23. target_id = models.CharField(max_length=128, verbose_name="被关联资源id", db_index=True)
  24. class Meta:
  25. db_table = "resource_mapping"