Initial commit
Some checks failed
Go-test / build (push) Has been cancelled

This commit is contained in:
2025-12-01 09:15:48 +07:00
parent d4638dddc8
commit 3a53de2ae1
23 changed files with 3177 additions and 22135 deletions

View File

@@ -52,20 +52,40 @@ func (dv *DuplicateValidator) ValidateDuplicate(ctx context.Context, config Vali
// ValidateDuplicateWithCustomFields checks for duplicates with additional custom fields
func (dv *DuplicateValidator) ValidateDuplicateWithCustomFields(ctx context.Context, config ValidationConfig, fields map[string]interface{}) error {
whereClause := fmt.Sprintf("%s = ANY($1) AND DATE(%s) = CURRENT_DATE", config.StatusColumn, config.DateColumn)
args := []interface{}{config.ActiveStatuses}
argIndex := 2
whereClause := ""
args := []interface{}{}
argIndex := 1
// Add additional field conditions
// for fieldName, fieldValue := range config.AdditionalFields {
// whereClause += fmt.Sprintf(" AND %s = $%d", fieldName, argIndex)
// args = append(args, fieldValue)
// argIndex++
// }
// Add additional field conditions from config
for fieldName, fieldValue := range config.AdditionalFields {
whereClause += fmt.Sprintf(" AND %s = $%d", fieldName, argIndex)
if whereClause != "" {
whereClause += " AND "
}
whereClause += fmt.Sprintf("%s = $%d", fieldName, argIndex)
args = append(args, fieldValue)
argIndex++
}
// Add dynamic fields
// for fieldName, fieldValue := range fields {
// whereClause += fmt.Sprintf(" AND %s = $%d", fieldName, argIndex)
// args = append(args, fieldValue)
// argIndex++
// }
// Add dynamic fields from input
for fieldName, fieldValue := range fields {
whereClause += fmt.Sprintf(" AND %s = $%d", fieldName, argIndex)
if whereClause != "" {
whereClause += " AND "
}
whereClause += fmt.Sprintf("%s = $%d", fieldName, argIndex)
args = append(args, fieldValue)
argIndex++
}