TP-55555|db additions adjustments in service,handler

This commit is contained in:
podili-varshitha_navi
2024-07-30 17:25:49 +05:30
23 changed files with 458 additions and 207 deletions

View File

@@ -2,6 +2,7 @@ package service
import (
"cybertron/models/db"
"net/http"
"time"
"gorm.io/gorm"
@@ -34,6 +35,22 @@ func (s *SourceMapService) GetSourceMap() db.SourceMap {
return sourceMap
}
func (s *SourceMapService) StoreSourceMap(sourceMap db.SourceMap) error {
return s.dbClient.Create(&sourceMap).Error
func (s *SourceMapService) StoreSourceMap(c *gin.Context) {
var sourceMap db.SourceMap
if err := c.ShouldBindJSON(&sourceMap); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
result := s.dbClient.Create(&db.SourceMap{
ReleaseReferenceId: sourceMap.ReleaseReferenceId,
ProjectReferenceId: sourceMap.ProjectReferenceId,
SourceMapZipUrl: sourceMap.SourceMapZipUrl,
})
if result.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to store source map"})
return
}
c.JSON(http.StatusOK, gin.H{"status": "Source map stored successfully"})
}