fix: use ilike and trim for category, company and type filters
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -162,14 +162,17 @@ class MaterialBaseService:
|
||||
))
|
||||
|
||||
# 2. 精确筛选
|
||||
if filters.get('company'):
|
||||
query = query.filter_by(company_name=filters['company'])
|
||||
company = filters.get('company')
|
||||
if company is not None and company != '':
|
||||
query = query.filter(MaterialBase.company_name.ilike(company.strip()))
|
||||
|
||||
if filters.get('category'):
|
||||
query = query.filter_by(category=filters['category'])
|
||||
category = filters.get('category')
|
||||
if category is not None and category != '':
|
||||
query = query.filter(MaterialBase.category.ilike(category.strip()))
|
||||
|
||||
if filters.get('type'):
|
||||
query = query.filter_by(material_type=filters['type'])
|
||||
type_val = filters.get('type')
|
||||
if type_val is not None and type_val != '':
|
||||
query = query.filter(MaterialBase.material_type.ilike(type_val.strip()))
|
||||
|
||||
if filters.get('isEnabled') is not None:
|
||||
is_active = bool(int(filters['isEnabled']))
|
||||
@ -370,12 +373,15 @@ class MaterialBaseService:
|
||||
MaterialBase.spec_model.ilike(kw),
|
||||
MaterialBase.company_name.ilike(kw)
|
||||
))
|
||||
if filters.get('company'):
|
||||
filter_conditions.append(MaterialBase.company_name == filters['company'])
|
||||
if filters.get('category'):
|
||||
filter_conditions.append(MaterialBase.category == filters['category'])
|
||||
if filters.get('type'):
|
||||
filter_conditions.append(MaterialBase.material_type == filters['type'])
|
||||
company = filters.get('company')
|
||||
if company is not None and company != '':
|
||||
filter_conditions.append(MaterialBase.company_name.ilike(company.strip()))
|
||||
category = filters.get('category')
|
||||
if category is not None and category != '':
|
||||
filter_conditions.append(MaterialBase.category.ilike(category.strip()))
|
||||
type_val = filters.get('type')
|
||||
if type_val is not None and type_val != '':
|
||||
filter_conditions.append(MaterialBase.material_type.ilike(type_val.strip()))
|
||||
if filters.get('isEnabled') is not None:
|
||||
is_active = bool(int(filters['isEnabled']))
|
||||
filter_conditions.append(MaterialBase.is_enabled == is_active)
|
||||
|
||||
Reference in New Issue
Block a user