MindMap/backend/mindmap/models.py

62 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.db import models
import uuid
class mindMap(models.Model):
"""思维导图(最小字段,按接口文档)"""
file_name = models.CharField(max_length=255, default='思维导图') # title
created_at = models.DateTimeField(auto_now_add=True) # createDate
updated_at = models.DateTimeField(auto_now=True) # updateDate
deleted = models.BooleanField(default=False) # delete
class Meta:
db_table = 'mindmaps'
ordering = ['-created_at']
def __str__(self):
return f"{self.file_name}"
class Node(models.Model):
"""节点(最小字段,按接口文档)"""
id = models.CharField(max_length=255, primary_key=True, default=uuid.uuid4)
mindmap = models.ForeignKey(mindMap, on_delete=models.CASCADE, related_name='nodes')
is_root = models.BooleanField(default=False) # isRoot
parent_id = models.CharField(max_length=255, null=True, blank=True) # parentId
children_count = models.IntegerField(default=0) # childrenCount
depth = models.IntegerField(default=0) # depth
title = models.CharField(max_length=500, blank=True, default='') # title
desc = models.TextField(blank=True, default='') # des
# 图片相关字段
image_url = models.URLField(max_length=1000, blank=True, null=True) # 图片URL
image_width = models.IntegerField(default=120, null=True, blank=True) # 图片宽度
image_height = models.IntegerField(default=80, null=True, blank=True) # 图片高度
image_fit = models.CharField(max_length=20, default='contain', blank=True) # 图片适配方式
# HTML内容字段
html_content = models.TextField(blank=True, default='') # dangerouslySetInnerHTML内容
# Markdown源码新增
markdown_content = models.TextField(blank=True, default='')
created_at = models.DateTimeField(auto_now_add=True) # createDate
updated_at = models.DateTimeField(auto_now=True) # updateDate
deleted = models.BooleanField(default=False) # delete
class Meta:
db_table = 'nodes'
ordering = ['created_at']