64 lines
2.4 KiB
Go
64 lines
2.4 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type User struct {
|
|
// WAJIB UUID
|
|
UserID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primaryKey" json:"user_id"`
|
|
NrpNip string `gorm:"unique;not null" json:"nrp_nip"`
|
|
FullName string `gorm:"not null" json:"full_name"`
|
|
Email string `gorm:"unique;not null" json:"email"`
|
|
Phone string `gorm:"not null" json:"phone"`
|
|
PasswordHash string `gorm:"not null" json:"-"`
|
|
Role string `gorm:"type:user_role;default:'student'" json:"role"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type Room struct {
|
|
RoomID uint `gorm:"primaryKey;column:room_id" json:"room_id"`
|
|
Name string `json:"name"`
|
|
Category string `json:"category"`
|
|
Floor string `json:"floor"`
|
|
Capacity int `json:"capacity"`
|
|
Status string `json:"status"`
|
|
PowerConsumption float64 `json:"power_consumption" gorm:"default:0"`
|
|
}
|
|
|
|
type Booking struct {
|
|
BookingID uuid.UUID `gorm:"type:uuid;default:uuid_generate_v4();primaryKey" json:"booking_id"`
|
|
|
|
UserID uuid.UUID `gorm:"type:uuid;not null" json:"user_id"`
|
|
User User `gorm:"foreignKey:UserID;references:UserID" json:"user,omitempty"`
|
|
|
|
RoomID uint `gorm:"not null" json:"room_id"`
|
|
Room Room `gorm:"foreignKey:RoomID;references:RoomID" json:"room"`
|
|
|
|
StartTime time.Time `gorm:"not null" json:"start_time"`
|
|
EndTime time.Time `gorm:"not null" json:"end_time"`
|
|
Purpose string `gorm:"not null" json:"purpose"`
|
|
Status string `gorm:"type:booking_status;default:'Pending'" json:"status"`
|
|
|
|
RedeemCode string `gorm:"type:varchar(10)" json:"redeem_code"`
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (ClassSchedule) TableName() string {
|
|
return "class_schedules"
|
|
}
|
|
|
|
type ClassSchedule struct {
|
|
ScheduleID int `gorm:"primaryKey;autoIncrement;column:schedule_id" json:"schedule_id"`
|
|
KodeMK string `gorm:"type:varchar(50);not null;column:kode_mk" json:"kode_mk"`
|
|
NamaMK string `gorm:"type:varchar(100);not null;column:nama_mk" json:"nama_mk"`
|
|
RoomID int `gorm:"not null;column:room_id" json:"room_id"`
|
|
Room Room `gorm:"foreignKey:RoomID" json:"room"`
|
|
Hari string `gorm:"type:varchar(20);not null;column:hari" json:"hari"`
|
|
JamMulai string `gorm:"type:time;not null;column:jam_mulai" json:"jam_mulai"`
|
|
JamSelesai string `gorm:"type:time;not null;column:jam_selesai" json:"jam_selesai"`
|
|
}
|