Example #1
0
File: group.go Project: rainkid/ago
func (c *Group) Index() {
	mgroup := models.NewGroupModel()
	groups, err := mgroup.Gets()
	if err == nil {
		c.Assign("groups", groups)
	}
}
Example #2
0
File: user.go Project: rainkid/ago
func (c *User) Add() {
	//group list
	mgroup := models.NewGroupModel()
	groups, err := mgroup.Gets()
	if err == nil {
		c.Assign("groups", groups)
	}
}
Example #3
0
File: group.go Project: rainkid/ago
func (c *Group) Delete() {
	id := c.GetInput("id")
	mgroup := models.NewGroupModel()
	affect, err := mgroup.Where("groupid = ?", id).Delete()
	if err != nil {
		c.Json(-1, "操作失败", nil)
		return
	}
	c.Json(0, "操作成功", affect)
}
Example #4
0
File: group.go Project: rainkid/ago
func (c *Group) Edit() {
	id := c.GetInput("id")
	mgroup := models.NewGroupModel()
	agroup, err := mgroup.Where("groupid = ?", id).Get()

	if err == nil {
		c.Assign("agroup", agroup)
	}

	menu := admin.NewMenu()
	c.Assign("menus", menu.Menus)
}
Example #5
0
File: group.go Project: rainkid/ago
func (c *Group) Add_post() {
	values := c.GetInputs([]string{"name", "descrip"})
	values["rvalue"] = strings.Join(c.GetInputList("rvalue"), ",")
	mgroup := models.NewGroupModel()

	if code, msg := mgroup.Valid(&values); code != 0 {
		c.Json(code, msg, nil)
		return
	}
	mgroup.Insert(values)
	c.Json(0, "操作成功", nil)
}
Example #6
0
File: user.go Project: rainkid/ago
func (c *User) getGroupName(groupid []byte) string {
	//group list
	mgroup := models.NewGroupModel()
	groups, err := mgroup.Gets()
	if err != nil {
		return ""
	}
	for _, group := range groups {
		if bytes.Equal(groupid, utils.ItoByte(group["groupid"])) {
			return utils.ItoString(group["name"])
		}
	}
	return ""
}
Example #7
0
File: user.go Project: rainkid/ago
func (c *User) Edit() {
	id := c.GetInput("id")
	user := models.NewUserModel()

	auser, err := user.Wherep(id).Get()
	if err == nil {
		c.Assign("auser", auser)
	}
	//group list
	mgroup := models.NewGroupModel()
	groups, err := mgroup.Gets()
	if err == nil {
		c.Assign("groups", groups)
	}
}
Example #8
0
File: group.go Project: rainkid/ago
func (c *Group) Edit_post() {
	id := c.GetInput("id")
	values := c.GetInputs([]string{"name", "descrip"})
	values["rvalue"] = strings.Join(c.GetInputList("rvalue"), ",")
	mgroup := models.NewGroupModel()

	if code, msg := mgroup.Valid(&values); code != 0 {
		c.Json(code, msg, nil)
		return
	}
	_, err := mgroup.Where("groupid=?", id).Update(values)
	if err != nil {
		c.Json(-1, "操作失败", nil)
		return
	}
	c.Json(0, "操作成功", nil)
}