TP-55555 | Get all the projects
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user