This commit is contained in:
[Valentino Heman Budiarto] 2026-03-06 14:00:50 +07:00
parent 54088abf22
commit ff78042fe4
2 changed files with 6 additions and 6 deletions

View File

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"os"
"s-class-backend/models" // Import package models
"s-class-backend/models"
"github.com/joho/godotenv"
"gorm.io/driver/postgres"
@ -14,7 +14,7 @@ import (
var DB *gorm.DB
func ConnectDatabase() {
// Load .env
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
@ -40,9 +40,9 @@ func ConnectDatabase() {
if err != nil {
fmt.Println("Gagal migrasi:", err)
} else {
fmt.Println("Database Migrated!")
fmt.Println("Database Migrated!")
}
fmt.Println("🚀 Sukses terkoneksi ke Database PostgreSQL!")
fmt.Println("Sukses terkoneksi ke Database PostgreSQL!")
DB = database
}

View File

@ -8,7 +8,7 @@ import (
"github.com/gin-gonic/gin"
)
// --- GET ALL ROOMS ---
// GET ALL ROOMS
func GetRooms(c *gin.Context) {
var rooms []models.Room
if err := config.DB.Find(&rooms).Error; err != nil {
@ -18,7 +18,7 @@ func GetRooms(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"data": rooms})
}
// --- CREATE ROOM ---
// CREATE ROOM
func CreateRoom(c *gin.Context) {
var input models.Room
if err := c.ShouldBindJSON(&input); err != nil {