# Generated by Django 5.1.5 on 2025-03-28 06:51

import django.contrib.auth.models
import django.contrib.auth.validators
import django.db.models.deletion
import django.utils.timezone
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0012_alter_user_first_name_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='FeishuCreator',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('record_id', models.CharField(max_length=100, unique=True, verbose_name='飞书记录ID')),
                ('contact_person', models.CharField(blank=True, max_length=50, verbose_name='对接人')),
                ('handle', models.CharField(blank=True, max_length=100, verbose_name='Handle')),
                ('tiktok_url', models.URLField(blank=True, verbose_name='链接')),
                ('fans_count', models.CharField(blank=True, max_length=50, verbose_name='粉丝数')),
                ('gmv', models.CharField(blank=True, max_length=50, verbose_name='GMV')),
                ('email', models.EmailField(blank=True, max_length=254, verbose_name='邮箱')),
                ('phone', models.CharField(blank=True, max_length=50, verbose_name='手机号|WhatsApp')),
                ('account_type', models.CharField(blank=True, max_length=50, verbose_name='账号属性')),
                ('price_quote', models.CharField(blank=True, max_length=100, verbose_name='报价')),
                ('response_speed', models.CharField(blank=True, max_length=50, verbose_name='回复速度')),
                ('cooperation_intention', models.CharField(blank=True, max_length=50, verbose_name='合作意向')),
                ('payment_method', models.CharField(blank=True, max_length=50, verbose_name='支付方式')),
                ('payment_account', models.CharField(blank=True, max_length=100, verbose_name='收款账号')),
                ('address', models.TextField(blank=True, verbose_name='收件地址')),
                ('has_ooin', models.CharField(blank=True, max_length=10, verbose_name='签约OOIN?')),
                ('source', models.CharField(blank=True, max_length=100, verbose_name='渠道来源')),
                ('contact_status', models.CharField(blank=True, max_length=50, verbose_name='建联进度')),
                ('cooperation_brands', models.JSONField(blank=True, default=list, verbose_name='合作品牌')),
                ('system_categories', models.CharField(blank=True, max_length=100, verbose_name='系统展示的带货品类')),
                ('actual_categories', models.CharField(blank=True, max_length=100, verbose_name='实际高播放量带货品类')),
                ('human_categories', models.CharField(blank=True, max_length=100, verbose_name='达人标想要货品类')),
                ('creator_base', models.CharField(blank=True, max_length=100, verbose_name='达人base')),
                ('notes', models.TextField(blank=True, verbose_name='父记录')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
            ],
            options={
                'verbose_name': '创作者数据',
                'verbose_name_plural': '创作者数据',
                'db_table': 'feishu_creators',
            },
        ),
        migrations.CreateModel(
            name='User',
            fields=[
                ('password', models.CharField(max_length=128, verbose_name='password')),
                ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
                ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
                ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
                ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
                ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
                ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
                ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
                ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
                ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(default='未设置', max_length=150, verbose_name='真实姓名')),
                ('role', models.CharField(choices=[('admin', '管理员'), ('leader', '组长'), ('member', '组员')], default='member', max_length=20, verbose_name='角色')),
                ('department', models.CharField(default='未分配', max_length=100, verbose_name='部门')),
                ('group', models.CharField(blank=True, max_length=100, null=True, verbose_name='小组')),
                ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
                ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
            ],
            options={
                'verbose_name': '用户',
                'verbose_name_plural': '用户',
                'db_table': 'users',
            },
            managers=[
                ('objects', django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.CreateModel(
            name='Data',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.CharField(help_text='数据名称', max_length=100)),
                ('desc', models.TextField(blank=True, help_text='数据描述')),
                ('type', models.CharField(choices=[('admin', '管理员数据'), ('leader', '组长数据'), ('member', '组员数据')], max_length=10)),
                ('meta', models.JSONField(blank=True, default=dict, help_text='元数据')),
                ('user_id', models.UUIDField(help_text='创建者ID')),
                ('department', models.CharField(blank=True, max_length=50)),
                ('char_length', models.IntegerField(blank=True, help_text='字符长度', null=True)),
                ('document_count', models.IntegerField(blank=True, help_text='文档数量', null=True)),
                ('application_mapping_count', models.IntegerField(default=0, help_text='应用映射数量')),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('update_time', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'user_data',
                'indexes': [models.Index(fields=['type', 'user_id'], name='user_data_type_37f45e_idx'), models.Index(fields=['create_time'], name='user_data_create__675afa_idx')],
            },
        ),
        migrations.CreateModel(
            name='KnowledgeBase',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('user_id', models.UUIDField(verbose_name='创建者ID')),
                ('name', models.CharField(max_length=100, unique=True, verbose_name='知识库名称')),
                ('desc', models.TextField(blank=True, null=True, verbose_name='知识库描述')),
                ('type', models.CharField(choices=[('admin', '管理级知识库'), ('leader', '部门级知识库'), ('member', '成员级知识库'), ('private', '私有知识库'), ('secret', '公司级别私密知识库')], default='private', max_length=20, verbose_name='知识库类型')),
                ('department', models.CharField(blank=True, max_length=50, null=True)),
                ('group', models.CharField(blank=True, max_length=50, null=True)),
                ('documents', models.JSONField(default=list)),
                ('char_length', models.IntegerField(default=0)),
                ('document_count', models.IntegerField(default=0)),
                ('external_id', models.UUIDField(blank=True, null=True)),
                ('create_time', models.DateTimeField(auto_now_add=True)),
                ('update_time', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'knowledge_bases',
                'indexes': [models.Index(fields=['type'], name='knowledge_b_type_0439e7_idx'), models.Index(fields=['department'], name='knowledge_b_departm_e739fd_idx'), models.Index(fields=['group'], name='knowledge_b_group_3dcf34_idx')],
            },
        ),
        migrations.CreateModel(
            name='Permission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('permissions', models.JSONField(default=dict, verbose_name='权限配置')),
                ('status', models.CharField(choices=[('pending', '待审批'), ('approved', '已批准'), ('rejected', '已拒绝')], default='pending', max_length=20, verbose_name='状态')),
                ('reason', models.TextField(verbose_name='申请原因')),
                ('response_message', models.TextField(blank=True, null=True, verbose_name='审批意见')),
                ('expires_at', models.DateTimeField(blank=True, null=True, verbose_name='过期时间')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
                ('applicant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='permission_applications', to=settings.AUTH_USER_MODEL, verbose_name='申请人')),
                ('approver', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='permission_approvals', to=settings.AUTH_USER_MODEL, verbose_name='审批人')),
                ('knowledge_base', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='permissions', to='user_management.knowledgebase', verbose_name='知识库')),
            ],
            options={
                'verbose_name': '权限申请',
                'verbose_name_plural': '权限申请',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='UserProfile',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('department', models.CharField(blank=True, help_text='部门', max_length=100)),
                ('group', models.CharField(blank=True, help_text='小组', max_length=100)),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'user_profiles',
            },
        ),
        migrations.CreateModel(
            name='ChatHistory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('conversation_id', models.CharField(db_index=True, max_length=100)),
                ('parent_id', models.CharField(blank=True, max_length=100, null=True)),
                ('role', models.CharField(choices=[('user', '用户'), ('assistant', 'AI助手'), ('system', '系统')], max_length=20)),
                ('content', models.TextField()),
                ('tokens', models.IntegerField(default=0, help_text='消息token数')),
                ('metadata', models.JSONField(blank=True, default=dict, help_text="\n    {\n        'model_id': 'xxx',\n        'dataset_id_list': ['id1', 'id2', ...],\n        'dataset_external_id_list': ['ext1', 'ext2', ...],\n        'primary_knowledge_base': 'id1'\n    }\n    ")),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('is_deleted', models.BooleanField(default=False)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('knowledge_base', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user_management.knowledgebase')),
            ],
            options={
                'db_table': 'chat_history',
                'ordering': ['created_at'],
                'indexes': [models.Index(fields=['conversation_id', 'created_at'], name='chat_histor_convers_33721a_idx'), models.Index(fields=['user', 'created_at'], name='chat_histor_user_id_aa050a_idx'), models.Index(fields=['conversation_id', 'is_deleted'], name='chat_histor_convers_89bc43_idx')],
            },
        ),
        migrations.CreateModel(
            name='KnowledgeBasePermission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('can_read', models.BooleanField(default=False, verbose_name='查看权限')),
                ('can_edit', models.BooleanField(default=False, verbose_name='修改权限')),
                ('can_delete', models.BooleanField(default=False, verbose_name='删除权限')),
                ('status', models.CharField(choices=[('active', '生效中'), ('expired', '已过期'), ('revoked', '已撤销')], default='active', max_length=10, verbose_name='状态')),
                ('granted_at', models.DateTimeField(auto_now_add=True, verbose_name='授权时间')),
                ('expires_at', models.DateTimeField(blank=True, null=True, verbose_name='过期时间')),
                ('granted_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='granted_permissions', to=settings.AUTH_USER_MODEL, verbose_name='授权人')),
                ('knowledge_base', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_permissions', to='user_management.knowledgebase', verbose_name='知识库')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='knowledge_base_permissions', to=settings.AUTH_USER_MODEL, verbose_name='用户')),
            ],
            options={
                'verbose_name': '知识库权限',
                'verbose_name_plural': '知识库权限',
                'db_table': 'knowledge_base_permissions',
                'indexes': [models.Index(fields=['knowledge_base', 'user', 'status'], name='knowledge_b_knowled_88e81e_idx')],
                'unique_together': {('knowledge_base', 'user')},
            },
        ),
        migrations.CreateModel(
            name='Notification',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('type', models.CharField(choices=[('permission_request', '权限申请'), ('permission_approved', '权限批准'), ('permission_rejected', '权限拒绝'), ('permission_expired', '权限过期'), ('system_notice', '系统通知')], max_length=20)),
                ('title', models.CharField(max_length=100)),
                ('content', models.TextField()),
                ('is_read', models.BooleanField(default=False)),
                ('related_resource', models.CharField(blank=True, max_length=100)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('receiver', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='received_notifications', to=settings.AUTH_USER_MODEL)),
                ('sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sent_notifications', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['receiver', '-created_at'], name='user_manage_receive_fcb0eb_idx'), models.Index(fields=['type', 'is_read'], name='user_manage_type_362052_idx')],
            },
        ),
    ]
