Fixing undefined errs
This commit is contained in:
parent
3e1ae821cd
commit
2174a0a201
@ -31,7 +31,8 @@ func (c *CompanyDataController) URLMapping() {
|
|||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *CompanyDataController) Post() {
|
func (c *CompanyDataController) Post() {
|
||||||
var v models.CompanyData
|
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 {
|
if _, err := models.AddCompanyData(o, &v); err == nil {
|
||||||
c.Ctx.Output.SetStatus(200)
|
c.Ctx.Output.SetStatus(200)
|
||||||
c.Data["json"] = v
|
c.Data["json"] = v
|
||||||
@ -150,7 +151,8 @@ func (c *CompanyDataController) Put() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
v := models.CompanyData{Id: id}
|
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)
|
v.ModifiedBy = int64(currentUser.Id)
|
||||||
if err := models.UpdateCompanyDataById(o, &v); err == nil {
|
if err := models.UpdateCompanyDataById(o, &v); err == nil {
|
||||||
c.ServeJSONSuccess("Updated CompanyData")
|
c.ServeJSONSuccess("Updated CompanyData")
|
||||||
@ -174,7 +176,8 @@ func (c *CompanyDataController) Put() {
|
|||||||
func (c *CompanyDataController) Delete() {
|
func (c *CompanyDataController) Delete() {
|
||||||
idStr := c.Ctx.Input.Param(":id")
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.Atoi(idStr)
|
id, _ := strconv.Atoi(idStr)
|
||||||
if err := models.DeleteCompanyData(o, id); err == nil {
|
err := models.DeleteCompanyData(o, id)
|
||||||
|
if err == nil {
|
||||||
c.ServeJSONSuccess("Ok")
|
c.ServeJSONSuccess("Ok")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ func (c *PostController) URLMapping() {
|
|||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *PostController) Post() {
|
func (c *PostController) Post() {
|
||||||
var v models.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 {
|
if _, err := models.AddPost(o, &v); err == nil {
|
||||||
c.Ctx.Output.SetStatus(201)
|
c.Ctx.Output.SetStatus(201)
|
||||||
c.Data["json"] = v
|
c.Data["json"] = v
|
||||||
@ -186,7 +187,8 @@ func (c *PostController) Put() {
|
|||||||
func (c *PostController) Delete() {
|
func (c *PostController) Delete() {
|
||||||
idStr := c.Ctx.Input.Param(":id")
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.Atoi(idStr)
|
id, _ := strconv.Atoi(idStr)
|
||||||
if err := models.DeletePost(o, id); err == nil {
|
err := models.DeletePost(o, id)
|
||||||
|
if err == nil {
|
||||||
c.ServeJSONSuccess("Ok")
|
c.ServeJSONSuccess("Ok")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user