models

package
v0.0.0-...-68ef193 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Course

type Course struct {
	gorm.Model
	Name        string `gorm:"not null"`
	Code        string `gorm:"uniqueIndex;not null"`
	Description string
	TeacherID   uint    `gorm:"not null"` // Reference to Teacher
	Teacher     Teacher `gorm:"foreignKey:TeacherID"`
}

Course represents a course in the system

func (Course) TableName

func (Course) TableName() string

type Enrollment

type Enrollment struct {
	gorm.Model
	StudentID uint    `gorm:"not null"`
	CourseID  uint    `gorm:"not null"`
	Grade     *string // Nullable grade
}

Enrollment represents a student's enrollment in a course

func (Enrollment) TableName

func (Enrollment) TableName() string

type Student

type Student struct {
	gorm.Model
	UserID      uint   `gorm:"uniqueIndex;not null"`
	User        User   `gorm:"foreignKey:UserID"`
	DateOfBirth string `gorm:"type:date"`
	Address     string
	Phone       string
}

Student represents a student in the system

func (Student) TableName

func (Student) TableName() string

type Teacher

type Teacher struct {
	gorm.Model
	UserID  uint   `gorm:"uniqueIndex;not null"`
	User    User   `gorm:"foreignKey:UserID"`
	Subject string `gorm:"not null"`
	Phone   string
}

Teacher represents a teacher in the system

func (Teacher) TableName

func (Teacher) TableName() string

type User

type User struct {
	gorm.Model
	Email     string `gorm:"uniqueIndex;not null"`
	Password  string `gorm:"not null"`
	FirstName string `gorm:"not null"`
	LastName  string `gorm:"not null"`
	Role      string `gorm:"not null"` // admin, teacher, student, parent
}

User represents a user in the system

func (*User) CheckPassword

func (u *User) CheckPassword(password string) error

CheckPassword verifies if the provided password matches the hashed password

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword hashes the password and sets it on the user

func (User) TableName

func (User) TableName() string

Set up table names for all models

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL