From bc1485663e071feca327ebebeef1f2ba6edec592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Sun, 12 Apr 2026 00:42:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=97=B6=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=86=A0=E5=AD=97=E5=8F=B7=E4=B8=BA9=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/information.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/app/routers/information.py b/backend/app/routers/information.py index 1484998..1c2628b 100644 --- a/backend/app/routers/information.py +++ b/backend/app/routers/information.py @@ -452,6 +452,23 @@ def create_information( db: Session = Depends(get_db) ): """发布资讯""" + # 验证并矫正冠字号(J0开头的9位数字) + if data.title: + import re + # 提取冠字号 + match = re.search(r'J0(\d+)', data.title) + if match: + num = match.group(1) + # 矫正位数 + if len(num) > 9: + # 多位:取前9位 + num = num[:9] + elif len(num) < 9: + # 少位:前面补0 + num = num.zfill(9) + # 重新构建title + original_num = match.group(0) + data.title = data.title.replace(original_num, 'J0' + num, 1) # 生成行情编号:日期 + 5位自然数(从00001开始) deal_no = None if data.info_type == 'deal':