Upstream sync
This commit is contained in:
@@ -3,12 +3,11 @@ package models
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
type Contract struct {
|
||||
gorm.Model
|
||||
BaseModel
|
||||
Name string `json:"name"`
|
||||
DeviceIDs pq.Int64Array `json:"deviceIds" gorm:"type:integer[]"`
|
||||
BuyerID uint `json:"buyerId"`
|
||||
@@ -64,7 +63,7 @@ type ContractResponse struct {
|
||||
}
|
||||
|
||||
func ConvertContractToResponse(contracts []Contract) []ContractResponse {
|
||||
var contractResponses []ContractResponse
|
||||
contractResponses := []ContractResponse{}
|
||||
for _, contract := range contracts {
|
||||
contractResponse := ContractResponse{
|
||||
BaseModel: BaseModel{
|
||||
@@ -102,13 +101,13 @@ func ConvertContractToResponse(contracts []Contract) []ContractResponse {
|
||||
}
|
||||
|
||||
func ConvertContractToResponseModel(contracts []Contract) []ListContractResponse {
|
||||
var listInvoiceResponses []ListContractResponse
|
||||
listInvoiceResponses := []ListContractResponse{}
|
||||
|
||||
// Get all statuses
|
||||
statuses := GetContractStatuses()
|
||||
statusMap := make(map[string]Status)
|
||||
for _, s := range statuses {
|
||||
statusMap[s.Value] = s
|
||||
statusMap[s.Key] = s
|
||||
}
|
||||
|
||||
for _, contract := range contracts {
|
||||
@@ -171,16 +170,22 @@ type ListContractResponse struct {
|
||||
}
|
||||
|
||||
type CreateContractRequestPayload struct {
|
||||
SellerID uint `json:"sellerId" binding:"required"`
|
||||
BuyerID uint `json:"buyerId" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
ProductID uint `json:"productId"`
|
||||
MinTemp float64 `json:"minTemp" binding:"required"`
|
||||
MaxTemp float64 `json:"maxTemp" binding:"required"`
|
||||
ArrivalDate int64 `json:"arrivalDate"`
|
||||
PenaltyType string `json:"penaltyType"`
|
||||
PenaltyValue int `json:"penaltyValue"`
|
||||
PenaltyRec string `json:"penaltyRec"`
|
||||
SellerID uint `json:"sellerId" binding:"required"`
|
||||
BuyerID uint `json:"buyerId" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
ProductID uint `json:"productId"`
|
||||
MinTemp float64 `json:"minTemp" binding:"required"`
|
||||
MaxTemp float64 `json:"maxTemp" binding:"required"`
|
||||
ArrivalDate int64 `json:"arrivalDate"`
|
||||
PenaltyType string `json:"penaltyType"`
|
||||
PenaltyValue int `json:"penaltyValue"`
|
||||
PenaltyRec string `json:"penaltyRec"`
|
||||
StartPlaceName string `json:"startPlaceName"`
|
||||
StartLat float64 `json:"startLat"`
|
||||
StartLon float64 `json:"startLon"`
|
||||
EndPlaceName string `json:"endPlaceName"`
|
||||
EndLat float64 `json:"endLat"`
|
||||
EndLon float64 `json:"endLon"`
|
||||
}
|
||||
|
||||
func (Contract) Update() (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user