func (this *HostGroupController) Save() { jsonResult := g.JsonResult{} item := models.HostGroup{} if err := this.ParseForm(&item); nil != err { logger.Errorln("parseForm error", err) jsonResult.Message = err.Error() } else { if 0 >= item.Id { item.GmtCreate = time.Now() } result, err := item.Insert() if nil != err { jsonResult.Message = err.Error() } else if 0 < result { jsonResult.Success = true } else { jsonResult.Message = "保存失败,未知错误" } } this.Data["json"] = &jsonResult this.ServeJSON() }