示例#1
0
func (this *Site) SaveSiteInfo(siteInfo map[string]interface{}) AjaxResult {
	ajaxResult := new(AjaxResult)

	content := utils.ToJson(siteInfo)

	o := orm.NewOrm()
	site := Site{Id: 1, Content: content}

	_, err := o.Update(&site)
	if err != nil {
		ajaxResult.Success = false
		ajaxResult.Error = err.Error()
	} else {
		ajaxResult.Success = true
	}
	return *ajaxResult
}
示例#2
0
func (this *LoginController) Post() {
	username := this.GetString("username")
	password := this.GetString("password")

	ajaxResult := new(models.AjaxResult)

	user := new(models.User)
	err := user.GetUserName(username)
	fmt.Println(user)
	if err != nil {
		ajaxResult.Error = "帐号不存在!"
	} else {
		if user.Password != utils.ToMD5([]byte(password)) {
			ajaxResult.Error = "密码输入错误!"
		} else {
			ajaxResult.Success = true
			this.SetSession("adminAuthen", utils.ToJson(user))
		}
	}

	this.Ctx.WriteString(ajaxResult.ToString())
}