72 lines
1.6 KiB
Go
72 lines
1.6 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/jinzhu/gorm"
|
|
"github.com/lib/pq"
|
|
)
|
|
|
|
type Contract struct {
|
|
gorm.Model
|
|
Name string
|
|
DeviceIDs pq.Int64Array `gorm:"type:integer[]"`
|
|
BuyerID uint
|
|
StartLat float64
|
|
StartLon float64
|
|
EndLat float64
|
|
EndLon float64
|
|
StartTime time.Time
|
|
EndTime time.Time
|
|
Status string
|
|
BlockchainID string
|
|
ContractInfos []ContractInfo
|
|
BuyerName string `gorm:"-"`
|
|
NumberOfDevices int `gorm:"-"`
|
|
}
|
|
|
|
const ContractStatusActive = "active"
|
|
const ContractStatusPending = "pending"
|
|
const ContractStatusDraft = "draft"
|
|
const ContractStatusSigned = "signed"
|
|
const ContractStatusReadyForActivation = "ready_for_activation"
|
|
const ContractStatusExecuted = "executed"
|
|
const ContractStatusRevoked = "revoked"
|
|
|
|
|
|
type Status struct {
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
func GetContractStatuses() []Status {
|
|
return []Status{
|
|
{Key: "Active", Value: "active"},
|
|
{Key: "Pending signature", Value: "pending"},
|
|
{Key: "Draft", Value: "draft"},
|
|
{Key: "Signed", Value: "signed"},
|
|
{Key: "Ready for Activation", Value: "ready_for_activation"},
|
|
{Key: "Executed", Value: "executed"},
|
|
{Key: "Revoked", Value: "revoked"},
|
|
}
|
|
}
|
|
|
|
type ListContractResponse struct {
|
|
Status KeyValue `json:"Status"`
|
|
Buyer CompanyShortResponse `json:"Buyer"`
|
|
ContractID int
|
|
NumberOfDevices int
|
|
DateCreated time.Time
|
|
|
|
}
|
|
|
|
func (Contract) Update() (bool, error) {
|
|
return false, nil
|
|
}
|
|
func (Contract) Create() (bool, error) {
|
|
return false, nil
|
|
}
|
|
func (Contract) Delete() (bool, error) {
|
|
return false, nil
|
|
}
|