feat(watchlist): add company identity catalog
Embed a pinned FinanceDatabase equity snapshot, add authenticated company search and identity-based follows, preserve legacy assets, and map selected Yahoo symbols for collection. Refs #19 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -3,6 +3,7 @@ package handlers
|
||||
import (
|
||||
"errors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/tradarr/backend/internal/httputil"
|
||||
"github.com/tradarr/backend/internal/models"
|
||||
"net/http"
|
||||
@ -33,14 +34,39 @@ func (h *Handler) GetMyAssets(c *gin.Context) {
|
||||
|
||||
type addAssetRequest struct {
|
||||
FIGI *string `json:"figi"`
|
||||
Symbol string `json:"symbol" binding:"required"`
|
||||
Symbol string `json:"symbol"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (h *Handler) AddMyAsset(c *gin.Context) {
|
||||
userID := c.GetString("userID")
|
||||
var identity struct {
|
||||
CompanyID *string `json:"company_id"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWith(&identity, binding.JSON); err != nil {
|
||||
httputil.BadRequest(c, err)
|
||||
return
|
||||
}
|
||||
if identity.CompanyID != nil {
|
||||
if h.companyCatalog == nil {
|
||||
c.JSON(503, gin.H{"error": "company catalog unavailable"})
|
||||
return
|
||||
}
|
||||
company, err := h.companyCatalog.ResolveCompany(strings.TrimSpace(*identity.CompanyID))
|
||||
if err != nil {
|
||||
c.JSON(400, gin.H{"error": "unknown company_id"})
|
||||
return
|
||||
}
|
||||
asset, err := h.repo.UpsertCompanyAsset(userID, company)
|
||||
if err != nil {
|
||||
c.JSON(500, gin.H{"error": "asset operation failed"})
|
||||
return
|
||||
}
|
||||
httputil.Created(c, asset)
|
||||
return
|
||||
}
|
||||
var req addAssetRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
if err := c.ShouldBindBodyWith(&req, binding.JSON); err != nil {
|
||||
httputil.BadRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user