Adding models, DB access, signup, login
* Created Base, Auth, User and Admin models * Added skeleton API structure containing: User signup, User & Admin login, authorized zones, ping tests * Simple user signup functional * Skeleton user login functional, no means to verify as of yet * Added POSTMAN file
This commit is contained in:
31
models/base.go
Normal file
31
models/base.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
Uid uuid.UUID `gorm:"type:uuid;primary_key;"`
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
Deleted time.Time `sql:"index"`
|
||||
Tenant uuid.UUID
|
||||
}
|
||||
|
||||
func (b *Base) BeforeCreate(scope *gorm.DB) error {
|
||||
b.Uid = uuid.New()
|
||||
b.Created = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Base) BeforeSave(tx *gorm.DB) error {
|
||||
b.Updated = time.Now()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Base) Delete() {
|
||||
b.Deleted = time.Now()
|
||||
}
|
||||
Reference in New Issue
Block a user