schoolClass

package
v0.0.0-...-181bd5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: MIT Imports: 5 Imported by: 0

README

APC Class

Get all Classes

  • HTTP Request : GET http://api.com/class

  • Return a list of object in json format as follow

        [
            {
                "id"                    :   ObjectId,
                "professorfirstname"    :   String,
                "professorlastname"     :   String,
                "classname"             :   String,
                "address"               :   String,
                "year"                  :   Integer,
                "season"                :   Integer,
                "contestsids"           :   []Integer,
                "groupid"               :   String
    
            },...
        ]
    

Get all Classes from a professor

  • HTTP Request : GET http://api.com/class/{professorid}

  • Return a list of object in json format as follow

    [
        {
            "ID"                    :   String,
            "ProfessorID"           :   String,
            "professorfirstname"    :   String,
            "professorlastname"     :   String,
            "classname"             :   String,
            "address"               :   String,
            "year"                  :   Integer,
            "season"                :   Integer,
            "contestsids"           :   []Integer,
            "groupid"               :   String
        },...
    ]
    

Create Classes

  • HTTP Request : POST http://api.com/class

  • Send Classes's data in the request body in the following format

  • PS : Only admin with Professor : True can make this request

    [
        {
            "professorfirstname"    :   String,
            "professorlastname"     :   String,
            "classname"             :   String,
            "address"               :   String,
            "year"                  :   Integer,
            "season"                :   Integer,
            `"contestsids"           :   []Integer,
            "groupid"               :   String`
        },...
    ]
    ``
    
  • http StatusCreated (201) will be sent if the class has been created correctly

Update Classes

  • HTTP Request : PUT http://api.com/class

  • Send data in the request body in the following format

  • PS : Only admin with Professor : True can make this request

    [
        {
            "id"                    :   ObjectId,
            "professorfirstname"    :   String,
            "professorlastname"     :   String,
            "classname"             :   String,
            "address"               :   String,
            "year"                  :   Integer,
            "season"                :   Integer,
            "contestsids"           :   []Integer,
            "groupid"               :   String
        }...
    ]
    
  • http StatusCreated (201) will be sent if the student has been updated correctly

Delete Classes

  • HTTP Request : DELETE http://api.com/class

  • Send data in the request body in the following format

  • PS : Only admin with Professor : True can make this request

    [
        {  
            "id" : ObjectId
        },...
    ]
    
  • http StatusOK (200) will be sent if the students have been deleted correctly

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClasses

func CreateClasses(db *mongo.Client, schoolClass []SchoolClassCreate, database_name, collection_name string) error

func DeleteClasses

func DeleteClasses(db *mongo.Client, schoolClass []SchoolClass, database_name, collection_name string) error

func UpdateClass

func UpdateClass(db *mongo.Client, classDAO SchoolClass, database_name, collection_name string) error

Types

type SchoolClass

type SchoolClass struct {
	ID                 primitive.ObjectID `bson:"_id,omitempty"`
	ProfessorID        primitive.ObjectID `bson:"professorid,omitempty"`
	ProfessorFirstName string             `json:"professorfirstname"`
	ProfessorLastName  string             `json:"professorlastname"`
	ClassName          string             `json:"classname"`
	Address            string             `json:"address"`
	Year               int                `json:"year"`
	Season             int                `json:"season"`
	ContestsIDs        []int              `json:"contestsids"`
	GroupID            string             `json:"groupid"`
}

func GetClass

func GetClass(db *mongo.Client, classID primitive.ObjectID, databaseName, collectionName string) (SchoolClass, error)

func GetClassProfessor

func GetClassProfessor(db *mongo.Client, professorID primitive.ObjectID, database_name, collection_name string) ([]SchoolClass, error)

func GetClasses

func GetClasses(db *mongo.Client, database_name, collection_name string) ([]SchoolClass, error)

type SchoolClassCreate

type SchoolClassCreate struct {
	ProfessorID        primitive.ObjectID `bson:"professorid,omitempty"`
	ProfessorFirstName string             `json:"professorfirstname"`
	ProfessorLastName  string             `json:"professorlastname"`
	ClassName          string             `json:"classname"`
	Address            string             `json:"address"`
	Year               int                `json:"year"`
	Season             int                `json:"season"`
	ContestsIDs        []int              `json:"contestsids"`
	GroupID            string             `json:"groupid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL