线下提号增加搜索手机号
This commit is contained in:
@@ -435,7 +435,13 @@ func (r *Repository) ListAdmin(ctx context.Context, query AdminPickupQuery) (*Pa
|
||||
}
|
||||
if kw := strings.TrimSpace(query.Keyword); kw != "" {
|
||||
like := "%" + kw + "%"
|
||||
db = db.Where("p.pickup_no LIKE ? OR l.listing_no LIKE ? OR a.title LIKE ?", like, like, like)
|
||||
db = db.Where(
|
||||
"p.pickup_no LIKE ? OR l.listing_no LIKE ? OR a.title LIKE ? OR owner.phone LIKE ?",
|
||||
like,
|
||||
like,
|
||||
like,
|
||||
like,
|
||||
)
|
||||
}
|
||||
return r.paginatePickups(db, query.Page, query.PageSize, false)
|
||||
}
|
||||
|
||||
@@ -154,6 +154,27 @@ func TestRepositoryListAdminFiltersShopName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepositoryListAdminFiltersOwnerPhone(t *testing.T) {
|
||||
repo, db := newPickupTestRepo(t)
|
||||
pickup := seedPickup(t, db, StatusPickingUp)
|
||||
|
||||
result, err := repo.ListAdmin(t.Context(), AdminPickupQuery{Keyword: "000000"})
|
||||
if err != nil {
|
||||
t.Fatalf("ListAdmin() error = %v", err)
|
||||
}
|
||||
if result.Total != 1 || len(result.Items) != 1 {
|
||||
t.Fatalf("手机号搜索结果 = total %d, items %d, want 1", result.Total, len(result.Items))
|
||||
}
|
||||
if result.Items[0].ID != pickup.ID || result.Items[0].OwnerPhone != "18800000000" {
|
||||
t.Fatalf(
|
||||
"手机号搜索结果 = id %d, phone %q, want id %d, phone 18800000000",
|
||||
result.Items[0].ID,
|
||||
result.Items[0].OwnerPhone,
|
||||
pickup.ID,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepositoryListShopNamesReturnsDistinctPlatformOptions(t *testing.T) {
|
||||
repo, db := newPickupTestRepo(t)
|
||||
first := seedPickup(t, db, StatusPickingUp)
|
||||
|
||||
Reference in New Issue
Block a user