清理:注释information.py中废弃的seek/deal重复端点
已废弃并注释的端点(统一使用 /api/seek/* 或 /api/deal/*):
- /information/seek/match → /api/seek/my-match
- /information/seek/network-match/{id} → /api/seek/network-match/{id}
- /information/my-seeks → /api/seek/list
- /information/seek/match-confirm → /api/seek/match-confirm
- /information/seek/matched-user/{id} → /api/seek/matched-user/{id}
- /information/seek/publisher/{id} → /api/seek/publisher/{id}
- /information/seek/stats → /api/seek/stats
- /information/deal/stats → /api/deal/stats
注意:评论相关端点保留(comment, comments),表为空但代码存在
This commit is contained in:
parent
41b3353613
commit
7100f2d40e
|
|
@ -636,183 +636,183 @@ def delete_information(
|
||||||
|
|
||||||
|
|
||||||
# 寻配号 - 自动匹配推荐藏品
|
# 寻配号 - 自动匹配推荐藏品
|
||||||
@router.get("/seek/match")
|
# DEPRECATED (use /api/seek/*): @router.get("/seek/match")
|
||||||
def get_seek_match(
|
# DEPRECATED: def get_seek_match(
|
||||||
info_id: str,
|
# DEPRECATED: info_id: str,
|
||||||
current_user: Optional[User] = Depends(get_current_user),
|
# DEPRECATED: current_user: Optional[User] = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""获取符合条件的我的藏品推荐"""
|
# DEPRECATED: """获取符合条件的我的藏品推荐"""
|
||||||
if not current_user:
|
# DEPRECATED: if not current_user:
|
||||||
raise HTTPException(status_code=401, detail="请先登录")
|
# DEPRECATED: raise HTTPException(status_code=401, detail="请先登录")
|
||||||
|
# DEPRECATED:
|
||||||
# 先查 information 表
|
# 先查 information 表
|
||||||
info = db.query(Information).filter(
|
# DEPRECATED: info = db.query(Information).filter(
|
||||||
Information.id == info_id,
|
# DEPRECATED: Information.id == info_id,
|
||||||
Information.info_type == "seek"
|
# DEPRECATED: Information.info_type == "seek"
|
||||||
).first()
|
# DEPRECATED: ).first()
|
||||||
|
# DEPRECATED:
|
||||||
# 如果 information 表没有,尝试 seek_info 表
|
# 如果 information 表没有,尝试 seek_info 表
|
||||||
if not info:
|
# DEPRECATED: if not info:
|
||||||
from app.models.seek_info import SeekInfo
|
# DEPRECATED: from app.models.seek_info import SeekInfo
|
||||||
info = db.query(SeekInfo).filter(SeekInfo.id == info_id).first()
|
# DEPRECATED: info = db.query(SeekInfo).filter(SeekInfo.id == info_id).first()
|
||||||
|
# DEPRECATED:
|
||||||
if not info:
|
# DEPRECATED: if not info:
|
||||||
raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
# DEPRECATED: raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
||||||
|
# DEPRECATED:
|
||||||
# 更新用户配号(寻号)次数
|
# 更新用户配号(寻号)次数
|
||||||
current_user.f99_96_search_count = (current_user.f99_96_search_count or 0) + 1
|
# DEPRECATED: current_user.f99_96_search_count = (current_user.f99_96_search_count or 0) + 1
|
||||||
db.commit()
|
# DEPRECATED: db.commit()
|
||||||
|
# DEPRECATED:
|
||||||
# 获取用户所有藏品
|
# 获取用户所有藏品
|
||||||
collections = db.query(Collection).filter(
|
# DEPRECATED: collections = db.query(Collection).filter(
|
||||||
Collection.f99_91_user_id == current_user.f99_90_id,
|
# DEPRECATED: Collection.f99_91_user_id == current_user.f99_90_id,
|
||||||
Collection.f01_04_status == "in_collection"
|
# DEPRECATED: Collection.f01_04_status == "in_collection"
|
||||||
).all()
|
# DEPRECATED: ).all()
|
||||||
|
# DEPRECATED:
|
||||||
# 去掉版别筛选,因为藏品分类和发布需求的版别不同
|
# 去掉版别筛选,因为藏品分类和发布需求的版别不同
|
||||||
# if info.expect_category:
|
# if info.expect_category:
|
||||||
# collections = [c for c in collections if c.f01_03_category == info.expect_category]
|
# collections = [c for c in collections if c.f01_03_category == info.expect_category]
|
||||||
|
# DEPRECATED:
|
||||||
# 按号码特征模式匹配
|
# 按号码特征模式匹配
|
||||||
matched = []
|
# DEPRECATED: matched = []
|
||||||
if info.expect_number and len(info.expect_number) == 10:
|
# DEPRECATED: if info.expect_number and len(info.expect_number) == 10:
|
||||||
pattern = info.expect_number[2:] # 后8位
|
# DEPRECATED: pattern = info.expect_number[2:] # 后8位
|
||||||
for c in collections:
|
# DEPRECATED: for c in collections:
|
||||||
number = c.f02_10_prefix_serial or ''
|
# DEPRECATED: number = c.f02_10_prefix_serial or ''
|
||||||
# 去掉J0前缀后取前8位
|
# 去掉J0前缀后取前8位
|
||||||
if len(number) >= 10 and number.startswith('J0'):
|
# DEPRECATED: if len(number) >= 10 and number.startswith('J0'):
|
||||||
col_pattern = number[2:10] # 取J0后面的8位
|
# DEPRECATED: col_pattern = number[2:10] # 取J0后面的8位
|
||||||
if match_pattern(col_pattern, pattern):
|
# DEPRECATED: if match_pattern(col_pattern, pattern):
|
||||||
matched.append(c)
|
# DEPRECATED: matched.append(c)
|
||||||
elif len(number) >= 8:
|
# DEPRECATED: elif len(number) >= 8:
|
||||||
col_pattern = number[:8] # 取前8位
|
# DEPRECATED: col_pattern = number[:8] # 取前8位
|
||||||
if match_pattern(col_pattern, pattern):
|
# DEPRECATED: if match_pattern(col_pattern, pattern):
|
||||||
matched.append(c)
|
# DEPRECATED: matched.append(c)
|
||||||
else:
|
# DEPRECATED: else:
|
||||||
matched = collections
|
# DEPRECATED: matched = collections
|
||||||
|
# DEPRECATED:
|
||||||
return {
|
# DEPRECATED: return {
|
||||||
"info_id": info_id,
|
# DEPRECATED: "info_id": info_id,
|
||||||
"matched_count": len(matched),
|
# DEPRECATED: "matched_count": len(matched),
|
||||||
"collections": [
|
# DEPRECATED: "collections": [
|
||||||
{
|
# DEPRECATED: {
|
||||||
"id": c.f99_90_id,
|
# DEPRECATED: "id": c.f99_90_id,
|
||||||
"code": c.f01_02_code or '',
|
# DEPRECATED: "code": c.f01_02_code or '',
|
||||||
"name": c.f01_01_name,
|
# DEPRECATED: "name": c.f01_01_name,
|
||||||
"number": c.f02_10_prefix_serial,
|
# DEPRECATED: "number": c.f02_10_prefix_serial,
|
||||||
"status": c.f01_04_status,
|
# DEPRECATED: "status": c.f01_04_status,
|
||||||
"category": c.f01_03_category,
|
# DEPRECATED: "category": c.f01_03_category,
|
||||||
"version": c.f02_11_version,
|
# DEPRECATED: "version": c.f02_11_version,
|
||||||
"packaging": c.f02_12_packaging,
|
# DEPRECATED: "packaging": c.f02_12_packaging,
|
||||||
"cost_price": c.f05_40_cost_price,
|
# DEPRECATED: "cost_price": c.f05_40_cost_price,
|
||||||
}
|
# DEPRECATED: }
|
||||||
for c in matched
|
# DEPRECATED: for c in matched
|
||||||
],
|
# DEPRECATED: ],
|
||||||
"network_matched_count": match_collections_count_from_coolbot(info.expect_number) if info.expect_number else 0,
|
# DEPRECATED: "network_matched_count": match_collections_count_from_coolbot(info.expect_number) if info.expect_number else 0,
|
||||||
"network_collections": match_collections_list_from_coolbot(info.expect_number, limit=20) if info.expect_number else []
|
# DEPRECATED: "network_collections": match_collections_list_from_coolbot(info.expect_number, limit=20) if info.expect_number else []
|
||||||
}
|
# DEPRECATED: }
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
# 获取网络数据匹配列表
|
# 获取网络数据匹配列表
|
||||||
@router.get("/seek/network-match/{info_id}")
|
# DEPRECATED (use /api/seek/*): @router.get("/seek/network-match/{info_id}")
|
||||||
def get_network_match(
|
# DEPRECATED: def get_network_match(
|
||||||
info_id: str,
|
# DEPRECATED: info_id: str,
|
||||||
limit: int = Query(20, ge=1, le=100),
|
# DEPRECATED: limit: int = Query(20, ge=1, le=100),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""获取一尘数据库中匹配的藏品列表"""
|
# DEPRECATED: """获取一尘数据库中匹配的藏品列表"""
|
||||||
info = db.query(Information).filter(
|
# DEPRECATED: info = db.query(Information).filter(
|
||||||
Information.id == info_id,
|
# DEPRECATED: Information.id == info_id,
|
||||||
Information.info_type == "seek"
|
# DEPRECATED: Information.info_type == "seek"
|
||||||
).first()
|
# DEPRECATED: ).first()
|
||||||
|
# DEPRECATED:
|
||||||
if not info:
|
# DEPRECATED: if not info:
|
||||||
raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
# DEPRECATED: raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
||||||
|
# DEPRECATED:
|
||||||
if not info.expect_number:
|
# DEPRECATED: if not info.expect_number:
|
||||||
return {"matched_count": 0, "collections": []}
|
# DEPRECATED: return {"matched_count": 0, "collections": []}
|
||||||
|
# DEPRECATED:
|
||||||
matched = match_collections_list_from_coolbot(info.expect_number, limit=limit)
|
# DEPRECATED: matched = match_collections_list_from_coolbot(info.expect_number, limit=limit)
|
||||||
|
# DEPRECATED:
|
||||||
return {
|
# DEPRECATED: return {
|
||||||
"matched_count": len(matched),
|
# DEPRECATED: "matched_count": len(matched),
|
||||||
"collections": matched
|
# DEPRECATED: "collections": matched
|
||||||
}
|
# DEPRECATED: }
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
# 我的寻号列表
|
# 我的寻号列表
|
||||||
@router.get("/my-seeks")
|
# DEPRECATED (use /api/seek/*): @router.get("/my-seeks")
|
||||||
def get_my_seeks(
|
# DEPRECATED: def get_my_seeks(
|
||||||
current_user: Optional[User] = Depends(get_current_user),
|
# DEPRECATED: current_user: Optional[User] = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""获取当前用户发布的所有寻号信息"""
|
# DEPRECATED: """获取当前用户发布的所有寻号信息"""
|
||||||
if not current_user:
|
# DEPRECATED: if not current_user:
|
||||||
raise HTTPException(status_code=401, detail="请先登录")
|
# DEPRECATED: raise HTTPException(status_code=401, detail="请先登录")
|
||||||
|
# DEPRECATED:
|
||||||
items = db.query(Information).filter(
|
# DEPRECATED: items = db.query(Information).filter(
|
||||||
Information.user_id == current_user.f99_90_id,
|
# DEPRECATED: Information.user_id == current_user.f99_90_id,
|
||||||
Information.info_type == "seek",
|
# DEPRECATED: Information.info_type == "seek",
|
||||||
Information.status == "active"
|
# DEPRECATED: Information.status == "active"
|
||||||
).order_by(Information.created_at.desc()).all()
|
# DEPRECATED: ).order_by(Information.created_at.desc()).all()
|
||||||
|
# DEPRECATED:
|
||||||
result = []
|
# DEPRECATED: result = []
|
||||||
for item in items:
|
# DEPRECATED: for item in items:
|
||||||
# 计算匹配数量
|
# 计算匹配数量
|
||||||
matched_count = 0
|
# DEPRECATED: matched_count = 0
|
||||||
if item.expect_number:
|
# DEPRECATED: if item.expect_number:
|
||||||
matched_count = match_collections_count(db, current_user.f99_90_id, item.expect_number)
|
# DEPRECATED: matched_count = match_collections_count(db, current_user.f99_90_id, item.expect_number)
|
||||||
|
# DEPRECATED:
|
||||||
result.append(InformationResponse(
|
# DEPRECATED: result.append(InformationResponse(
|
||||||
id=item.id,
|
# DEPRECATED: id=item.id,
|
||||||
user_id=item.user_id,
|
# DEPRECATED: user_id=item.user_id,
|
||||||
info_type=item.info_type,
|
# DEPRECATED: info_type=item.info_type,
|
||||||
title=item.title,
|
# DEPRECATED: title=item.title,
|
||||||
content=item.content,
|
# DEPRECATED: content=item.content,
|
||||||
collection_id=item.collection_id,
|
# DEPRECATED: collection_id=item.collection_id,
|
||||||
expect_category=item.expect_category,
|
# DEPRECATED: expect_category=item.expect_category,
|
||||||
expect_version=item.expect_version,
|
# DEPRECATED: expect_version=item.expect_version,
|
||||||
expect_packaging=item.expect_packaging,
|
# DEPRECATED: expect_packaging=item.expect_packaging,
|
||||||
expect_number=item.expect_number,
|
# DEPRECATED: expect_number=item.expect_number,
|
||||||
expect_price_min=item.expect_price_min,
|
# DEPRECATED: expect_price_min=item.expect_price_min,
|
||||||
expect_price_max=item.expect_price_max,
|
# DEPRECATED: expect_price_max=item.expect_price_max,
|
||||||
deal_price=item.deal_price,
|
# DEPRECATED: deal_price=item.deal_price,
|
||||||
deal_date=item.deal_date,
|
# DEPRECATED: deal_date=item.deal_date,
|
||||||
status=item.status,
|
# DEPRECATED: status=item.status,
|
||||||
is_matched=item.is_matched,
|
# DEPRECATED: is_matched=item.is_matched,
|
||||||
matched_user_id=item.matched_user_id,
|
# DEPRECATED: matched_user_id=item.matched_user_id,
|
||||||
matched_contact=item.matched_contact,
|
# DEPRECATED: matched_contact=item.matched_contact,
|
||||||
view_count=item.view_count,
|
# DEPRECATED: view_count=item.view_count,
|
||||||
contact_count=item.contact_count,
|
# DEPRECATED: contact_count=item.contact_count,
|
||||||
created_at=item.created_at,
|
# DEPRECATED: created_at=item.created_at,
|
||||||
user_name=item.user.f01_01_name if item.user else None,
|
# DEPRECATED: user_name=item.user.f01_01_name if item.user else None,
|
||||||
user_avatar=item.user.avatar if item.user else None,
|
# DEPRECATED: user_avatar=item.user.avatar if item.user else None,
|
||||||
collection_name=item.collection.f01_01_name if item.collection else None,
|
# DEPRECATED: collection_name=item.collection.f01_01_name if item.collection else None,
|
||||||
collection_category=item.collection.f01_03_category if item.collection else None,
|
# DEPRECATED: collection_category=item.collection.f01_03_category if item.collection else None,
|
||||||
collection_version=item.collection.f02_11_version if item.collection else None,
|
# DEPRECATED: collection_version=item.collection.f02_11_version if item.collection else None,
|
||||||
collection_number=item.collection.f02_10_prefix_serial if item.collection else None,
|
# DEPRECATED: collection_number=item.collection.f02_10_prefix_serial if item.collection else None,
|
||||||
matched_count=matched_count,
|
# DEPRECATED: matched_count=matched_count,
|
||||||
network_matched_count=match_collections_count_from_coolbot(item.expect_number) if item.info_type == 'seek' and item.expect_number else 0,
|
# DEPRECATED: network_matched_count=match_collections_count_from_coolbot(item.expect_number) if item.info_type == 'seek' and item.expect_number else 0,
|
||||||
))
|
# DEPRECATED: ))
|
||||||
|
# DEPRECATED:
|
||||||
# 获取总数并设置响应头
|
# 获取总数并设置响应头
|
||||||
from fastapi import Response
|
# DEPRECATED: from fastapi import Response
|
||||||
total_query = db.query(Information).filter(Information.status == status)
|
# DEPRECATED: total_query = db.query(Information).filter(Information.status == status)
|
||||||
if info_type:
|
# DEPRECATED: if info_type:
|
||||||
total_query = total_query.filter(Information.info_type == info_type)
|
# DEPRECATED: total_query = total_query.filter(Information.info_type == info_type)
|
||||||
total_count = total_query.count()
|
# DEPRECATED: total_count = total_query.count()
|
||||||
total_pages = (total_count + page_size - 1) // page_size
|
# DEPRECATED: total_pages = (total_count + page_size - 1) // page_size
|
||||||
|
# DEPRECATED:
|
||||||
# 设置响应头
|
# 设置响应头
|
||||||
response.headers['X-Total-Pages'] = str(total_pages)
|
# DEPRECATED: response.headers['X-Total-Pages'] = str(total_pages)
|
||||||
response.headers['X-Total-Count'] = str(total_count)
|
# DEPRECATED: response.headers['X-Total-Count'] = str(total_count)
|
||||||
|
# DEPRECATED:
|
||||||
return result
|
# DEPRECATED: return result
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
# 成交数据统计
|
# 成交数据统计
|
||||||
@router.get("/deal/stats")
|
# DEPRECATED (use /api/deal/stats): @router.get("/deal/stats")
|
||||||
def get_deal_stats(
|
def get_deal_stats(
|
||||||
days: int = Query(7, ge=1, le=90, description="统计天数"),
|
days: int = Query(7, ge=1, le=90, description="统计天数"),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
|
|
@ -959,49 +959,49 @@ class MatchSeekRequest(BaseModel):
|
||||||
contact: Optional[str] = None
|
contact: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@router.post("/seek/match-confirm")
|
# DEPRECATED (use /api/seek/*): @router.post("/seek/match-confirm")
|
||||||
def match_seek(
|
# DEPRECATED: def match_seek(
|
||||||
request: MatchSeekRequest,
|
# DEPRECATED: request: MatchSeekRequest,
|
||||||
current_user: User = Depends(get_current_user),
|
# DEPRECATED: current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""确认匹配寻号 - 用户愿意交换联系方式给发布者"""
|
# DEPRECATED: """确认匹配寻号 - 用户愿意交换联系方式给发布者"""
|
||||||
info = db.query(Information).filter(
|
# DEPRECATED: info = db.query(Information).filter(
|
||||||
Information.id == request.info_id,
|
# DEPRECATED: Information.id == request.info_id,
|
||||||
Information.info_type == "seek",
|
# DEPRECATED: Information.info_type == "seek",
|
||||||
Information.status == "active"
|
# DEPRECATED: Information.status == "active"
|
||||||
).first()
|
# DEPRECATED: ).first()
|
||||||
|
# DEPRECATED:
|
||||||
if not info:
|
# DEPRECATED: if not info:
|
||||||
raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
# DEPRECATED: raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
||||||
|
# DEPRECATED:
|
||||||
# 检查是否已被匹配(一个寻号只能被一个用户匹配)
|
# 检查是否已被匹配(一个寻号只能被一个用户匹配)
|
||||||
if info.is_matched == "matched":
|
# DEPRECATED: if info.is_matched == "matched":
|
||||||
raise HTTPException(status_code=400, detail="该寻号已被其他用户匹配")
|
# DEPRECATED: raise HTTPException(status_code=400, detail="该寻号已被其他用户匹配")
|
||||||
|
# DEPRECATED:
|
||||||
# 更新匹配状态
|
# 更新匹配状态
|
||||||
info.is_matched = "matched"
|
# DEPRECATED: info.is_matched = "matched"
|
||||||
info.matched_user_id = current_user.f99_90_id
|
# DEPRECATED: info.matched_user_id = current_user.f99_90_id
|
||||||
# 保存匹配者的联系方式
|
# 保存匹配者的联系方式
|
||||||
info.matched_contact = request.contact or ''
|
# DEPRECATED: info.matched_contact = request.contact or ''
|
||||||
|
# DEPRECATED:
|
||||||
# 更新发布寻号者的内容,显示有藏品被匹配
|
# 更新发布寻号者的内容,显示有藏品被匹配
|
||||||
original_content = info.content or ""
|
# DEPRECATED: original_content = info.content or ""
|
||||||
# 添加匹配信息:藏品被XX藏友匹配,联系方式为:xxx
|
# 添加匹配信息:藏品被XX藏友匹配,联系方式为:xxx
|
||||||
match_info = f"\n藏品被{current_user.f01_01_name}匹配成功!联系方式:{request.collection_id or '已交换'}"
|
# DEPRECATED: match_info = f"\n藏品被{current_user.f01_01_name}匹配成功!联系方式:{request.collection_id or '已交换'}"
|
||||||
info.content = original_content + match_info
|
# DEPRECATED: info.content = original_content + match_info
|
||||||
|
# DEPRECATED:
|
||||||
db.commit()
|
# DEPRECATED: db.commit()
|
||||||
|
# DEPRECATED:
|
||||||
return {"message": "匹配成功,已通知发布者", "is_matched": "matched"}
|
# DEPRECATED: return {"message": "匹配成功,已通知发布者", "is_matched": "matched"}
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
# ============ 添加留言 ============
|
# ============ 添加留言 ============
|
||||||
class CommentRequest(BaseModel):
|
# DEPRECATED: class CommentRequest(BaseModel):
|
||||||
information_id: str
|
# DEPRECATED: information_id: str
|
||||||
content: str
|
# DEPRECATED: content: str
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
@router.post("/comment")
|
@router.post("/comment")
|
||||||
def add_comment(
|
def add_comment(
|
||||||
request: CommentRequest,
|
request: CommentRequest,
|
||||||
|
|
@ -1063,84 +1063,84 @@ def get_comments(
|
||||||
|
|
||||||
|
|
||||||
# ============ 获取匹配者信息 ============
|
# ============ 获取匹配者信息 ============
|
||||||
@router.get("/seek/matched-user/{info_id}")
|
# DEPRECATED (use /api/seek/*): @router.get("/seek/matched-user/{info_id}")
|
||||||
def get_matched_user(
|
# DEPRECATED: def get_matched_user(
|
||||||
info_id: str,
|
# DEPRECATED: info_id: str,
|
||||||
current_user: User = Depends(get_current_user),
|
# DEPRECATED: current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""获取寻号的匹配者信息(仅发布者可见)"""
|
# DEPRECATED: """获取寻号的匹配者信息(仅发布者可见)"""
|
||||||
info = db.query(Information).filter(
|
# DEPRECATED: info = db.query(Information).filter(
|
||||||
Information.id == info_id,
|
# DEPRECATED: Information.id == info_id,
|
||||||
Information.info_type == "seek"
|
# DEPRECATED: Information.info_type == "seek"
|
||||||
).first()
|
# DEPRECATED: ).first()
|
||||||
|
# DEPRECATED:
|
||||||
if not info:
|
# DEPRECATED: if not info:
|
||||||
raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
# DEPRECATED: raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
||||||
|
# DEPRECATED:
|
||||||
# 只有发布者可以看到匹配者信息
|
# 只有发布者可以看到匹配者信息
|
||||||
if info.user_id != current_user.f99_90_id:
|
# DEPRECATED: if info.user_id != current_user.f99_90_id:
|
||||||
raise HTTPException(status_code=403, detail="无权访问")
|
# DEPRECATED: raise HTTPException(status_code=403, detail="无权访问")
|
||||||
|
# DEPRECATED:
|
||||||
if not info.matched_user_id:
|
# DEPRECATED: if not info.matched_user_id:
|
||||||
return {"message": "暂无匹配者"}
|
# DEPRECATED: return {"message": "暂无匹配者"}
|
||||||
|
# DEPRECATED:
|
||||||
# 获取匹配者信息
|
# 获取匹配者信息
|
||||||
matched_user = db.query(User).filter(User.f99_90_id == info.matched_user_id).first()
|
# DEPRECATED: matched_user = db.query(User).filter(User.f99_90_id == info.matched_user_id).first()
|
||||||
if not matched_user:
|
# DEPRECATED: if not matched_user:
|
||||||
return {"message": "匹配者不存在"}
|
# DEPRECATED: return {"message": "匹配者不存在"}
|
||||||
|
# DEPRECATED:
|
||||||
return {
|
# DEPRECATED: return {
|
||||||
"matched_user_id": info.matched_user_id,
|
# DEPRECATED: "matched_user_id": info.matched_user_id,
|
||||||
"user_name": matched_user.f01_01_name,
|
# DEPRECATED: "user_name": matched_user.f01_01_name,
|
||||||
"phone": matched_user.phone,
|
# DEPRECATED: "phone": matched_user.phone,
|
||||||
"matched_contact": info.matched_contact,
|
# DEPRECATED: "matched_contact": info.matched_contact,
|
||||||
"matched_at": info.updated_at.isoformat() if info.updated_at else None
|
# DEPRECATED: "matched_at": info.updated_at.isoformat() if info.updated_at else None
|
||||||
}
|
# DEPRECATED: }
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
# ============ 获取发布者信息 ============
|
# ============ 获取发布者信息 ============
|
||||||
@router.get("/seek/publisher/{info_id}")
|
# DEPRECATED (use /api/seek/*): @router.get("/seek/publisher/{info_id}")
|
||||||
def get_publisher_info(
|
# DEPRECATED: def get_publisher_info(
|
||||||
info_id: str,
|
# DEPRECATED: info_id: str,
|
||||||
current_user: User = Depends(get_current_user),
|
# DEPRECATED: current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""获取寻号的发布者信息(仅匹配者可见)"""
|
# DEPRECATED: """获取寻号的发布者信息(仅匹配者可见)"""
|
||||||
info = db.query(Information).filter(
|
# DEPRECATED: info = db.query(Information).filter(
|
||||||
Information.id == info_id,
|
# DEPRECATED: Information.id == info_id,
|
||||||
Information.info_type == "seek"
|
# DEPRECATED: Information.info_type == "seek"
|
||||||
).first()
|
# DEPRECATED: ).first()
|
||||||
|
# DEPRECATED:
|
||||||
if not info:
|
# DEPRECATED: if not info:
|
||||||
raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
# DEPRECATED: raise HTTPException(status_code=404, detail="寻配号信息不存在")
|
||||||
|
# DEPRECATED:
|
||||||
# 只有匹配者可以看到发布者信息
|
# 只有匹配者可以看到发布者信息
|
||||||
if not info.matched_user_id or info.matched_user_id != current_user.f99_90_id:
|
# DEPRECATED: if not info.matched_user_id or info.matched_user_id != current_user.f99_90_id:
|
||||||
raise HTTPException(status_code=403, detail="无权访问")
|
# DEPRECATED: raise HTTPException(status_code=403, detail="无权访问")
|
||||||
|
# DEPRECATED:
|
||||||
# 获取发布者信息
|
# 获取发布者信息
|
||||||
publisher = db.query(User).filter(User.f99_90_id == info.user_id).first()
|
# DEPRECATED: publisher = db.query(User).filter(User.f99_90_id == info.user_id).first()
|
||||||
if not publisher:
|
# DEPRECATED: if not publisher:
|
||||||
return {"message": "发布者不存在"}
|
# DEPRECATED: return {"message": "发布者不存在"}
|
||||||
|
# DEPRECATED:
|
||||||
# 从content中解析联系方式
|
# 从content中解析联系方式
|
||||||
contact = ''
|
# DEPRECATED: contact = ''
|
||||||
if info.content:
|
# DEPRECATED: if info.content:
|
||||||
import re
|
# DEPRECATED: import re
|
||||||
match = re.search(r'联系方式[:\s]*(.+?)(?:\n|$)', info.content)
|
# DEPRECATED: match = re.search(r'联系方式[:\s]*(.+?)(?:\n|$)', info.content)
|
||||||
if match:
|
# DEPRECATED: if match:
|
||||||
contact = match.group(1).strip()
|
# DEPRECATED: contact = match.group(1).strip()
|
||||||
|
# DEPRECATED:
|
||||||
return {
|
# DEPRECATED: return {
|
||||||
"user_id": info.user_id,
|
# DEPRECATED: "user_id": info.user_id,
|
||||||
"user_name": publisher.f01_01_name,
|
# DEPRECATED: "user_name": publisher.f01_01_name,
|
||||||
"phone": publisher.phone,
|
# DEPRECATED: "phone": publisher.phone,
|
||||||
"contact": contact,
|
# DEPRECATED: "contact": contact,
|
||||||
"created_at": info.created_at.isoformat() if info.created_at else None
|
# DEPRECATED: "created_at": info.created_at.isoformat() if info.created_at else None
|
||||||
}
|
# DEPRECATED: }
|
||||||
|
# DEPRECATED:
|
||||||
|
# DEPRECATED:
|
||||||
@router.get("/yichen-posts")
|
@router.get("/yichen-posts")
|
||||||
def get_yichen_posts(category: str = None, search: str = None, page: int = 1, page_size: int = 20):
|
def get_yichen_posts(category: str = None, search: str = None, page: int = 1, page_size: int = 20):
|
||||||
from app.models.models import Information
|
from app.models.models import Information
|
||||||
|
|
@ -1156,59 +1156,59 @@ def get_yichen_posts(category: str = None, search: str = None, page: int = 1, pa
|
||||||
return {"data": items, "pagination": {"page": page, "limit": page_size, "total": total}}
|
return {"data": items, "pagination": {"page": page, "limit": page_size, "total": total}}
|
||||||
|
|
||||||
|
|
||||||
@router.get("/seek/stats")
|
# DEPRECATED (use /api/seek/*): @router.get("/seek/stats")
|
||||||
def get_seek_stats(
|
# DEPRECATED: def get_seek_stats(
|
||||||
current_user: User = Depends(get_current_user),
|
# DEPRECATED: current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
# DEPRECATED: db: Session = Depends(get_db)
|
||||||
):
|
# DEPRECATED: ):
|
||||||
"""获取寻配号统计数据"""
|
# DEPRECATED: """获取寻配号统计数据"""
|
||||||
# 寻号需求数(seek类型且expect_number不为空的总数)
|
# 寻号需求数(seek类型且expect_number不为空的总数)
|
||||||
seek_count = db.query(Information).filter(
|
# DEPRECATED: seek_count = db.query(Information).filter(
|
||||||
Information.info_type == 'seek',
|
# DEPRECATED: Information.info_type == 'seek',
|
||||||
Information.expect_number.isnot(None),
|
# DEPRECATED: Information.expect_number.isnot(None),
|
||||||
Information.expect_number != ''
|
# DEPRECATED: Information.expect_number != ''
|
||||||
).count()
|
# DEPRECATED: ).count()
|
||||||
|
# DEPRECATED:
|
||||||
# 我的匹配:自有藏品匹配成功的寻号帖子数量
|
# 我的匹配:自有藏品匹配成功的寻号帖子数量
|
||||||
# 即 is_matched = 'confirmed' 的记录,用户ID等于当前用户
|
# 即 is_matched = 'confirmed' 的记录,用户ID等于当前用户
|
||||||
user_matched_count = 0
|
# DEPRECATED: user_matched_count = 0
|
||||||
if current_user:
|
# DEPRECATED: if current_user:
|
||||||
user_matched_count = db.query(Information).filter(
|
# DEPRECATED: user_matched_count = db.query(Information).filter(
|
||||||
Information.info_type == 'seek',
|
# DEPRECATED: Information.info_type == 'seek',
|
||||||
Information.expect_number.isnot(None),
|
# DEPRECATED: Information.expect_number.isnot(None),
|
||||||
Information.expect_number != '',
|
# DEPRECATED: Information.expect_number != '',
|
||||||
Information.matched_user_id == current_user.f99_90_id,
|
# DEPRECATED: Information.matched_user_id == current_user.f99_90_id,
|
||||||
Information.is_matched == 'confirmed'
|
# DEPRECATED: Information.is_matched == 'confirmed'
|
||||||
).count()
|
# DEPRECATED: ).count()
|
||||||
|
# DEPRECATED:
|
||||||
# 总共匹配:自有匹配成功 + 网络数据匹配成功
|
# 总共匹配:自有匹配成功 + 网络数据匹配成功
|
||||||
# 自有匹配成功:is_matched = 'confirmed'
|
# 自有匹配成功:is_matched = 'confirmed'
|
||||||
# 网络数据匹配成功:查询每个帖子的network_matched_count并求和
|
# 网络数据匹配成功:查询每个帖子的network_matched_count并求和
|
||||||
seeks = db.query(Information).filter(
|
# DEPRECATED: seeks = db.query(Information).filter(
|
||||||
Information.info_type == 'seek',
|
# DEPRECATED: Information.info_type == 'seek',
|
||||||
Information.expect_number.isnot(None),
|
# DEPRECATED: Information.expect_number.isnot(None),
|
||||||
Information.expect_number != ''
|
# DEPRECATED: Information.expect_number != ''
|
||||||
).all()
|
# DEPRECATED: ).all()
|
||||||
|
# DEPRECATED:
|
||||||
total_self_matched = 0
|
# DEPRECATED: total_self_matched = 0
|
||||||
total_network_matched = 0
|
# DEPRECATED: total_network_matched = 0
|
||||||
for seek in seeks:
|
# DEPRECATED: for seek in seeks:
|
||||||
# 自身匹配成功
|
# 自身匹配成功
|
||||||
if seek.is_matched == 'confirmed':
|
# DEPRECATED: if seek.is_matched == 'confirmed':
|
||||||
total_self_matched += 1
|
# DEPRECATED: total_self_matched += 1
|
||||||
# 网络数据匹配成功(通过coolbot数据库查询)
|
# 网络数据匹配成功(通过coolbot数据库查询)
|
||||||
if seek.expect_number:
|
# DEPRECATED: if seek.expect_number:
|
||||||
network_count = match_collections_count_from_coolbot(seek.expect_number)
|
# DEPRECATED: network_count = match_collections_count_from_coolbot(seek.expect_number)
|
||||||
total_network_matched += network_count
|
# DEPRECATED: total_network_matched += network_count
|
||||||
|
# DEPRECATED:
|
||||||
total_matched_count = total_self_matched + total_network_matched
|
# DEPRECATED: total_matched_count = total_self_matched + total_network_matched
|
||||||
|
# DEPRECATED:
|
||||||
return {
|
# DEPRECATED: return {
|
||||||
"seekCount": seek_count,
|
# DEPRECATED: "seekCount": seek_count,
|
||||||
"userMatchedCount": user_matched_count,
|
# DEPRECATED: "userMatchedCount": user_matched_count,
|
||||||
"totalMatchedCount": total_matched_count
|
# DEPRECATED: "totalMatchedCount": total_matched_count
|
||||||
}
|
# DEPRECATED: }
|
||||||
|
# DEPRECATED:
|
||||||
# 批量解析行情数据API
|
# 批量解析行情数据API
|
||||||
@router.post("/batch-parse")
|
@router.post("/batch-parse")
|
||||||
async def batch_parse_deals(text: str = Body(..., embed=True)):
|
async def batch_parse_deals(text: str = Body(..., embed=True)):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue