mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
добавил ручки для фронта
This commit is contained in:
@@ -57,3 +57,15 @@ func (h *OCRHandler) SaveMatch(c *gin.Context) {
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"status": "saved"})
|
||||
}
|
||||
|
||||
// GetMatches возвращает список всех обученных связей
|
||||
func (h *OCRHandler) GetMatches(c *gin.Context) {
|
||||
matches, err := h.service.GetKnownMatches()
|
||||
if err != nil {
|
||||
logger.Log.Error("Ошибка получения списка матчей", zap.Error(err))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, matches)
|
||||
}
|
||||
|
||||
37
internal/transport/http/handlers/recommendations.go
Normal file
37
internal/transport/http/handlers/recommendations.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"rmser/internal/services/recommend"
|
||||
"rmser/pkg/logger"
|
||||
)
|
||||
|
||||
type RecommendationsHandler struct {
|
||||
service *recommend.Service
|
||||
}
|
||||
|
||||
func NewRecommendationsHandler(service *recommend.Service) *RecommendationsHandler {
|
||||
return &RecommendationsHandler{service: service}
|
||||
}
|
||||
|
||||
// GetRecommendations godoc
|
||||
// @Summary Получить список рекомендаций
|
||||
// @Description Возвращает сгенерированные рекомендации (проблемные зоны учета)
|
||||
// @Tags recommendations
|
||||
// @Produce json
|
||||
// @Success 200 {array} recommendations.Recommendation
|
||||
// @Failure 500 {object} map[string]string
|
||||
func (h *RecommendationsHandler) GetRecommendations(c *gin.Context) {
|
||||
recs, err := h.service.GetRecommendations()
|
||||
if err != nil {
|
||||
logger.Log.Error("Ошибка получения рекомендаций", zap.Error(err))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, recs)
|
||||
}
|
||||
Reference in New Issue
Block a user