This commit is contained in:
2026-02-11 17:46:22 +03:00
commit eacfacb13b
266 changed files with 51337 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package queries
import (
"bssapp-backend/models"
"database/sql"
"fmt"
)
// GetTodayCurrencyV3 tek bir döviz türü için güncel kuru döndürür (MSSQL sürümü)
func GetTodayCurrencyV3(db *sql.DB, currencyCode string) (*models.TodayCurrencyV3, error) {
query := `
SELECT TOP 1
CurrencyCode,
RelationCurrencyCode,
ExchangeTypeCode,
Rate,
CONVERT(varchar, Date, 23) AS Date
FROM AllExchangeRates
WHERE CurrencyCode = @p1
AND RelationCurrencyCode = 'TRY'
AND ExchangeTypeCode = 6
AND Rate > 0
ORDER BY ABS(DATEDIFF(DAY, Date, GETDATE())) ASC
`
row := db.QueryRow(query, currencyCode)
var c models.TodayCurrencyV3
err := row.Scan(&c.CurrencyCode, &c.RelationCurrencyCode, &c.ExchangeTypeCode, &c.Rate, &c.Date)
if err != nil {
return nil, fmt.Errorf("kur bilgisi alınamadı: %v", err)
}
return &c, nil
}