|
|
|
@ -39,13 +39,21 @@ type SearchUserOptions struct {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { |
|
|
|
|
var cond builder.Cond = builder.Eq{"type": opts.Type} |
|
|
|
|
var cond builder.Cond |
|
|
|
|
if opts.Type == UserTypeIdentity { |
|
|
|
|
cond = builder.Or( |
|
|
|
|
builder.Eq{"type": UserTypeIndividual}, |
|
|
|
|
builder.Eq{"type": UserTypeOrganization}, |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
cond = builder.Eq{"type": opts.Type} |
|
|
|
|
} |
|
|
|
|
if len(opts.Keyword) > 0 { |
|
|
|
|
lowerKeyword := strings.ToLower(opts.Keyword) |
|
|
|
|
keywordCond := builder.Or( |
|
|
|
|
builder.Like{"lower_name", lowerKeyword}, |
|
|
|
|
builder.Like{"LOWER(full_name)", lowerKeyword}, |
|
|
|
|
builder.Like{"LOWER(description)", lowerKeyword},
|
|
|
|
|
builder.Like{"LOWER(description)", lowerKeyword}, |
|
|
|
|
) |
|
|
|
|
if opts.SearchByEmail { |
|
|
|
|
keywordCond = keywordCond.Or(builder.Like{"LOWER(email)", lowerKeyword}) |
|
|
|
|