feat: 添加批注功能
后端: - Comment 模型(支持日记/任务/经验三种内容类型) - CommentSerializer 和 CommentViewSet - API: /api/comments/ - 批注 CRUD - API: /api/comments/by_content/?content_type=diary&object_id=1 - 按内容获取批注 - 日记/任务/经验序列化器嵌套显示批注 前端: - 批注样式(comments-section, comment-item) - 添加批注输入框 使用方式: - 北极星可以在任何日记/任务/经验下添加批注 - 批注会显示在内容下方 - 支持查看历史批注
This commit is contained in:
29
backend/diary/migrations/0005_comment.py
Normal file
29
backend/diary/migrations/0005_comment.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Generated by Django 4.2.11 on 2026-04-14 11:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('diary', '0004_diaryentry_content_diaryentry_linked_tasks_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Comment',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('content_type', models.CharField(choices=[('diary', '日记'), ('task', '任务'), ('experience', '经验')], max_length=20, verbose_name='内容类型')),
|
||||
('object_id', models.IntegerField(verbose_name='内容 ID')),
|
||||
('content', models.TextField(verbose_name='批注内容')),
|
||||
('created_by', models.CharField(default='北极星', max_length=100, verbose_name='创建者')),
|
||||
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '批注',
|
||||
'verbose_name_plural': '批注',
|
||||
'ordering': ['-created_at'],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user