Files
old-backend/models/contract.go

72 lines
1.6 KiB
Go
Raw Normal View History

2023-09-18 12:27:40 +02:00
package models
2023-09-18 13:39:32 +02:00
import (
2023-09-21 11:59:08 +02:00
"time"
2023-09-18 13:39:32 +02:00
"github.com/jinzhu/gorm"
"github.com/lib/pq"
)
2023-09-18 12:27:40 +02:00
type Contract struct {
gorm.Model
Name string
2023-09-18 13:39:32 +02:00
DeviceIDs pq.Int64Array `gorm:"type:integer[]"`
2023-09-18 12:27:40 +02:00
BuyerID uint
2023-09-21 11:59:08 +02:00
StartLat float64
StartLon float64
EndLat float64
EndLon float64
StartTime time.Time
EndTime time.Time
2023-09-18 12:27:40 +02:00
Status string
BlockchainID string
ContractInfos []ContractInfo
2023-10-03 18:26:57 +02:00
BuyerName string `gorm:"-"`
NumberOfDevices int `gorm:"-"`
2023-09-18 12:27:40 +02:00
}
2023-09-19 08:15:42 +02:00
const ContractStatusActive = "active"
const ContractStatusPending = "pending"
2023-10-03 18:26:57 +02:00
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
}
2023-09-19 08:15:42 +02:00
2023-09-18 12:27:40 +02:00
func (Contract) Update() (bool, error) {
return false, nil
}
func (Contract) Create() (bool, error) {
return false, nil
}
func (Contract) Delete() (bool, error) {
return false, nil
}