1
0
forked from erp-dev/erp

feat: upload mdy stagging to qiniu beta

This commit is contained in:
2026-06-28 22:19:02 +08:00
parent cc4607725c
commit 5f182db148
7 changed files with 1004 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
# Generated by Codex on 2026-06-28
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api_v1', '0015_alter_apiauditlog_method_and_more'),
]
operations = [
migrations.CreateModel(
name='MDYPlateOrderStagingQiniuImageUploadAudit',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
('updated_at', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
('mdy_rowid', models.CharField(db_index=True, max_length=64, verbose_name='明道云 RowID')),
(
'source',
models.CharField(
choices=[('raw_plate_images', 'raw.开版图')],
default='raw_plate_images',
max_length=50,
verbose_name='图片来源',
),
),
('attachment_index', models.PositiveIntegerField(verbose_name='附件序号')),
('source_field', models.CharField(blank=True, max_length=64, verbose_name='原始 URL 字段')),
('original_url', models.URLField(max_length=2048, verbose_name='原始图片 URL')),
('original_host', models.CharField(blank=True, db_index=True, max_length=255, verbose_name='原始图片域名')),
('qiniu_key', models.CharField(blank=True, max_length=500, verbose_name='七牛对象 Key')),
('qiniu_url', models.URLField(blank=True, max_length=2048, verbose_name='七牛图片 URL')),
(
'status',
models.CharField(
choices=[
('pending', '待处理'),
('processing', '处理中'),
('success', '成功'),
('failed', '失败'),
('skipped', '跳过'),
],
db_index=True,
default='pending',
max_length=20,
verbose_name='上传状态',
),
),
('attempts', models.PositiveIntegerField(default=0, verbose_name='尝试次数')),
('error', models.TextField(blank=True, verbose_name='错误信息')),
('file_size', models.PositiveBigIntegerField(blank=True, null=True, verbose_name='文件大小')),
('content_type', models.CharField(blank=True, max_length=100, verbose_name='Content-Type')),
('raw_attachment', models.JSONField(blank=True, default=dict, verbose_name='原始附件快照')),
('started_at', models.DateTimeField(blank=True, null=True, verbose_name='开始处理时间')),
('uploaded_at', models.DateTimeField(blank=True, null=True, verbose_name='上传成功时间')),
('last_attempt_at', models.DateTimeField(blank=True, null=True, verbose_name='最后尝试时间')),
(
'staging',
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name='qiniu_image_upload_audits',
to='api_v1.mdyplateorderstaging',
verbose_name='开版暂存记录',
),
),
],
options={
'verbose_name': '开版暂存开版图七牛上传审计',
'verbose_name_plural': '开版暂存开版图七牛上传审计',
'db_table': 'api_mdy_plate_order_staging_qiniu_image_upload_audit',
'ordering': ['-created_at'],
},
),
migrations.AddConstraint(
model_name='mdyplateorderstagingqiniuimageuploadaudit',
constraint=models.UniqueConstraint(
fields=('staging', 'source', 'attachment_index', 'source_field', 'original_url'),
name='uniq_mdy_qiniu_staging_src_idx_url',
),
),
migrations.AddIndex(
model_name='mdyplateorderstagingqiniuimageuploadaudit',
index=models.Index(fields=['status', 'id'], name='mdy_qiniu_status_id_idx'),
),
migrations.AddIndex(
model_name='mdyplateorderstagingqiniuimageuploadaudit',
index=models.Index(fields=['original_url'], name='mdy_qiniu_orig_url_idx'),
),
migrations.AddIndex(
model_name='mdyplateorderstagingqiniuimageuploadaudit',
index=models.Index(fields=['staging', 'source'], name='mdy_qiniu_staging_src_idx'),
),
]