moving insert to another model and done so in database internal
This commit is contained in:
@@ -45,7 +45,7 @@ func AddTradeHandler(db *sql.DB) http.HandlerFunc {
|
||||
Product: model.TradeProduct(req.Product),
|
||||
Type: model.TradeType(req.Type),
|
||||
Price: req.Price,
|
||||
Currency: currency,
|
||||
Currency: currency.Name,
|
||||
Date: req.Date,
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package handlers
|
||||
import (
|
||||
"Portifolio/internal/database"
|
||||
"Portifolio/internal/model"
|
||||
"Portifolio/internal/service"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -41,7 +40,16 @@ func AddRevenueEntryHandler(db *sql.DB) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
if err := service.InsertRevenue(db, input.CompanyID, input.CurrencyID, input.Category, nil, input.Value, period); err != nil {
|
||||
rev := model.RevenueInsert{
|
||||
CompanyID: input.CompanyID,
|
||||
CurrencyID: input.CurrencyID,
|
||||
CategoryName: input.Category,
|
||||
Period: period,
|
||||
Value: input.Value,
|
||||
}
|
||||
|
||||
err := database.InsertRevenue(db, rev)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user