meetandeat/controller/api/job.go

34 lines
509 B
Go
Raw Permalink Normal View History

2019-03-22 16:35:16 +01:00
package api
import (
"net/http"
"github.com/gin-gonic/gin"
"dev.sum7.eu/genofire/golang-lib/database"
"dev.sum7.eu/genofire/meetandeat/models"
)
func getJobAll(c *gin.Context) {
list := []*models.Job{}
database.Read.Find(&list)
c.JSON(http.StatusOK, list)
}
func addJob(c *gin.Context) {
var name string
if err := c.BindJSON(&name); err != nil {
c.JSON(http.StatusBadRequest, err.Error())
return
}
d := &models.Job{
Name: name,
}
database.Write.Save(d)
c.JSON(http.StatusOK, d)
}