//编辑会员 func (c *User) Edit(user *models.User) revel.Result { if c.Request.Method == "GET" { title := "编辑会员--GoCMS管理系统" var id string = c.Params.Get("id") if len(id) > 0 { Id, err := strconv.ParseInt(id, 10, 64) if err != nil { revel.WARN.Println(err) } //内容 user_info := user.GetById(Id) //会员组 user_group := new(models.User_Group) group_list := user_group.GetGroupList() c.Render(title, id, group_list, user_info) } else { c.Render(title, id) } return c.RenderTemplate("User/Manage/Edit.html") } else { data := make(map[string]string) var id string = c.Params.Get("id") if len(id) <= 0 { data["status"] = "0" data["message"] = "参数错误,编辑失败!" return c.RenderJson(data) } Id, err := strconv.ParseInt(id, 10, 64) if err != nil { revel.WARN.Println(err) } var email string = c.Params.Get("email") if len(email) <= 0 { data["status"] = "0" data["message"] = "请输入邮箱!" return c.RenderJson(data) } else { user.Email = email } var password string = c.Params.Get("password") var pwdconfirm string = c.Params.Get("pwdconfirm") if len(pwdconfirm) > 0 { if password != pwdconfirm { data["status"] = "0" data["message"] = "两次输入密码不一致!" return c.RenderJson(data) } else { user.Password = password } } var nickname string = c.Params.Get("nickname") if len(nickname) <= 0 { data["status"] = "0" data["message"] = "请输入昵称!" return c.RenderJson(data) } else { user.Nickname = nickname } var mobile string = c.Params.Get("mobile") if len(mobile) <= 0 { data["status"] = "0" data["message"] = "请输入手机号码!" return c.RenderJson(data) } else { user.Mobile = mobile } var groupid string = c.Params.Get("groupid") if len(groupid) <= 0 { data["status"] = "0" data["message"] = "请选择会员组!" return c.RenderJson(data) } else { Groupid, err := strconv.ParseInt(groupid, 10, 64) if err != nil { revel.WARN.Println(err) } user.Groupid = Groupid } var islock string = c.Params.Get("islock") if len(islock) <= 0 { data["status"] = "0" data["message"] = "请选择是否定锁!" return c.RenderJson(data) } else { Islock, err := strconv.ParseInt(islock, 10, 64) if err != nil { revel.WARN.Println(err) } user.Islock = Islock } var point string = c.Params.Get("point") if len(point) <= 0 { data["status"] = "0" data["message"] = "请输入积分点数!" return c.RenderJson(data) } else { Point, err := strconv.ParseInt(point, 10, 64) if err != nil { revel.WARN.Println(err) } user.Point = Point } var birthday string = c.Params.Get("birthday") if len(birthday) <= 0 { user.Birthday = "0000-00-00" } else { user.Birthday = birthday } var vip string = c.Params.Get("vip") if vip == "1" { var overduedate string = c.Params.Get("overduedate") if len(overduedate) <= 0 { data["status"] = "0" data["message"] = "请选择过期时间!" return c.RenderJson(data) } else { user.Vip = 1 user.Overduedate = overduedate } } else { user.Vip = 0 user.Overduedate = "0000-00-00 00:00:00" } if user.Edit(Id) { data["status"] = "1" data["message"] = "编辑会员成功!" return c.RenderJson(data) } else { data["status"] = "0" data["message"] = "编辑会员失败!" return c.RenderJson(data) } } }