- Manager Employees - Teams
- Connect to Database and save information
- Write API for employees and teams
- Install MongoDB
- Create file
.env
in folderemployee/configs
for employee andteam/configs
for team - Configure features in file
.env
the following format in fileenv.example
- We must install package:
tkanos/gonfig
,github.com/go-chi/chi
,go-sql-driver/mysql
by the following:
go get github.com/go-chi/chi
go get github.com/go-sql-driver/mysql
go get github.com/tkanos/gonfig
-
Before running the program, you must set up the MongoDB: 5.1 Schema: employee 5.2 Collection: employee 5.3 Schema: team 5.4 Collection: team
-
Use command:
go run employee/cmd/httpapi/main.go
run employee serve -
Use command:
go run team/cmd/httpapi/main.go
run team serve -
API :
- Get list all employees:
localhost:8282/employees (GET)
- Get list all teams:
localhost:8181/teams (GET)
- Search employee by id:
localhost:8282/employee/{id} (GET)
- Search team by id:
localhost:8181/team/{id} (GET)
- Create employee:
localhost:8282/employee (POST)
Example Body:
{ "name" : "hien", "gender" :2, "dob" : "2001-11-11" }
- Create team:
localhost:8181/team (POST)
Example Body:
{ "name": "pentest" }
- Update employee:
localhost:8282/employee/{id} (PUT)
- Update team:
localhost:8181/team/{id} (PUT)
- Delete employee:
localhost:8282/employee/{id} (DELETE)
- Delete team:
localhost:8181/team/{id} (DELETE)
- Delete/Add employee join to team:
localhost:8282/api/v1/event/employee-team (POST)
- Example Body:
{ "eid":"5b23489a-d6c7-42f6-9a41-65edd53aaf6f", "tid":"6f31a96c-1981-460f-a387-413c655b9edb" }