TP-55555 | Get all the projects

This commit is contained in:
Lokesh Dugar
2024-07-24 14:59:27 +05:30
parent 0952887606
commit e02d17b85f

View File

@@ -39,11 +39,15 @@ func (h *ProjectHandler) ProjectCreate(c *gin.Context) {
}
func (h *ProjectHandler) ProjectGet(c *gin.Context) {
var project db.Project
h.dbClient.First(&project, 1)
c.JSON(http.StatusOK, gin.H{
"message": project,
})
var projects []db.Project
h.dbClient.Find(&projects)
if result := h.dbClient.Find(&projects); result.Error != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": result.Error.Error()})
return
}
c.JSON(http.StatusOK, projects)
}
func NewProjectHandler(dbClient *gorm.DB) *ProjectHandler {