Пример #1
0
//首页
func (c *Group) Index(user_group *models.User_Group) revel.Result {
	title := "会员组首页--GoCMS管理系统"

	group_list := user_group.GetGroupList()

	c.Render(title, group_list)
	return c.RenderTemplate("User/Group/Index.html")
}
Пример #2
0
//首页
func (c *User) Index(user *models.User) revel.Result {
	title := "会员首页--GoCMS管理系统"

	var page string = c.Params.Get("page")
	var search string = c.Params.Get("search")

	var Page int64 = 1

	if len(page) > 0 {
		Page, _ = strconv.ParseInt(page, 10, 64)
	}

	user_list, pages, where := user.GetUserList(search, Page, 10)

	//会员组
	user_group := new(models.User_Group)
	group_list := user_group.GetGroupList()

	c.Render(title, user_list, group_list, pages, where)
	return c.RenderTemplate("User/Manage/Index.html")
}
Пример #3
0
//添加会员组
func (c *Group) Add(user_group *models.User_Group) revel.Result {

	if c.Request.Method == "GET" {

		title := "添加会员组--GoCMS管理系统"

		c.Render(title)
		return c.RenderTemplate("User/Group/Add.html")
	} else {

		data := make(map[string]string)

		var name string = c.Params.Get("name")
		if len(name) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入会员组名称!"
			return c.RenderJson(data)
		} else {
			user_group.Name = name
		}

		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_group.Point = Point
		}

		var star string = c.Params.Get("star")
		if len(star) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入星星数!"
			return c.RenderJson(data)
		} else {
			Star, err := strconv.ParseInt(star, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			user_group.Star = Star
		}

		var allowpost string = c.Params.Get("allowpost")
		Allowpost, err := strconv.ParseInt(allowpost, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Allowpost = Allowpost

		var allowpostverify string = c.Params.Get("allowpostverify")
		Allowpostverify, err := strconv.ParseInt(allowpostverify, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Allowpostverify = Allowpostverify

		var allowupgrade string = c.Params.Get("allowupgrade")
		Allowupgrade, err := strconv.ParseInt(allowupgrade, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Allowupgrade = Allowupgrade

		var allowsendmessage string = c.Params.Get("allowsendmessage")
		Allowsendmessage, err := strconv.ParseInt(allowsendmessage, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Allowsendmessage = Allowsendmessage

		var allowattachment string = c.Params.Get("allowattachment")
		Allowattachment, err := strconv.ParseInt(allowattachment, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Allowattachment = Allowattachment

		var allowsearch string = c.Params.Get("allowsearch")
		Allowsearch, err := strconv.ParseInt(allowsearch, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Allowsearch = Allowsearch

		var priceday string = c.Params.Get("priceday")
		Priceday, err := strconv.ParseFloat(priceday, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Priceday = Priceday

		var pricemonth string = c.Params.Get("pricemonth")
		Pricemonth, err := strconv.ParseFloat(pricemonth, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Pricemonth = Pricemonth

		var priceyear string = c.Params.Get("priceyear")
		Priceyear, err := strconv.ParseFloat(priceyear, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Priceyear = Priceyear

		var allowmessage string = c.Params.Get("allowmessage")
		if len(allowmessage) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入最大短消息数!"
			return c.RenderJson(data)
		} else {
			Allowmessage, err := strconv.ParseInt(allowmessage, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			user_group.Allowmessage = Allowmessage
		}

		var allowpostnum string = c.Params.Get("allowpostnum")
		if len(allowpostnum) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入日最大投稿数!"
			return c.RenderJson(data)
		} else {
			Allowpostnum, err := strconv.ParseInt(allowpostnum, 10, 64)
			if err != nil {
				revel.WARN.Println(err)
			}
			user_group.Allowpostnum = Allowpostnum
		}

		var usernamecolor string = c.Params.Get("usernamecolor")
		user_group.Usernamecolor = usernamecolor

		var icon string = c.Params.Get("icon")
		user_group.Icon = icon

		var desc string = c.Params.Get("desc")
		user_group.Desc = desc

		var status string = c.Params.Get("status")
		Status, err := strconv.ParseInt(status, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}
		user_group.Status = Status

		if user_group.Save() {
			data["status"] = "1"
			data["message"] = "添加成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "0"
			data["message"] = "添加失败!"
			return c.RenderJson(data)
		}
	}
}
Пример #4
0
//添加会员
func (c *User) Add(user *models.User) revel.Result {

	if c.Request.Method == "GET" {

		title := "添加会员--GoCMS管理系统"

		//会员组
		user_group := new(models.User_Group)
		group_list := user_group.GetGroupList()

		c.Render(title, group_list)
		return c.RenderTemplate("User/Manage/Add.html")
	} else {

		data := make(map[string]string)

		var username string = c.Params.Get("username")
		if len(username) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入用户名!"
			return c.RenderJson(data)
		} else {
			user.Username = username
		}

		if user.HasName() {
			data["status"] = "0"
			data["message"] = "用户名‘" + username + "’已有!"
			return c.RenderJson(data)
		}

		var email string = c.Params.Get("email")
		if len(email) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入邮箱!"
			return c.RenderJson(data)
		} else {
			user.Email = email
		}

		if user.HasEmail() {
			data["status"] = "0"
			data["message"] = "邮箱‘" + email + "’已有!"
			return c.RenderJson(data)
		}

		var password string = c.Params.Get("password")
		if len(password) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入密码!"
			return c.RenderJson(data)
		}

		var pwdconfirm string = c.Params.Get("pwdconfirm")
		if len(pwdconfirm) <= 0 {
			data["status"] = "0"
			data["message"] = "请输入确认密码!"
			return c.RenderJson(data)
		} else {
			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" {
			user.Vip = 1

			var overduedate string = c.Params.Get("overduedate")

			if len(overduedate) <= 0 {
				data["status"] = "0"
				data["message"] = "请选择过期时间!"
				return c.RenderJson(data)
			} else {
				user.Overduedate = overduedate
			}

		} else {
			user.Vip = 0
			user.Overduedate = time.Now().Format("2006-01-02 15:04:04")
		}

		if ip := c.Request.Header.Get("X-Forwarded-For"); ip != "" {
			ips := strings.Split(ip, ",")
			if len(ips) > 0 && ips[0] != "" {
				rip := strings.Split(ips[0], ":")
				user.Regip = rip[0]
			}
		} else {
			ip := strings.Split(c.Request.RemoteAddr, ":")
			if len(ip) > 0 {
				if ip[0] != "[" {
					user.Regip = ip[0]
				}
			}
		}

		if user.Save() {
			data["status"] = "1"
			data["message"] = "添加会员成功!"
			return c.RenderJson(data)
		} else {
			data["status"] = "0"
			data["message"] = "添加会员失败!"
			return c.RenderJson(data)
		}
	}
}
Пример #5
0
//编辑会员
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)
		}
	}
}