29 lines
644 B
Go
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)
|
|
} |