34 lines
509 B
Go
34 lines
509 B
Go
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)
|
|
}
|