Найдено статическим анализом (dupl/jscpd) + проверено вручную:
Go:
- appstate/path.go: ResolveDBPath/ResolveConfigPath → общий resolvePath()
- handlers/respond.go: дженерик BindJSON[T] для bind+422-ошибки
- article/generator.go: buildNetSegment/buildPSUSegment → buildProfileSegment()
- cmd/qfs/main.go (+respond.go): 8 повторяющихся switch{case errors.Is(...)}
→ respondByErrCase(c, err, errCase{...}, ...)
Frontend (index.html):
- 5 идентичных обработчиков клавиатурной навигации автокомплита
→ handleAutocompleteKeyGeneric(event, onSelect)
- 4 функции сборки нового элемента корзины из автокомплита
→ buildNewCartItem()/commitCartChange()
Также: PricingMarkup — единая точка правды для аплифт-коэффициента
в JS (render + export), с cross-reference комментариями к Go-константам
в export.go (defaultSaleMarkup/stockCompetitorMarkupFactor).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
65 lines
1.3 KiB
Go
65 lines
1.3 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.mchus.pro/mchus/quoteforge/internal/services"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type QuoteHandler struct {
|
|
quoteService *services.QuoteService
|
|
}
|
|
|
|
func NewQuoteHandler(quoteService *services.QuoteService) *QuoteHandler {
|
|
return &QuoteHandler{quoteService: quoteService}
|
|
}
|
|
|
|
func (h *QuoteHandler) Validate(c *gin.Context) {
|
|
req, ok := BindJSON[services.QuoteRequest](c)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
result, err := h.quoteService.ValidateAndCalculate(req)
|
|
if err != nil {
|
|
RespondError(c, http.StatusUnprocessableEntity, "invalid request", err)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, result)
|
|
}
|
|
|
|
func (h *QuoteHandler) Calculate(c *gin.Context) {
|
|
req, ok := BindJSON[services.QuoteRequest](c)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
result, err := h.quoteService.ValidateAndCalculate(req)
|
|
if err != nil {
|
|
RespondError(c, http.StatusUnprocessableEntity, "invalid request", err)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"items": result.Items,
|
|
"total": result.Total,
|
|
})
|
|
}
|
|
|
|
func (h *QuoteHandler) PriceLevels(c *gin.Context) {
|
|
req, ok := BindJSON[services.PriceLevelsRequest](c)
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
result, err := h.quoteService.CalculatePriceLevels(req)
|
|
if err != nil {
|
|
RespondError(c, http.StatusUnprocessableEntity, "invalid request", err)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, result)
|
|
}
|