This commit is contained in:
2025-03-19 14:55:12 +08:00
commit d746bc3935
11 changed files with 854 additions and 0 deletions

31
controllers/train.go Normal file
View File

@ -0,0 +1,31 @@
package controllers
import (
"github.com/gin-gonic/gin"
"hr_receiver/config"
"hr_receiver/models"
"net/http"
)
func ReceiveTrainingData(c *gin.Context) {
var data models.TrainingData
if err := c.ShouldBindJSON(&data); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": "Invalid request body: " + err.Error(),
})
return
}
if result := config.DB.Create(&data); result.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"error": "Failed to save data: " + result.Error.Error(),
})
return
}
c.JSON(http.StatusCreated, gin.H{
"message": "Data saved successfully",
"id": data.ID,
})
}