Fixing undefined errs

This commit is contained in:
Lukas Bachschwell 2018-11-16 20:00:20 +01:00
parent 3e1ae821cd
commit 2174a0a201
2 changed files with 10 additions and 5 deletions

View File

@ -31,7 +31,8 @@ func (c *CompanyDataController) URLMapping() {
// @router / [post]
func (c *CompanyDataController) Post() {
var v models.CompanyData
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &v); err == nil {
err := json.Unmarshal(c.Ctx.Input.RequestBody, &v)
if err == nil {
if _, err := models.AddCompanyData(o, &v); err == nil {
c.Ctx.Output.SetStatus(200)
c.Data["json"] = v
@ -150,7 +151,8 @@ func (c *CompanyDataController) Put() {
}
v := models.CompanyData{Id: id}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &v); err == nil {
err := json.Unmarshal(c.Ctx.Input.RequestBody, &v)
if err == nil {
v.ModifiedBy = int64(currentUser.Id)
if err := models.UpdateCompanyDataById(o, &v); err == nil {
c.ServeJSONSuccess("Updated CompanyData")
@ -174,7 +176,8 @@ func (c *CompanyDataController) Put() {
func (c *CompanyDataController) Delete() {
idStr := c.Ctx.Input.Param(":id")
id, _ := strconv.Atoi(idStr)
if err := models.DeleteCompanyData(o, id); err == nil {
err := models.DeleteCompanyData(o, id)
if err == nil {
c.ServeJSONSuccess("Ok")
return
}

View File

@ -31,7 +31,8 @@ func (c *PostController) URLMapping() {
// @router / [post]
func (c *PostController) Post() {
var v models.Post
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &v); err == nil {
err := json.Unmarshal(c.Ctx.Input.RequestBody, &v)
if err == nil {
if _, err := models.AddPost(o, &v); err == nil {
c.Ctx.Output.SetStatus(201)
c.Data["json"] = v
@ -186,7 +187,8 @@ func (c *PostController) Put() {
func (c *PostController) Delete() {
idStr := c.Ctx.Input.Param(":id")
id, _ := strconv.Atoi(idStr)
if err := models.DeletePost(o, id); err == nil {
err := models.DeletePost(o, id)
if err == nil {
c.ServeJSONSuccess("Ok")
return
}