workshop/internal/controllers/workHistoryController.go
Dmitry Sirotkin 9677e0d7ab 4
2025-03-28 19:03:56 +03:00

29 lines
644 B
Go

package controllers
import (
"gocommunity.ru/workshop/internal/api"
"gocommunity.ru/workshop/internal/models"
u "gocommunity.ru/workshop/internal/utils"
"encoding/json"
"net/http"
)
var GetEmployeesReport = func(w http.ResponseWriter, r *http.Request) {
request := &api.WorkReportRequest{}
workHistory := &models.WorkHistory{}
err := json.NewDecoder(r.Body).Decode(request)
if err != nil {
u.Respond(w, u.Message(false, "Errorz!"))
return
}
data := workHistory.GetHistoryByDateAndEmployeeId(request.Start, request.Finish, request.EmployeeId)
resp := u.Message(true, "success")
resp["data"] = data
u.Respond(w, resp)
}