mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
Полноценно редактируются черновики
Добавляются фасовки как в черновике, так и в обучении Исправил внешний вид
This commit is contained in:
@@ -92,6 +92,26 @@ func (h *OCRHandler) DeleteMatch(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"status": "deleted"})
|
||||
}
|
||||
|
||||
// SearchProducts ищет товары (для автокомплита)
|
||||
func (h *OCRHandler) SearchProducts(c *gin.Context) {
|
||||
query := c.Query("q") // ?q=молоко
|
||||
if query == "" {
|
||||
c.JSON(http.StatusOK, []interface{}{})
|
||||
return
|
||||
}
|
||||
|
||||
products, err := h.service.SearchProducts(query)
|
||||
if err != nil {
|
||||
logger.Log.Error("Search error", zap.Error(err))
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Отдаем на фронт упрощенную структуру или полную, в зависимости от нужд.
|
||||
// Product entity уже содержит JSON теги, так что можно отдать напрямую.
|
||||
c.JSON(http.StatusOK, products)
|
||||
}
|
||||
|
||||
// GetMatches возвращает список всех обученных связей
|
||||
func (h *OCRHandler) GetMatches(c *gin.Context) {
|
||||
matches, err := h.service.GetKnownMatches()
|
||||
|
||||
Reference in New Issue
Block a user