Skip to content

Instantly share code, notes, and snippets.

@mohashari
Created June 21, 2018 17:05
Show Gist options
  • Select an option

  • Save mohashari/72ccb2f3e27712c0ec26b72d10b3e46b to your computer and use it in GitHub Desktop.

Select an option

Save mohashari/72ccb2f3e27712c0ec26b72d10b3e46b to your computer and use it in GitHub Desktop.
func fetchAllStudent(c *gin.Context) {
var model [] student
var vo [] transformedStudent
db.Find(&model)
if len(model) <= 0 {
c.JSON(http.StatusNotFound, gin.H{"message": http.StatusNotFound, "result": "Data Tidak Ada"})
}
for _, item := range model {
vo = append(vo, transferModelToVo(item))
}
c.JSON(http.StatusOK, gin.H{"message": http.StatusOK, "result": vo})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment