v0.0.9 - 寻配号功能稳定版

- 自有匹配:正常计算
- 网络匹配:使用缓存方式(数据库字段)
- 加载速度:0.06秒

News.jsx: 0.0.7 → 0.0.8
seek.py: 0.0.8 → 0.0.9
This commit is contained in:
甲辰生产 2026-04-24 14:34:01 +08:00
parent d1a245c340
commit a2e6d328f0
2 changed files with 14 additions and 15 deletions

View File

@ -1,6 +1,6 @@
# seek - 寻配号路由 # seek - 寻配号路由
# Version: 0.0.8 (2026-04-24) # Version: 0.0.9 (2026-04-24)
# 更新network_matched_count缓存到数据库创建时初始化点击时更新 # 稳定版:自有匹配+网络匹配缓存
from fastapi import APIRouter, Depends, Query, HTTPException from fastapi import APIRouter, Depends, Query, HTTPException
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
@ -104,16 +104,13 @@ def get_seek_list(
user_name = user.f01_01_name if user else '匿名用户' user_name = user.f01_01_name if user else '匿名用户'
# 构建响应(不实时计算网络匹配,网络匹配在点击时再查) # 构建响应(不实时计算网络匹配,网络匹配在点击时再查)
# 计算自有匹配数量网络匹配数量从数据库读取如为0则计算一次 # 网络匹配数量从数据库读取不再实时计算初始为0
matched_count = 0 network_matched_count = 0
network_matched_count = getattr(item, 'network_matched_count', 0) or 0 if hasattr(item, 'network_matched_count') and item.network_matched_count:
if network_matched_count == 0 and item.expect_number and len(item.expect_number) == 10: network_matched_count = item.network_matched_count
# 如果数据库中没有值,计算一次并保存
network_matched_count = match_collections_count_from_coolbot(item.expect_number)
# 更新数据库
item.network_matched_count = network_matched_count
db.commit()
# 自有匹配数量使用缓存方式如为0则计算一次
matched_count = 0
if item.expect_number and len(item.expect_number) == 10: if item.expect_number and len(item.expect_number) == 10:
if current_user and current_user.f99_90_id: if current_user and current_user.f99_90_id:
matched_count = match_collections_count(db, current_user.f99_90_id, item.expect_number) matched_count = match_collections_count(db, current_user.f99_90_id, item.expect_number)

View File

@ -1,7 +1,7 @@
/** /**
* News - 资讯列表页面 * News - 资讯列表页面
* Version: 0.0.7 (2026-04-24) * Version: 0.0.8 (2026-04-24)
* 更新network_matched_count缓存机制 * 稳定版自有匹配+网络匹配缓存
*/ */
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
@ -44,6 +44,8 @@ export default function News() {
const [matchCollections, setMatchCollections] = useState([]) const [matchCollections, setMatchCollections] = useState([])
const [networkMatchCollections, setNetworkMatchCollections] = useState([]) const [networkMatchCollections, setNetworkMatchCollections] = useState([])
const [showNetworkMatchList, setShowNetworkMatchList] = useState(false) const [showNetworkMatchList, setShowNetworkMatchList] = useState(false)
const [networkMatchInfoId, setNetworkMatchInfoId] = useState(null)
const [networkMatchTotalCount, setNetworkMatchTotalCount] = useState(0)
const [customModal, setCustomModal] = useState({show: false, title: '', content: ''}) const [customModal, setCustomModal] = useState({show: false, title: '', content: ''})
const [seekForm, setSeekForm] = useState({ const [seekForm, setSeekForm] = useState({
edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: getUserPhone() || '' edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: getUserPhone() || ''
@ -817,7 +819,7 @@ export default function News() {
> >
自有{item.matched_count || 0}条藏品匹配成功 自有{item.matched_count || 0}条藏品匹配成功
</span> </span>
{item.network_matched_count !== undefined && ( {item.network_matched_count !== undefined && item.network_matched_count > 0 && (
<span <span
style={{ color: '#3b82f6', fontSize: '13px', fontWeight: 'bold', cursor: 'pointer', marginLeft: '12px' }} style={{ color: '#3b82f6', fontSize: '13px', fontWeight: 'bold', cursor: 'pointer', marginLeft: '12px' }}
onClick={() => fetchNetworkMatchCollections(item.id)} onClick={() => fetchNetworkMatchCollections(item.id)}
@ -1058,7 +1060,7 @@ export default function News() {
<div style={{ position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, background: 'rgba(0,0,0,0.8)', zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center' }}> <div style={{ position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, background: 'rgba(0,0,0,0.8)', zIndex: 1000, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<div style={{ background: '#1e293b', borderRadius: '12px', padding: '20px', width: '90%', maxHeight: '80vh', overflow: 'auto' }}> <div style={{ background: '#1e293b', borderRadius: '12px', padding: '20px', width: '90%', maxHeight: '80vh', overflow: 'auto' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '16px' }}> <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '16px' }}>
<h3 style={{ color: '#fff', margin: 0 }}>匹配藏品清单网络数据</h3> <h3 style={{ color: '#fff', margin: 0 }}>匹配藏品清单网络数据{networkMatchTotalCount > 0 ? `${networkMatchTotalCount}` : ''}</h3>
<button onClick={() => setShowNetworkMatchList(false)} style={{ background: 'transparent', border: 'none', color: '#94a3b8', fontSize: '20px', cursor: 'pointer' }}>×</button> <button onClick={() => setShowNetworkMatchList(false)} style={{ background: 'transparent', border: 'none', color: '#94a3b8', fontSize: '20px', cursor: 'pointer' }}>×</button>
</div> </div>
{networkMatchCollections.length === 0 ? ( {networkMatchCollections.length === 0 ? (