diff --git a/internal/class/model/class.go b/internal/class/model/class.go new file mode 100644 index 0000000..21bd426 --- /dev/null +++ b/internal/class/model/class.go @@ -0,0 +1,22 @@ +package classmodel + +import ( + "github.com/EngineerProOrg/BE-K01/internal/room/model" + "github.com/EngineerProOrg/BE-K01/internal/course/model" + "github.com/EngineerProOrg/BE-K01/internal/professor/model" +) + +type Class struct { + Class_id int `json:"class_id" gorm:"column:CLASS_ID;primaryKey"` + Class_name string `json:"class_name" gorm:"column:CLASS_NAME"` + Prof_id int `json:"prof_id" gorm:"column:PROF_ID"` + Prof professormodel.Professor `json:"prof" gorm:"preload:false"` + Course_id int `json:"course_id" gorm:"column:COURSE_ID"` + Course coursemodel.Course `json:"course" gorm:"preload:false"` + Room_id int `json:"room_id" gorm:"column:ROOM_ID"` + Room roommodel.Room `json:"room" gorm:"preload:false"` +} + +func (Class) TableName() string { + return "CLASS" +} \ No newline at end of file diff --git a/internal/course/model/course.go b/internal/course/model/course.go new file mode 100644 index 0000000..215618e --- /dev/null +++ b/internal/course/model/course.go @@ -0,0 +1,16 @@ +// create table COURSE ( +// COURSE_ID int primary key, +// COURSE_NAME varchar(255) +// ) + + +package coursemodel + +type Course struct { + Course_id int `json:"course_id" gorm:"column:COURSE_ID;primaryKey"` + Course_name string `json:"course_name" gorm:"column:COURSE_NAME"` +} + +func (Course) TableName() string { + return "COURSE" +} \ No newline at end of file diff --git a/internal/enroll/model/enroll.go b/internal/enroll/model/enroll.go new file mode 100644 index 0000000..0a8db57 --- /dev/null +++ b/internal/enroll/model/enroll.go @@ -0,0 +1,27 @@ +package enrollmodel + +import ( + "github.com/EngineerProOrg/BE-K01/internal/class/model" + "github.com/EngineerProOrg/BE-K01/internal/student/model" +) + +// create table ENROLL( +// STUD_ID int, +// CLASS_ID int, +// GRADE varchar(3), +// foreign key (STUD_ID) references STUDENT(STUD_ID), +// foreign key (CLASS_ID) references CLASS(CLASS_ID), +// PRIMARY KEY (STUD_ID, CLASS_ID) +// ) + +type Enroll struct { + Stud_id int `json:"stud_id" gorm:"column:STUD_ID;primaryKey"` + Stud studentmodel.Student `json:"stud" gorm:"preload:false"` + Class_id int `json:"class_id" gorm:"column:CLASS_ID;primaryKey"` + Class classmodel.Class `json:"class" gorm:"preload:false"` + Grade string `json:"grade" gorm:"column:GRADE"` +} + +func (Enroll) TableName() string { + return "ENROLL" +} \ No newline at end of file diff --git a/internal/professor/model/professor.go b/internal/professor/model/professor.go new file mode 100644 index 0000000..8d8753d --- /dev/null +++ b/internal/professor/model/professor.go @@ -0,0 +1,11 @@ +package professormodel + +type Professor struct { + Prof_id int `json:"prof_id" gorm:"column:PROF_ID;primaryKey"` + Prof_lname string `json:"prof_name" gorm:"column:PROF_NAME"` + Prof_fname string `json:"prof_fname" gorm:"column:PROF_FNAME"` +} + +func (Professor) TableName() string { + return "PROFESSOR" +} \ No newline at end of file diff --git a/internal/room/model/room.go b/internal/room/model/room.go new file mode 100644 index 0000000..31200c0 --- /dev/null +++ b/internal/room/model/room.go @@ -0,0 +1,19 @@ +package roommodel + + +// create table ROOM ( +// ROOM_ID int primary key, +// ROOM_LOC varchar(50), +// ROOM_CAP varchar(50), +// CLASS_ID int +// ) +type Room struct { + Room_id int `json:"room_id" gorm:"column:ROOM_ID;primaryKey"` + Room_loc string `json:"room_loc" gorm:"column:ROOM_LOC"` + Room_cap string `json:"room_cap" gorm:"column:ROOM_CAP"` + Class_id int `json:"class_id" gorm:"column:CLASS_ID"` +} + +func (Room) TableName() string { + return "ROOM" +} \ No newline at end of file diff --git a/internal/student/model/student.go b/internal/student/model/student.go new file mode 100644 index 0000000..00c1c50 --- /dev/null +++ b/internal/student/model/student.go @@ -0,0 +1,23 @@ +// create table STUDENT ( +// STUD_ID int primary key, +// STUD_LNAME varchar(50), +// STUD_FNAME varchar(50), +// STUD_STREET varchar(255), +// STUD_CITY varchar(50), +// STUD_ZIP varchar(10) +// ) + +package studentmodel + +type Student struct { + Stud_id int `json:"stud_id" gorm:"column:STUD_ID;primaryKey"` + Stud_lname string `json:"stud_lname" gorm:"column:STUD_LNAME"` + Stud_fname string `json:"stud_fname" gorm:"column:STUD_FNAME"` + Stud_street string `json:"stud_street" gorm:"column:STUD_STREET"` + Stud_city string `json:"stud_city" gorm:"column:STUD_CITY"` + Stud_zip string `json:"stud_zip" gorm:"column:STUD_ZIP"` +} + +func (Student) TableName() string { + return "STUDENT" +} \ No newline at end of file