Browse Source

minor fix

Anton 5 years ago
parent
commit
8bb812fa99
1 changed files with 3 additions and 3 deletions
  1. 3 3
      api/check.go

+ 3 - 3
api/check.go

@@ -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)
 	}
 }