enroll controller + db connection
This commit is contained in:
1 parent
b069ee1aa2
commit
f8d006fe8b
12 files changed
+186
-48
No files matched your search
@@ -1,6 +1,10 @@
|
||||
package models
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type Contact struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
@@ -13,4 +17,6 @@ type Contact struct {
|
||||
Email string `json:"email" validate:"required"`
|
||||
Relation string `json:"relation" validate:"required"`
|
||||
PrimaryContact bool `json:"primaraycontact" validate:"required"`
|
||||
Created_at time.Time `json:"created_at"`
|
||||
Updated_at time.Time `json:"updated_at"`
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package models
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type Course struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
@@ -8,4 +12,6 @@ type Course struct {
|
||||
Description string `json:"description"`
|
||||
Grade_level int `json:"grade_level" validate:"required"`
|
||||
Credits int `json:"credits" validate:"required"`
|
||||
Created_at time.Time `json:"created_at"`
|
||||
Updated_at time.Time `json:"updated_at"`
|
||||
}
|
||||
+19
-1
@@ -1,6 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
@@ -12,7 +17,7 @@ type Student struct {
|
||||
Age int `json:"age" validate:"required"`
|
||||
GradeLevel int `json:"gradelevel" validate:"required"`
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required,min=8,max=32"`
|
||||
Password []byte `json:"password" validate:"required,min=8,max=32"`
|
||||
SID string `json:"sid"` // Student ID
|
||||
PED string `json:"ped"` // Personal Education Number
|
||||
Homeroom string `json:"homeroom"`
|
||||
@@ -25,4 +30,17 @@ type Student struct {
|
||||
DOB string `json:"dob" validate:"required"`
|
||||
Photo string `json:"photo"`
|
||||
Contacts []Contact `json:"contacts"`
|
||||
Created_at time.Time `json:"created_at"`
|
||||
Updated_at time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (s *Student) HashPassword(password string) []byte {
|
||||
hashPass, _ := bcrypt.GenerateFromPassword([]byte(password), 14)
|
||||
return hashPass
|
||||
}
|
||||
|
||||
func (s *Student) GenerateSchoolEmail() string {
|
||||
var email string = strings.ToLower(string(s.FirstName[0])) + "." + strings.ToLower(s.LastName) + "@surreyschools.ca"
|
||||
// Add check to see if email already exists
|
||||
return email
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
package models
|
||||
|
||||
import "go.mongodb.org/mongo-driver/bson/primitive"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type Teacher struct {
|
||||
ID primitive.ObjectID `bson:"_id"`
|
||||
@@ -17,4 +21,6 @@ type Teacher struct {
|
||||
PC string `json:"pc"` // Postal Code
|
||||
DOB string `json:"dob" validate:"required"`
|
||||
Photo string `json:"string"`
|
||||
Created_at time.Time `json:"created_at"`
|
||||
Updated_at time.Time `json:"updated_at"`
|
||||
}
|
||||
Reference in new issue
Block a user