replace aid, tid and sid with uid for general user-id input
This commit is contained in:
5 files changed
+80
-80
No files matched your search
@@ -358,7 +358,7 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["sid"] == "" {
|
||||
if data["uid"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -378,7 +378,7 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -421,7 +421,7 @@ func RemoveTeachersDisabled(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["tid"] == "" {
|
||||
if data["uid"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -440,7 +440,7 @@ func RemoveTeachersDisabled(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.tid": data["tid"]},
|
||||
bson.M{"school.tid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
|
||||
@@ -45,7 +45,7 @@ func UpdateStudentName(c *fiber.Ctx) error {
|
||||
|
||||
// Check id and names are included
|
||||
// Middle name is optional
|
||||
if data["sid"] == "" || data["firstname"] == "" || data["lastname"] == "" {
|
||||
if data["uid"] == "" || data["firstname"] == "" || data["lastname"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -81,7 +81,7 @@ func UpdateStudentName(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -124,7 +124,7 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["sid"] == nil || data["gradelevel"] == nil {
|
||||
if data["uid"] == nil || data["gradelevel"] == nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -142,7 +142,7 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"].(string)},
|
||||
bson.M{"school.sid": data["uid"].(string)},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -195,7 +195,7 @@ func UpdateStudentHomeroom(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["sid"] == "" || data["homeroom"] == "" {
|
||||
if data["uid"] == "" || data["homeroom"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -213,7 +213,7 @@ func UpdateStudentHomeroom(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -363,7 +363,7 @@ func ResetStudentPassword(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included (email must be personal email)
|
||||
if data["sid"] == "" || data["email"] == "" {
|
||||
if data["uid"] == "" || data["email"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -372,7 +372,7 @@ func ResetStudentPassword(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["sid"]}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["uid"]}).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{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -456,7 +456,7 @@ func UpdateStudentLocker(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check id and locker are included
|
||||
if data["sid"] == "" || data["lockernumber"] == "" {
|
||||
if data["uid"] == "" || data["lockernumber"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -485,7 +485,7 @@ func UpdateStudentLocker(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -527,7 +527,7 @@ func UpdateStudentAddress(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["sid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" {
|
||||
if data["uid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -548,7 +548,7 @@ func UpdateStudentAddress(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"sid": data["sid"]},
|
||||
bson.M{"sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -591,7 +591,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["sid"] == "" || data["yog"] == nil {
|
||||
if data["uid"] == "" || data["yog"] == nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -600,7 +600,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var student models.Student
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["sid"].(string)}).Decode(&student)
|
||||
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"school.sid": data["uid"].(string)}).Decode(&student)
|
||||
if findErr != nil {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
@@ -619,7 +619,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"].(string)},
|
||||
bson.M{"school.sid": data["uid"].(string)},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -662,7 +662,7 @@ func RemoveStudentContact(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check id and contact id are included
|
||||
if data["sid"] == "" || data["contactid"] == "" {
|
||||
if data["uid"] == "" || data["contactid"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -693,7 +693,7 @@ func RemoveStudentContact(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -736,7 +736,7 @@ func AddStudentContact(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check id and contact id are included
|
||||
if data["sid"] == "" || data["contactid"] == "" {
|
||||
if data["uid"] == "" || data["contactid"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -767,7 +767,7 @@ func AddStudentContact(c *fiber.Ctx) error {
|
||||
|
||||
result, updateErr := StudentCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.sid": data["sid"]},
|
||||
bson.M{"school.sid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -929,14 +929,14 @@ func UpdateStudentEmail(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
if verifiedAdmin && data["sid"] == "" {
|
||||
if verifiedAdmin && data["uid"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
"message": "missing required fields",
|
||||
})
|
||||
} else if verifiedAdmin {
|
||||
sid = data["sid"]
|
||||
sid = data["uid"]
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
|
||||
@@ -50,7 +50,7 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["tid"] == "" || data["homeroom"] == "" {
|
||||
if data["uid"] == "" || data["homeroom"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -68,7 +68,7 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.tid": data["tid"]},
|
||||
bson.M{"school.tid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -216,7 +216,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included (email must be personal email)
|
||||
if data["tid"] == "" || data["email"] == "" {
|
||||
if data["uid"] == "" || data["email"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -225,7 +225,7 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"school.tid": data["tid"]}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"school.tid": data["uid"]}).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{"school.tid": data["tid"]},
|
||||
bson.M{"school.tid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -309,7 +309,7 @@ func UpdateTeacherAddress(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
if data["tid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" {
|
||||
if data["uid"] == "" || data["address"] == "" || data["city"] == "" || data["province"] == "" || data["postal"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -330,7 +330,7 @@ func UpdateTeacherAddress(c *fiber.Ctx) error {
|
||||
|
||||
_, updateErr := TeacherCollection.UpdateOne(
|
||||
ctx,
|
||||
bson.M{"school.tid": data["tid"]},
|
||||
bson.M{"school.tid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
@@ -492,14 +492,14 @@ func UpdateTeacherEmail(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
if verifiedAdmin && data["tid"] == "" {
|
||||
if verifiedAdmin && data["uid"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
"message": "missing required fields",
|
||||
})
|
||||
} else if verifiedAdmin {
|
||||
tid = data["tid"]
|
||||
tid = data["uid"]
|
||||
}
|
||||
|
||||
// Check required fields are included
|
||||
@@ -563,7 +563,7 @@ func UpdateTeacherName(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// Check id and names are included
|
||||
if data["tid"] == "" || data["firstname"] == "" || data["lastname"] == "" {
|
||||
if data["uid"] == "" || data["firstname"] == "" || data["lastname"] == "" {
|
||||
cancel()
|
||||
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{
|
||||
"success": false,
|
||||
@@ -573,7 +573,7 @@ func UpdateTeacherName(c *fiber.Ctx) error {
|
||||
|
||||
// Get teacher
|
||||
var teacher models.Teacher
|
||||
findErr := TeacherCollection.FindOne(ctx, bson.M{"school.tid": data["tid"]}).Decode(&teacher)
|
||||
findErr := TeacherCollection.FindOne(ctx, bson.M{"school.tid": data["uid"]}).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{"school.tid": data["tid"]},
|
||||
bson.M{"school.tid": data["uid"]},
|
||||
update,
|
||||
)
|
||||
if updateErr != nil {
|
||||
|
||||
Reference in new issue
Block a user