25 lines
419 B
Go
25 lines
419 B
Go
package authz
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func BuildINClause(column string, codes []string) string {
|
|
if len(codes) == 0 {
|
|
return "1=0"
|
|
}
|
|
var quoted []string
|
|
for _, c := range codes {
|
|
c = strings.TrimSpace(strings.ToUpper(c))
|
|
if c == "" {
|
|
continue
|
|
}
|
|
quoted = append(quoted, "'"+c+"'")
|
|
}
|
|
if len(quoted) == 0 {
|
|
return "1=0"
|
|
}
|
|
return fmt.Sprintf("%s IN (%s)", column, strings.Join(quoted, ","))
|
|
}
|