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:
parent
d1a245c340
commit
a2e6d328f0
|
|
@ -1,6 +1,6 @@
|
|||
# seek - 寻配号路由
|
||||
# Version: 0.0.8 (2026-04-24)
|
||||
# 更新:network_matched_count缓存到数据库,创建时初始化,点击时更新
|
||||
# Version: 0.0.9 (2026-04-24)
|
||||
# 稳定版:自有匹配+网络匹配缓存
|
||||
|
||||
from fastapi import APIRouter, Depends, Query, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
|
@ -104,16 +104,13 @@ def get_seek_list(
|
|||
user_name = user.f01_01_name if user else '匿名用户'
|
||||
|
||||
# 构建响应(不实时计算网络匹配,网络匹配在点击时再查)
|
||||
# 计算自有匹配数量,网络匹配数量从数据库读取(如为0则计算一次)
|
||||
matched_count = 0
|
||||
network_matched_count = getattr(item, 'network_matched_count', 0) or 0
|
||||
if network_matched_count == 0 and item.expect_number and len(item.expect_number) == 10:
|
||||
# 如果数据库中没有值,计算一次并保存
|
||||
network_matched_count = match_collections_count_from_coolbot(item.expect_number)
|
||||
# 更新数据库
|
||||
item.network_matched_count = network_matched_count
|
||||
db.commit()
|
||||
# 网络匹配数量从数据库读取(不再实时计算,初始为0)
|
||||
network_matched_count = 0
|
||||
if hasattr(item, 'network_matched_count') and item.network_matched_count:
|
||||
network_matched_count = item.network_matched_count
|
||||
|
||||
# 自有匹配数量(使用缓存方式,如为0则计算一次)
|
||||
matched_count = 0
|
||||
if item.expect_number and len(item.expect_number) == 10:
|
||||
if current_user and current_user.f99_90_id:
|
||||
matched_count = match_collections_count(db, current_user.f99_90_id, item.expect_number)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* News - 资讯列表页面
|
||||
* Version: 0.0.7 (2026-04-24)
|
||||
* 更新:network_matched_count缓存机制
|
||||
* Version: 0.0.8 (2026-04-24)
|
||||
* 稳定版:自有匹配+网络匹配缓存
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react'
|
||||
|
|
@ -44,6 +44,8 @@ export default function News() {
|
|||
const [matchCollections, setMatchCollections] = useState([])
|
||||
const [networkMatchCollections, setNetworkMatchCollections] = useState([])
|
||||
const [showNetworkMatchList, setShowNetworkMatchList] = useState(false)
|
||||
const [networkMatchInfoId, setNetworkMatchInfoId] = useState(null)
|
||||
const [networkMatchTotalCount, setNetworkMatchTotalCount] = useState(0)
|
||||
const [customModal, setCustomModal] = useState({show: false, title: '', content: ''})
|
||||
const [seekForm, setSeekForm] = useState({
|
||||
edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: getUserPhone() || ''
|
||||
|
|
@ -817,7 +819,7 @@ export default function News() {
|
|||
>
|
||||
自有{item.matched_count || 0}条藏品匹配成功
|
||||
</span>
|
||||
{item.network_matched_count !== undefined && (
|
||||
{item.network_matched_count !== undefined && item.network_matched_count > 0 && (
|
||||
<span
|
||||
style={{ color: '#3b82f6', fontSize: '13px', fontWeight: 'bold', cursor: 'pointer', marginLeft: '12px' }}
|
||||
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={{ background: '#1e293b', borderRadius: '12px', padding: '20px', width: '90%', maxHeight: '80vh', overflow: 'auto' }}>
|
||||
<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>
|
||||
</div>
|
||||
{networkMatchCollections.length === 0 ? (
|
||||
|
|
|
|||
Loading…
Reference in New Issue