mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-04 02:42:17 +00:00
- Split profile_handlers.go into profile_handlers_core.go, profile_handlers_management_core.go, and profile_handlers_management_delete.go - Simplify OrderProfileHandlerWithRepo with ICCID/IMSI-only validation and "downloaded" state - Remove webhook and message queue notifications from order handler - Add UpdateProfileHandler with state validation for downloaded/activated/deactivated/expired - Add DeleteProfileHandler with existence
78 lines
1.8 KiB
Go
78 lines
1.8 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// RemoveCarrier handles removing a carrier
|
|
func (h *SMDPHandler) RemoveCarrier(c *gin.Context) {
|
|
carrierID := c.Param("carrier_id")
|
|
if carrierID == "" {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Carrier ID is required"})
|
|
return
|
|
}
|
|
|
|
if err := h.manager.RemoveCarrier(carrierID); err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{
|
|
"error": "Failed to remove carrier",
|
|
"message": err.Error(),
|
|
})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"success": true,
|
|
"message": "Carrier removed successfully",
|
|
})
|
|
}
|
|
|
|
// GetSelectionHistory handles selection history requests
|
|
func (h *SMDPHandler) GetSelectionHistory(c *gin.Context) {
|
|
carrierID := c.Param("carrier_id")
|
|
if carrierID == "" {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Carrier ID is required"})
|
|
return
|
|
}
|
|
|
|
history := h.manager.GetSelectionHistory(carrierID)
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"success": true,
|
|
"history": history,
|
|
"count": len(history),
|
|
})
|
|
}
|
|
|
|
// UpdateLearning handles learning update requests
|
|
func (h *SMDPHandler) UpdateLearning(c *gin.Context) {
|
|
carrierID := c.Param("carrier_id")
|
|
if carrierID == "" {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Carrier ID is required"})
|
|
return
|
|
}
|
|
|
|
var req struct {
|
|
ActualPerformance float64 `json:"actual_performance"`
|
|
}
|
|
if err := c.ShouldBindJSON(&req); err != nil {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request body"})
|
|
return
|
|
}
|
|
|
|
if req.ActualPerformance < 0 || req.ActualPerformance > 100 {
|
|
c.JSON(http.StatusBadRequest, gin.H{
|
|
"error": "Actual performance must be between 0 and 100",
|
|
})
|
|
return
|
|
}
|
|
|
|
h.manager.UpdateLearning(carrierID, req.ActualPerformance)
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"success": true,
|
|
"message": "Learning updated successfully",
|
|
})
|
|
}
|