作者 陈志颖

feat:优化模糊查询

... ... @@ -831,7 +831,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
cooperationContracts := make([]*domain.CooperationContract, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions)
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" {
query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
... ...
... ... @@ -170,8 +170,8 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
}
if orderOrReturnedOrderNum, ok := queryOptions["orderOrReturnedOrderNum"]; ok && orderOrReturnedOrderNum != "" {
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
q.WhereOr("dividends_order_number like ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
q.WhereOr("dividends_returned_order_number like ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
q.WhereOr("dividends_order_number ilike ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
q.WhereOr("dividends_returned_order_number ilike ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
return q, nil
})
}
... ...