package db

import (
	"time"

	uuid "github.com/satori/go.uuid"
	"gorm.io/gorm"
)

type Base struct {
	ID        *uuid.UUID `gorm:"type:uuid;primary_key" json:"id" ownJson:"id" adminJson:"id" teamleadJson:"id"`
	CreatedAt time.Time  `json:"created_at" ownJson:"created_at" adminJson:"created_at" teamleadJson:"created_at"`
	UpdatedAt time.Time  `json:"updated_at" ownJson:"updated_at" adminJson:"updated_at" teamleadJson:"updated_at"`
}

func (b *Base) BeforeCreate(_ *gorm.DB) error {
	id := uuid.NewV4()
	b.ID = &id
	return nil
}
