Documentation ¶
Index ¶
- func CreateAdmin(db *mongo.Client, api *goforces.Client, admins []AdminCreate, ...) ([]user.UserCredentials, error)
- func CreateAdminFile(db *mongo.Client, request, databaseName, collectionName string) ([]user.UserCredentials, error)
- func DeleteAdmin(db *mongo.Client, admin Admin, databaseName, collectionName string) error
- func UpdateAdmin(db *mongo.Client, api *goforces.Client, admin AdminUpdate, ...) error
- func UpdateAdminStudent(db *mongo.Client, api *goforces.Client, admin AdminUpdateStudent, ...) error
- type Admin
- type AdminCreate
- type AdminInfo
- type AdminUpdate
- type AdminUpdateStudent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAdmin ¶
func CreateAdmin(db *mongo.Client, api *goforces.Client, admins []AdminCreate, databaseName, collectionName string) ([]user.UserCredentials, error)
CreateAdmin receive a list of students Checks if that list is not null (can't insert null list) Insert each student individually in database @param db pointer to database @param students list of students @param databaseName name of database @param collectionName name of collection @return error function error TODO : Insert all students at the same time (if possible)
func CreateAdminFile ¶
func CreateAdminFile(db *mongo.Client, request, databaseName, collectionName string) ([]user.UserCredentials, error)
CreateAdminFile receive a csv file in that current format : https://github.com/apc-unb/tree/master/components/student calls getAdminFromFile() that return list of AdminCreate and insert into db @param db pointer to database @param request all data to be parsed @param databaseName name of database @param collectionName name of collection @return error function error
func DeleteAdmin ¶
func UpdateAdmin ¶
func UpdateAdmin(db *mongo.Client, api *goforces.Client, admin AdminUpdate, databaseName, collectionName string) error
UpdateAdmins receive admin (updated) Checks if admin old password matches with db to update that admin password or email @param db pointer to database (updated) @param api codeforces api @param admin list of admins @param databaseName name of database @param collectionName name of collection @return error function error TODO : Update all students at the same time (if possible)
func UpdateAdminStudent ¶
func UpdateAdminStudent(db *mongo.Client, api *goforces.Client, admin AdminUpdateStudent, databaseName, studentCollectionName, adminLoginCollectionName string) error
UpdateAdminStudent receive update stundets data, receive a student (updated) @param db pointer to database (updated) @param api codeforces api @param admin student to be updated @param databaseName name of database @param collectionName name of collection @return error function error
Types ¶
type Admin ¶
type Admin struct { ID primitive.ObjectID `bson:"_id,omitempty"` ClassID primitive.ObjectID `bson:"classid,omitempty"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Matricula string `json:"matricula"` PhotoURL string `json:"photourl"` Email string `json:"email"` Projects int32 `json:"projects"` Professor bool `json:"professor"` }
Admin contains all admin data
type AdminCreate ¶
type AdminCreate struct { ClassID primitive.ObjectID `bson:"classid,omitempty"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Matricula string `json:"matricula"` PhotoURL string `json:"photourl"` Email string `json:"email"` Projects int32 `json:"projects"` Professor bool `json:"professor"` }
AdminCreate contais all admin data except from ID
type AdminInfo ¶
type AdminInfo struct { ID primitive.ObjectID `bson:"_id,omitempty"` ClassID primitive.ObjectID `bson:"classid,omitempty"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Matricula string `json:"matricula"` PhotoURL string `json:"photourl"` Email string `json:"email"` Projects int32 `json:"projects"` Professor bool `json:"professor"` }
AdminInfo contais all admin data except from Password
func AuthAdmin ¶
func AuthAdmin(db *mongo.Client, admin user.UserCredentials, databaseName, collectionName string) (AdminInfo, error)
AuthAdmin recieve an admin (to be authenticated) Checks if that login and password exist in database @param db pointer to database @param admin admin matricula and password @param databaseName name of database @param collectionName name of collection @return AdminInfo json if exist plus all admin data @return error function error
func GetAdmins ¶
GetAdmins return list of all students from Database Get all students at the same time and store inside cursor Decode each student inside student class and append into students array @param db pointer to database @param databaseName name of database @param collectionName name of collection @return []Student list of all students @return error function error
type AdminUpdate ¶
type AdminUpdate struct { ID primitive.ObjectID `bson:"_id,omitempty"` ClassID primitive.ObjectID `bson:"classid,omitempty"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Matricula string `json:"matricula"` PhotoURL string `json:"photourl"` Email string `json:"email"` Projects int32 `json:"projects"` Password string `json:"password"` NewPassword string `json:"newpassword"` }
AdminUpdate contais all data that admin can update
type AdminUpdateStudent ¶
type AdminUpdateStudent struct { AdminID primitive.ObjectID `bson:"adminid,omitempty"` StudentID primitive.ObjectID `bson:"studentid,omitempty"` ClassID primitive.ObjectID `bson:"classid,omitempty"` AdminPassword string `json:"adminpassword"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Matricula string `json:"matricula"` Handles student.StudentHandles `json:"handles"` PhotoURL string `json:"photourl"` Email string `json:"email"` Grades student.StudentGrades `json:"grades"` }
AdminUpdateStudent all data of a student to be updated