diff --git a/pkg/model/audit_event.go b/pkg/model/audit_event.go index 998f76d..2481358 100644 --- a/pkg/model/audit_event.go +++ b/pkg/model/audit_event.go @@ -5,7 +5,7 @@ import ( "time" ) -type AuditEventType int32 +type AuditEventType uint32 // User clicked "Submit", "Accept" etc const AuditEventTypeAction AuditEventType = 0 @@ -43,11 +43,11 @@ type AuditEventDataChangeName struct { } type AuditEvent struct { - ID int64 `gorm:"primaryKey"` + ID uint64 `gorm:"primaryKey"` CreatedAt time.Time User uint64 ResourceType ResourceType // is this a submission or is it a mapfix - ResourceID int64 // submission / mapfix / map ID + ResourceID uint64 // submission / mapfix / map ID EventType AuditEventType EventData json.RawMessage `gorm:"type:jsonb"` } diff --git a/pkg/model/mapfix.go b/pkg/model/mapfix.go index 6c9d9a7..e418a5b 100644 --- a/pkg/model/mapfix.go +++ b/pkg/model/mapfix.go @@ -2,7 +2,7 @@ package model import "time" -type MapfixStatus int32 +type MapfixStatus uint32 const ( // Phase: Creation @@ -25,7 +25,7 @@ const ( ) type Mapfix struct { - ID int64 `gorm:"primaryKey"` + ID uint64 `gorm:"primaryKey"` DisplayName string Creator string GameID uint32 diff --git a/pkg/model/nats.go b/pkg/model/nats.go index 7a69450..34d693e 100644 --- a/pkg/model/nats.go +++ b/pkg/model/nats.go @@ -7,26 +7,26 @@ package model type CreateSubmissionRequest struct { // operation_id is passed back in the response message - OperationID int32 + OperationID uint32 ModelID uint64 } type CreateMapfixRequest struct { - OperationID int32 + OperationID uint32 ModelID uint64 TargetAssetID uint64 } type ValidateSubmissionRequest struct { // submission_id is passed back in the response message - SubmissionID int64 + SubmissionID uint64 ModelID uint64 ModelVersion uint64 ValidatedModelID *uint64 // optional value } type ValidateMapfixRequest struct { - MapfixID int64 + MapfixID uint64 ModelID uint64 ModelVersion uint64 ValidatedModelID *uint64 // optional value @@ -34,14 +34,14 @@ type ValidateMapfixRequest struct { // Create a new map type UploadSubmissionRequest struct { - SubmissionID int64 + SubmissionID uint64 ModelID uint64 ModelVersion uint64 ModelName string } type UploadMapfixRequest struct { - MapfixID int64 + MapfixID uint64 ModelID uint64 ModelVersion uint64 TargetAssetID uint64 diff --git a/pkg/model/operation.go b/pkg/model/operation.go index a3fefbc..64236de 100644 --- a/pkg/model/operation.go +++ b/pkg/model/operation.go @@ -2,7 +2,7 @@ package model import "time" -type OperationStatus int32 +type OperationStatus uint32 const ( OperationStatusCreated OperationStatus = 0 OperationStatusCompleted OperationStatus = 1 @@ -10,7 +10,7 @@ const ( ) type Operation struct { - ID int32 `gorm:"primaryKey"` + ID uint32 `gorm:"primaryKey"` CreatedAt time.Time Owner uint64 // UserID StatusID OperationStatus diff --git a/pkg/model/page.go b/pkg/model/page.go index 37ff8be..3a86a11 100644 --- a/pkg/model/page.go +++ b/pkg/model/page.go @@ -1,6 +1,6 @@ package model type Page struct { - Number int32 - Size int32 + Number uint32 + Size uint32 } diff --git a/pkg/model/policy.go b/pkg/model/policy.go index d63a5a6..df91070 100644 --- a/pkg/model/policy.go +++ b/pkg/model/policy.go @@ -2,7 +2,7 @@ package model import "time" -type Policy int32 +type Policy uint32 const ( ScriptPolicyNone Policy = 0 // not yet reviewed @@ -13,7 +13,7 @@ const ( ) type ScriptPolicy struct { - ID int64 `gorm:"primaryKey"` + ID uint64 `gorm:"primaryKey"` // Hash of the source code that leads to this policy. // If this is a replacement mapping, the original source may not be pointed to by any policy. // The original source should still exist in the scripts table, which can be located by the same hash. @@ -21,7 +21,7 @@ type ScriptPolicy struct { // The ID of the replacement source (ScriptPolicyReplace) // or verbatim source (ScriptPolicyAllowed) // or 0 (other) - ToScriptID int64 + ToScriptID uint64 Policy Policy CreatedAt time.Time UpdatedAt time.Time diff --git a/pkg/model/script.go b/pkg/model/script.go index 61b011e..2caad3d 100644 --- a/pkg/model/script.go +++ b/pkg/model/script.go @@ -23,7 +23,7 @@ func HashParse(hash string) (uint64, error){ return strconv.ParseUint(hash, 16, 64) } -type ResourceType int32 +type ResourceType uint32 const ( ResourceUnknown ResourceType = 0 ResourceMapfix ResourceType = 1 @@ -31,12 +31,17 @@ const ( ) type Script struct { - ID int64 `gorm:"primaryKey"` + ID uint64 `gorm:"primaryKey"` Name string - Hash int64 // postgres does not support unsigned integers, so we have to pretend + hash uint64 Source string ResourceType ResourceType // is this a submission or is it a mapfix - ResourceID int64 // which submission / mapfix did this script first appear in + ResourceID uint64 // which submission / mapfix did this script first appear in CreatedAt time.Time UpdatedAt time.Time } + +// postgres does not support unsigned integers, so we have to pretend +func (script *Script) GetPostgresInt64() (int64) { + return int64(script.hash) +} diff --git a/pkg/model/submission.go b/pkg/model/submission.go index 8001697..d1b64d5 100644 --- a/pkg/model/submission.go +++ b/pkg/model/submission.go @@ -2,7 +2,7 @@ package model import "time" -type SubmissionStatus int32 +type SubmissionStatus uint32 const ( // Phase: Creation @@ -26,7 +26,7 @@ const ( ) type Submission struct { - ID int64 `gorm:"primaryKey"` + ID uint64 `gorm:"primaryKey"` DisplayName string Creator string GameID uint32