update
This commit is contained in:
parent
3d4a146174
commit
c36a4073d9
@ -55,26 +55,44 @@ async def search_user_inquiry(ns={}):
|
||||
# 分页查询
|
||||
search_sql = """select * from product_inquiry where %s order by update_time desc limit %d offset %d;""" % (where_clause, page_size, offset)
|
||||
result = await sor.sqlExe(search_sql, {})
|
||||
dict_sql = """select dict_type, dict_key, dict_value from product_inquiry_dict where status = 1 order by dict_type asc, sort_order asc;"""
|
||||
dict_sql = """
|
||||
select dict_type, dict_key, dict_value_zh, dict_value_en
|
||||
from product_inquiry_dict
|
||||
where status = 1
|
||||
order by dict_type asc, sort_order asc;
|
||||
"""
|
||||
dict_result = await sor.sqlExe(dict_sql, {})
|
||||
dict_mapping = {}
|
||||
dict_mapping_zh = {}
|
||||
dict_mapping_en = {}
|
||||
for dict_item in dict_result:
|
||||
dict_type = dict_item.get('dict_type')
|
||||
dict_mapping.setdefault(dict_type, {})[str(dict_item.get('dict_key'))] = dict_item.get('dict_value')
|
||||
dict_key = str(dict_item.get('dict_key'))
|
||||
dict_mapping_zh.setdefault(dict_type, {})[dict_key] = dict_item.get('dict_value_zh')
|
||||
dict_mapping_en.setdefault(dict_type, {})[dict_key] = dict_item.get('dict_value_en')
|
||||
|
||||
value_mapping = {
|
||||
value_mapping_zh = {
|
||||
'custom_type': {'0': '个人', '1': '企业'},
|
||||
'enterprise_type': dict_mapping.get('enterprise_type', {}),
|
||||
'region': dict_mapping.get('region', {}),
|
||||
'enterprise_type': dict_mapping_zh.get('enterprise_type', {}),
|
||||
'region': dict_mapping_zh.get('region', {}),
|
||||
'feedback': {'0': '待回复', '1': '已回复'}
|
||||
}
|
||||
value_mapping_en = {
|
||||
'custom_type': {'0': 'Individual', '1': 'Enterprise'},
|
||||
'enterprise_type': dict_mapping_en.get('enterprise_type', {}),
|
||||
'region': dict_mapping_en.get('region', {}),
|
||||
'feedback': {'0': 'Pending Reply', '1': 'Replied'}
|
||||
}
|
||||
for data_dic in result:
|
||||
for key, mapping in value_mapping.items():
|
||||
for key in value_mapping_zh.keys():
|
||||
if key in data_dic:
|
||||
data_dic['%s_name' % key] = mapping.get(str(data_dic.get(key)), data_dic.get(key))
|
||||
direction_mapping = dict_mapping.get('direction', {})
|
||||
value_key = str(data_dic.get(key))
|
||||
data_dic['%s_name_zh' % key] = value_mapping_zh[key].get(value_key, data_dic.get(key))
|
||||
data_dic['%s_name_en' % key] = value_mapping_en[key].get(value_key, data_dic.get(key))
|
||||
direction_mapping_zh = dict_mapping_zh.get('direction', {})
|
||||
direction_mapping_en = dict_mapping_en.get('direction', {})
|
||||
direction_keys = str(data_dic.get('consult_direction')).split(',') if data_dic.get('consult_direction') else []
|
||||
data_dic['consult_direction_name'] = ','.join([direction_mapping.get(direction_key.strip(), direction_key.strip()) for direction_key in direction_keys if direction_key.strip()])
|
||||
data_dic['consult_direction_name_zh'] = ','.join([direction_mapping_zh.get(direction_key.strip(), direction_key.strip()) for direction_key in direction_keys if direction_key.strip()])
|
||||
data_dic['consult_direction_name_en'] = ', '.join([direction_mapping_en.get(direction_key.strip(), direction_key.strip()) for direction_key in direction_keys if direction_key.strip()])
|
||||
|
||||
if ns.get('to_excel') == '1':
|
||||
# 创建映射字段 导出execl
|
||||
@ -106,11 +124,11 @@ async def search_user_inquiry(ns={}):
|
||||
value = data_dic[key]
|
||||
chinese_key = field_mapping[key]
|
||||
if key == 'consult_direction':
|
||||
direction_mapping = dict_mapping.get('direction', {})
|
||||
direction_mapping = dict_mapping_zh.get('direction', {})
|
||||
direction_keys = str(value).split(',') if value else []
|
||||
new_data_dic[chinese_key] = ','.join([direction_mapping.get(direction_key.strip(), direction_key.strip()) for direction_key in direction_keys if direction_key.strip()])
|
||||
elif key in value_mapping:
|
||||
mapped_value = value_mapping[key].get(str(value), value) # 若未找到对应映射,保留原始值
|
||||
elif key in value_mapping_zh:
|
||||
mapped_value = value_mapping_zh[key].get(str(value), value) # 若未找到对应映射,保留原始值
|
||||
new_data_dic[chinese_key] = mapped_value
|
||||
else:
|
||||
new_data_dic[chinese_key] = value
|
||||
|
||||
@ -4,7 +4,12 @@ async def search_user_inquiry_dict(ns={}):
|
||||
where_sql = "where status = 1"
|
||||
if ns.get('dict_type'):
|
||||
where_sql += " and dict_type = '%s'" % ns.get('dict_type')
|
||||
search_sql = """select * from product_inquiry_dict %s order by dict_type asc, sort_order asc;""" % where_sql
|
||||
search_sql = """
|
||||
select id, dict_type, dict_key, dict_value_zh, dict_value_en, sort_order
|
||||
from product_inquiry_dict
|
||||
%s
|
||||
order by dict_type asc, sort_order asc;
|
||||
""" % where_sql
|
||||
result = await sor.sqlExe(search_sql, {})
|
||||
return {
|
||||
'status': True,
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
# Bilingual Inquiry Dictionary Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Adapt inquiry search APIs to the bilingual dictionary value columns.
|
||||
|
||||
**Architecture:** Build independent Chinese and English dictionary maps from one query. Return separate language display fields in normal search results while reusing the Chinese map for the existing Excel export.
|
||||
|
||||
**Tech Stack:** DSPY Python endpoints, async DBPools/sor access, MySQL.
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Update inquiry result mapping
|
||||
|
||||
**Files:**
|
||||
- Modify: `b/product/search_user_inquiry.dspy`
|
||||
|
||||
- [ ] Query `dict_value_zh` and `dict_value_en`.
|
||||
- [ ] Build separate Chinese and English maps.
|
||||
- [ ] Return `*_name_zh` and `*_name_en` for single-choice fields.
|
||||
- [ ] Return `consult_direction_name_zh` and `consult_direction_name_en`.
|
||||
- [ ] Keep Excel export mapped through Chinese values.
|
||||
|
||||
### Task 2: Update dictionary search output
|
||||
|
||||
**Files:**
|
||||
- Modify: `b/product/search_user_inquiry_dict.dspy`
|
||||
|
||||
- [ ] Replace `select *` with the explicit bilingual dictionary columns.
|
||||
|
||||
### Task 3: Verify
|
||||
|
||||
**Files:**
|
||||
- Verify: `b/product/search_user_inquiry.dspy`
|
||||
- Verify: `b/product/search_user_inquiry_dict.dspy`
|
||||
|
||||
- [ ] Confirm neither SQL query references the removed `dict_value` column.
|
||||
- [ ] Compile both DSPY function bodies.
|
||||
- [ ] Run IDE diagnostics and `git diff --check`.
|
||||
Loading…
x
Reference in New Issue
Block a user