shorter data names
This commit is contained in:
7 files changed
+59
-59
No files matched your search
@@ -237,7 +237,7 @@ func Enroll(c *fiber.Ctx) error {
|
||||
}
|
||||
student.Personal.LastName = data["lastname"].(string)
|
||||
student.Personal.Age = data["age"].(float64)
|
||||
student.SchoolData.GradeLevel = data["gradelevel"].(float64)
|
||||
student.School.GradeLevel = data["gradelevel"].(float64)
|
||||
student.Personal.DOB = data["dob"].(string)
|
||||
student.Personal.Email = data["email"].(string)
|
||||
student.Personal.Province = data["province"].(string)
|
||||
@@ -245,7 +245,7 @@ func Enroll(c *fiber.Ctx) error {
|
||||
student.Personal.Address = data["address"].(string)
|
||||
student.Personal.Postal = data["postal"].(string)
|
||||
student.Personal.Contacts = []string{}
|
||||
student.SchoolData.YOG = ((12 - int(student.SchoolData.GradeLevel)) + time.Now().Year()) + 1
|
||||
student.School.YOG = ((12 - int(student.School.GradeLevel)) + time.Now().Year()) + 1
|
||||
|
||||
var photo models.Photo
|
||||
photo.Name = uuid.New().String()
|
||||
@@ -256,7 +256,7 @@ func Enroll(c *fiber.Ctx) error {
|
||||
defaultImage, _ := os.ReadFile("./database/defaultImage.txt")
|
||||
photo.Base64 = string(defaultImage)
|
||||
|
||||
student.SchoolData.PhotoName = photo.Name
|
||||
student.School.PhotoName = photo.Name
|
||||
|
||||
var schoolEmail string = ""
|
||||
offset := 0
|
||||
@@ -285,7 +285,7 @@ func Enroll(c *fiber.Ctx) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
student.SchoolData.SID = sid
|
||||
student.School.SID = sid
|
||||
|
||||
// Send student personal email student ID
|
||||
subject := "Account Registered"
|
||||
@@ -307,7 +307,7 @@ func Enroll(c *fiber.Ctx) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
student.SchoolData.PEN = pen
|
||||
student.School.PEN = pen
|
||||
|
||||
student.Created_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
student.Updated_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
@@ -426,7 +426,7 @@ func RegisterTeacher(c *fiber.Ctx) error {
|
||||
defaultImage, _ := os.ReadFile("./database/defaultImage.txt")
|
||||
photo.Base64 = string(defaultImage)
|
||||
|
||||
teacher.SchoolData.PhotoName = photo.Name
|
||||
teacher.School.PhotoName = photo.Name
|
||||
|
||||
var schoolEmail string = ""
|
||||
offset := 0
|
||||
@@ -455,7 +455,7 @@ func RegisterTeacher(c *fiber.Ctx) error {
|
||||
break
|
||||
}
|
||||
}
|
||||
teacher.SchoolData.TID = tid
|
||||
teacher.School.TID = tid
|
||||
|
||||
// Send teacher personal email student ID
|
||||
subject := "Account Registered"
|
||||
@@ -633,7 +633,7 @@ func StudentLogin(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var student models.Student
|
||||
err := StudentCollection.FindOne(ctx, bson.M{"schooldata.sid": data["sid"]}).Decode(&student)
|
||||
err := StudentCollection.FindOne(ctx, bson.M{"School.sid": data["sid"]}).Decode(&student)
|
||||
|
||||
if err != nil {
|
||||
cancel()
|
||||
@@ -666,7 +666,7 @@ func StudentLogin(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -715,7 +715,7 @@ func StudentLogin(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
cancel()
|
||||
@@ -742,7 +742,7 @@ func StudentLogin(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -757,7 +757,7 @@ func StudentLogin(c *fiber.Ctx) error {
|
||||
defer cancel()
|
||||
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{
|
||||
Issuer: student.SchoolData.SID,
|
||||
Issuer: student.School.SID,
|
||||
ExpiresAt: time.Now().Add(time.Hour * 24).Unix(), // 1 Day
|
||||
})
|
||||
token, err := claims.SignedString([]byte(SecretKey))
|
||||
@@ -805,7 +805,7 @@ func TeacherLogin(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var teacher models.Teacher
|
||||
err := TeacherCollection.FindOne(ctx, bson.M{"schooldata.tid": data["tid"]}).Decode(&teacher)
|
||||
err := TeacherCollection.FindOne(ctx, bson.M{"School.tid": data["tid"]}).Decode(&teacher)
|
||||
defer cancel()
|
||||
|
||||
if err != nil {
|
||||
@@ -827,7 +827,7 @@ func TeacherLogin(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
claims := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.StandardClaims{
|
||||
Issuer: teacher.SchoolData.TID,
|
||||
Issuer: teacher.School.TID,
|
||||
ExpiresAt: time.Now().Add(time.Hour * 24).Unix(), // 1 Day
|
||||
})
|
||||
token, err := claims.SignedString([]byte(SecretKey))
|
||||
@@ -968,7 +968,7 @@ func Student(c *fiber.Ctx) error {
|
||||
responseData["photo"] = nil
|
||||
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"schooldata.sid": sid}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"School.sid": sid}).Decode(&student)
|
||||
if findErr != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -986,8 +986,8 @@ func Student(c *fiber.Ctx) error {
|
||||
responseData["student"] = student
|
||||
|
||||
var locker models.Locker
|
||||
if student.SchoolData.Locker != "" {
|
||||
LockerCollection.FindOne(context.TODO(), bson.M{"ID": student.SchoolData.Locker}).Decode(&locker)
|
||||
if student.School.Locker != "" {
|
||||
LockerCollection.FindOne(context.TODO(), bson.M{"ID": student.School.Locker}).Decode(&locker)
|
||||
responseData["locker"] = locker
|
||||
}
|
||||
|
||||
@@ -1005,7 +1005,7 @@ func Student(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var photo models.Photo
|
||||
findErr = ImageCollection.FindOne(context.TODO(), bson.M{"name": student.SchoolData.PhotoName}).Decode(&photo)
|
||||
findErr = ImageCollection.FindOne(context.TODO(), bson.M{"name": student.School.PhotoName}).Decode(&photo)
|
||||
if findErr != nil {
|
||||
responseData["error"] = "Error! There was an error finding the student photo"
|
||||
}
|
||||
@@ -1033,7 +1033,7 @@ func Teacher(c *fiber.Ctx) error {
|
||||
claims := token.Claims.(*jwt.StandardClaims)
|
||||
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"schooldata.tid": claims.Issuer}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"School.tid": claims.Issuer}).Decode(&teacher)
|
||||
if findErr != nil {
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -1269,7 +1269,7 @@ func RemoveStudent(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
_, deleteErr = StudentCollection.DeleteOne(ctx, bson.M{"schooldata.sid": data["sid"]})
|
||||
_, deleteErr = StudentCollection.DeleteOne(ctx, bson.M{"School.sid": data["sid"]})
|
||||
if deleteErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
@@ -1327,7 +1327,7 @@ func RemoveTeacher(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
_, deleteErr = TeacherCollection.DeleteOne(ctx, bson.M{"schooldata.tid": data["tid"]})
|
||||
_, deleteErr = TeacherCollection.DeleteOne(ctx, bson.M{"School.tid": data["tid"]})
|
||||
if deleteErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
|
||||
@@ -37,7 +37,7 @@ func ValidateID(id string, userType int) bool { // true: valid id, false: id alr
|
||||
func ValidatePEN(pen string) bool { // true: valid pen, false: pen already in use
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
var foundID models.Id
|
||||
err := StudentCollection.FindOne(ctx, bson.M{"schooldata.pen": pen}).Decode(&foundID)
|
||||
err := StudentCollection.FindOne(ctx, bson.M{"School.pen": pen}).Decode(&foundID)
|
||||
cancel()
|
||||
return err != nil
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -440,7 +440,7 @@ func RemoveTeachersDisabled(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": data["tid"]},
|
||||
bson.M{"School.tid": data["tid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
|
||||
@@ -81,7 +81,7 @@ func UpdateStudentName(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -135,14 +135,14 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error {
|
||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
update := bson.M{
|
||||
"$set": bson.M{
|
||||
"schooldata.gradelevel": data["gradelevel"].(float64),
|
||||
"School.gradelevel": data["gradelevel"].(float64),
|
||||
"updated_at": update_time,
|
||||
},
|
||||
}
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"].(string)},
|
||||
bson.M{"School.sid": data["sid"].(string)},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -206,14 +206,14 @@ func UpdateStudentHomeroom(c *fiber.Ctx) error {
|
||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
update := bson.M{
|
||||
"$set": bson.M{
|
||||
"schooldata.homeroom": data["homeroom"],
|
||||
"School.homeroom": data["homeroom"],
|
||||
"updated_at": update_time,
|
||||
},
|
||||
}
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -261,7 +261,7 @@ func UpdateStudentPassword(c *fiber.Ctx) error {
|
||||
claims := token.Claims.(*jwt.StandardClaims)
|
||||
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(ctx, bson.M{"schooldata.sid": claims.Issuer}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(ctx, bson.M{"School.sid": claims.Issuer}).Decode(&student)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -317,7 +317,7 @@ func UpdateStudentPassword(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": claims.Issuer},
|
||||
bson.M{"School.sid": claims.Issuer},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -372,7 +372,7 @@ func ResetStudentPassword(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"schooldata.sid": data["sid"]}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"School.sid": data["sid"]}).Decode(&student)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -401,7 +401,7 @@ func ResetStudentPassword(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -478,14 +478,14 @@ func UpdateStudentLocker(c *fiber.Ctx) error {
|
||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
update := bson.M{
|
||||
"$set": bson.M{
|
||||
"schooldata.locker": locker.ID,
|
||||
"School.locker": locker.ID,
|
||||
"updated_at": update_time,
|
||||
},
|
||||
}
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -600,7 +600,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"schooldata.sid": data["sid"].(string)}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"School.sid": data["sid"].(string)}).Decode(&student)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -612,14 +612,14 @@ func UpdateStudentYOG(c *fiber.Ctx) error {
|
||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
update := bson.M{
|
||||
"$set": bson.M{
|
||||
"schooldata.yog": data["yog"].(int),
|
||||
"School.yog": data["yog"].(int),
|
||||
"updated_at": update_time,
|
||||
},
|
||||
}
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"].(string)},
|
||||
bson.M{"School.sid": data["sid"].(string)},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -693,7 +693,7 @@ func RemoveStudentContact(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -767,7 +767,7 @@ func AddStudentContact(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": data["sid"]},
|
||||
bson.M{"School.sid": data["sid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -810,7 +810,7 @@ func UpdateStudentPhoto(c *fiber.Ctx) error {
|
||||
|
||||
// Get student
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"schooldata.sid": sid}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"School.sid": sid}).Decode(&student)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -833,7 +833,7 @@ func UpdateStudentPhoto(c *fiber.Ctx) error {
|
||||
|
||||
// Get student photo
|
||||
var photo models.Photo
|
||||
findErr = ImageCollection.FindOne(context.TODO(), bson.M{"name": student.SchoolData.PhotoName}).Decode(&photo)
|
||||
findErr = ImageCollection.FindOne(context.TODO(), bson.M{"name": student.School.PhotoName}).Decode(&photo)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
@@ -958,7 +958,7 @@ func UpdateStudentEmail(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.sid": sid},
|
||||
bson.M{"School.sid": sid},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
|
||||
@@ -61,14 +61,14 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error {
|
||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||
update := bson.M{
|
||||
"$set": bson.M{
|
||||
"schooldata.homeroom": data["homeroom"],
|
||||
"School.homeroom": data["homeroom"],
|
||||
"updated_at": update_time,
|
||||
},
|
||||
}
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": data["tid"]},
|
||||
bson.M{"School.tid": data["tid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -116,7 +116,7 @@ func UpdateTeacherPassword(c *fiber.Ctx) error {
|
||||
claims := token.Claims.(*jwt.StandardClaims)
|
||||
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(ctx, bson.M{"schooldata.tid": claims.Issuer}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(ctx, bson.M{"School.tid": claims.Issuer}).Decode(&teacher)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -172,7 +172,7 @@ func UpdateTeacherPassword(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": claims.Issuer},
|
||||
bson.M{"School.tid": claims.Issuer},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -225,7 +225,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"schooldata.tid": data["tid"]}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"School.tid": data["tid"]}).Decode(&teacher)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -254,7 +254,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": data["tid"]},
|
||||
bson.M{"School.tid": data["tid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -330,7 +330,7 @@ func UpdateTeacherAddress(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": data["tid"]},
|
||||
bson.M{"School.tid": data["tid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -372,7 +372,7 @@ func UpdateTeacherPhoto(c *fiber.Ctx) error {
|
||||
|
||||
// Get teacher
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"schooldata.tid": tid}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"School.tid": tid}).Decode(&teacher)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -395,7 +395,7 @@ func UpdateTeacherPhoto(c *fiber.Ctx) error {
|
||||
|
||||
// Get student photo
|
||||
var photo models.Photo
|
||||
findErr = ImageCollection.FindOne(context.TODO(), bson.M{"name": teacher.SchoolData.PhotoName}).Decode(&photo)
|
||||
findErr = ImageCollection.FindOne(context.TODO(), bson.M{"name": teacher.School.PhotoName}).Decode(&photo)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
@@ -521,7 +521,7 @@ func UpdateTeacherEmail(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": tid},
|
||||
bson.M{"School.tid": tid},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -573,7 +573,7 @@ func UpdateTeacherName(c *fiber.Ctx) error {
|
||||
|
||||
// Get teacher
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(ctx, bson.M{"schooldata.tid": data["tid"]}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(ctx, bson.M{"School.tid": data["tid"]}).Decode(&teacher)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -601,7 +601,7 @@ func UpdateTeacherName(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"schooldata.tid": data["tid"]},
|
||||
bson.M{"School.tid": data["tid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
|
||||
@@ -36,7 +36,7 @@ type Student struct {
|
||||
DOB string `json:"dob" validate:"required"`
|
||||
Contacts []string `json:"contacts"` // List of contact ID's rather than contact object
|
||||
} `json:"Personal"`
|
||||
SchoolData struct {
|
||||
School struct {
|
||||
GradeLevel float64 `json:"gradelevel" validate:"required"`
|
||||
SID string `json:"sid"` // Student ID
|
||||
PEN string `json:"ped"` // Personal Education Number
|
||||
@@ -44,7 +44,7 @@ type Student struct {
|
||||
Locker string `json:"-"` // Locker ID
|
||||
YOG int `json:"yog"` // Year of Graduation
|
||||
PhotoName string `json:"photoname"` // name of photo in db
|
||||
} `json:"schooldata"`
|
||||
} `json:"School"`
|
||||
Account struct {
|
||||
VerifiedEmail bool `json:"verifiedemail"`
|
||||
SchoolEmail string `json:"schoolemail"`
|
||||
|
||||
@@ -39,11 +39,11 @@ type Teacher struct {
|
||||
Postal string `json:"postal"`
|
||||
DOB string `json:"dob" validate:"required"`
|
||||
} `json:"Personal"`
|
||||
SchoolData struct {
|
||||
School struct {
|
||||
TID string `json:"tid"` // Teacher ID
|
||||
Homeroom string `json:"homeroom"`
|
||||
PhotoName string `json:"photoname"` // name of photo in db
|
||||
} `json:"schooldata"`
|
||||
} `json:"School"`
|
||||
Account struct {
|
||||
VerifiedEmail bool `json:"verifiedemail"`
|
||||
SchoolEmail string `json:"schoolemail"`
|
||||
|
||||
Reference in new issue
Block a user