f
This commit is contained in:
@@ -149,6 +149,28 @@ func (r *GormApiCallRepository) ListByUserIdWithFiltersAndProductName(ctx contex
|
||||
|
||||
// 应用筛选条件
|
||||
if filters != nil {
|
||||
// 产品ID筛选(支持多个)
|
||||
if productIds, ok := filters["product_ids"].(string); ok && productIds != "" {
|
||||
// 多个产品ID,逗号分隔
|
||||
productIdsList := strings.Split(productIds, ",")
|
||||
// 去除空白字符
|
||||
var cleanProductIds []string
|
||||
for _, id := range productIdsList {
|
||||
id = strings.TrimSpace(id)
|
||||
if id != "" {
|
||||
cleanProductIds = append(cleanProductIds, id)
|
||||
}
|
||||
}
|
||||
if len(cleanProductIds) > 0 {
|
||||
placeholders := strings.Repeat("?,", len(cleanProductIds))
|
||||
placeholders = placeholders[:len(placeholders)-1] // 移除最后一个逗号
|
||||
whereCondition += " AND ac.product_id IN (" + placeholders + ")"
|
||||
for _, id := range cleanProductIds {
|
||||
whereArgs = append(whereArgs, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 时间范围筛选
|
||||
if startTime, ok := filters["start_time"].(time.Time); ok {
|
||||
whereCondition += " AND ac.created_at >= ?"
|
||||
@@ -337,6 +359,28 @@ func (r *GormApiCallRepository) ListWithFiltersAndProductName(ctx context.Contex
|
||||
whereArgs = append(whereArgs, userId)
|
||||
}
|
||||
|
||||
// 产品ID筛选(支持多个)
|
||||
if productIds, ok := filters["product_ids"].(string); ok && productIds != "" {
|
||||
// 多个产品ID,逗号分隔
|
||||
productIdsList := strings.Split(productIds, ",")
|
||||
// 去除空白字符
|
||||
var cleanProductIds []string
|
||||
for _, id := range productIdsList {
|
||||
id = strings.TrimSpace(id)
|
||||
if id != "" {
|
||||
cleanProductIds = append(cleanProductIds, id)
|
||||
}
|
||||
}
|
||||
if len(cleanProductIds) > 0 {
|
||||
placeholders := strings.Repeat("?,", len(cleanProductIds))
|
||||
placeholders = placeholders[:len(placeholders)-1] // 移除最后一个逗号
|
||||
whereCondition += " AND ac.product_id IN (" + placeholders + ")"
|
||||
for _, id := range cleanProductIds {
|
||||
whereArgs = append(whereArgs, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 时间范围筛选
|
||||
if startTime, ok := filters["start_time"].(time.Time); ok {
|
||||
whereCondition += " AND ac.created_at >= ?"
|
||||
|
||||
Reference in New Issue
Block a user