package app import ( "fmt" "strings" ) func testUserFilter(userType, batch string) (string, []any, error) { where := "" args := []any{} switch userType { case "": case "test": where = " AND u.is_test=1" case "registered": where = " AND u.is_test=0" default: return "", nil, fmt.Errorf("用户类型筛选无效") } batch = strings.TrimSpace(batch) if len(batch) > 64 { return "", nil, fmt.Errorf("测试批次长度不能超过64位") } if batch != "" { where += " AND u.is_test=1 AND u.test_batch=?" args = append(args, batch) } return where, args, nil }