fix: allow agency search by parent bd display id
This commit is contained in:
parent
3af61b2468
commit
424594ba02
@ -867,6 +867,13 @@ func TestAdminCreateAgencyControlsAppSearch(t *testing.T) {
|
||||
if len(agencies) != 1 || agencies[0].AgencyID != created.Agency.AgencyID {
|
||||
t.Fatalf("created agency should be searchable by owner display id: %+v", agencies)
|
||||
}
|
||||
agencies, err = svc.SearchAgencies(ctx, 902, displayID(900), 20)
|
||||
if err != nil {
|
||||
t.Fatalf("SearchAgencies by parent BD display id failed: %v", err)
|
||||
}
|
||||
if len(agencies) != 1 || agencies[0].AgencyID != created.Agency.AgencyID {
|
||||
t.Fatalf("created agency should be searchable by parent BD display id: %+v", agencies)
|
||||
}
|
||||
|
||||
disabledJoin, err := svc.SetAgencyJoinEnabled(ctx, hostservice.SetAgencyJoinEnabledInput{
|
||||
CommandID: "admin-disable-agency-join-901",
|
||||
|
||||
@ -42,6 +42,8 @@ func (r *Repository) SearchAgencies(ctx context.Context, command hostservice.Sea
|
||||
FROM agencies a
|
||||
INNER JOIN users owner
|
||||
ON owner.app_code = a.app_code AND owner.user_id = a.owner_user_id
|
||||
LEFT JOIN users parent_bd
|
||||
ON parent_bd.app_code = a.app_code AND parent_bd.user_id = a.parent_bd_user_id
|
||||
LEFT JOIN agency_memberships active_member
|
||||
ON active_member.app_code = a.app_code
|
||||
AND active_member.agency_id = a.agency_id
|
||||
@ -55,8 +57,9 @@ func (r *Repository) SearchAgencies(ctx context.Context, command hostservice.Sea
|
||||
args := []any{hostdomain.MembershipStatusActive, appcode.FromContext(ctx), country, hostdomain.AgencyStatusActive}
|
||||
if strings.TrimSpace(command.Keyword) != "" {
|
||||
keyword := strings.TrimSpace(command.Keyword)
|
||||
query += ` AND (a.name LIKE ? OR a.agency_id = ? OR owner.current_display_user_id = ?)`
|
||||
args = append(args, "%"+keyword+"%", int64FromKeyword(keyword), keyword)
|
||||
// Host 申请页里运营常按 BD 短号找“这个 BD 下面的公会”,因此关键字同时匹配 owner 和 parent BD。
|
||||
query += ` AND (a.name LIKE ? OR a.agency_id = ? OR owner.current_display_user_id = ? OR parent_bd.current_display_user_id = ?)`
|
||||
args = append(args, "%"+keyword+"%", int64FromKeyword(keyword), keyword, keyword)
|
||||
}
|
||||
query += `
|
||||
GROUP BY
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user