Added create contact ednpoint
This commit is contained in:
@@ -1,18 +1,60 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
type InvoiceItem struct {
|
||||
gorm.Model
|
||||
Description string
|
||||
Quantity int64
|
||||
Unit string
|
||||
PriceCents int64 `gorm:"column:price_cents"`
|
||||
InvoiceID uint
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt sql.NullTime `json:"deletedAt" gorm:"index"`
|
||||
Description string `json:"description"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
Unit string `json:"unit"`
|
||||
PriceCents int64 `json:"priceCents" gorm:"column:price_cents"`
|
||||
InvoiceID uint `json:"invoiceId"`
|
||||
}
|
||||
|
||||
type InvoiceItemResponse struct {
|
||||
BaseModel
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt sql.NullTime `json:"deletedAt" gorm:"index"`
|
||||
Description string `json:"description"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
Unit string `json:"unit"`
|
||||
PriceCents int64 `json:"priceCents" gorm:"column:price_cents"`
|
||||
InvoiceID uint `json:"invoiceId"`
|
||||
}
|
||||
|
||||
// ConvertSliceOfInvoiceItemToResponse converts a slice of InvoiceItem models to a slice of InvoiceItemResponse models
|
||||
func ConvertInvoiceItemToResponse(items []InvoiceItem) []InvoiceItemResponse {
|
||||
var itemResponses []InvoiceItemResponse
|
||||
for _, item := range items {
|
||||
itemResponse := InvoiceItemResponse{
|
||||
BaseModel: BaseModel{
|
||||
ID: item.ID,
|
||||
CreatedAt: item.CreatedAt,
|
||||
UpdatedAt: item.UpdatedAt,
|
||||
},
|
||||
Description: item.Description,
|
||||
Quantity: item.Quantity,
|
||||
Unit: item.Unit,
|
||||
PriceCents: item.PriceCents,
|
||||
InvoiceID: item.InvoiceID,
|
||||
}
|
||||
itemResponses = append(itemResponses, itemResponse)
|
||||
}
|
||||
return itemResponses
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func (InvoiceItem) Update() (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user