|
@@ -30,7 +30,7 @@ func CheckRoute(w http.ResponseWriter, r *http.Request){
|
|
|
func planWithExample(w http.ResponseWriter, r *http.Request){
|
|
|
var subject Subjectofplan
|
|
|
json.NewDecoder(r.Body).Decode(&subject) // Декодируем JSON в экземпляр структуры
|
|
|
- if subject != nil { // Проверка на пустой POST-запрос
|
|
|
+ if subject.ID <= 0 { // Проверка на пустой POST-запрос
|
|
|
json.NewEncoder(w).Encode(struct{ Error string }{ Error: "error during processing data" })
|
|
|
return
|
|
|
}
|
|
@@ -48,12 +48,12 @@ func planWithExample(w http.ResponseWriter, r *http.Request){
|
|
|
if subOfExample.Totalhours>=subject.Hoursquantitytotal{ // Если все в порядке, то возвращаем true и количество вариативных часов
|
|
|
var checkResult CheckResult
|
|
|
checkResult.Status = true
|
|
|
- checkResult.Hours = subOfExample.Totalhours-subject.Hoursquantitytotal
|
|
|
+ checkResult.Hours = int(subOfExample.Totalhours)-int(subject.Hoursquantitytotal)
|
|
|
json.NewEncoder(w).Encode(checkResult)
|
|
|
} else{ // Если нет - возвращаем false и недостающее количество часов
|
|
|
var checkResult CheckResult
|
|
|
checkResult.Status = false
|
|
|
- checkResult.Hours = subject.Hoursquantitytotal-subOfExample.Totalhours
|
|
|
+ checkResult.Hours = int(subject.Hoursquantitytotal)-int(subOfExample.Totalhours)
|
|
|
json.NewEncoder(w).Encode(checkResult)
|
|
|
}
|
|
|
}
|