Esempio n. 1
0
func (this *Team) Remove() error {
	err := UnlinkByTeamId(this.Id)
	if err != nil {
		return err
	}

	num, err := DeleteTeamById(this.Id)
	if err == nil && num > 0 {
		cache.Delete(fmt.Sprintf("team:id:%s", this.Name))
		cache.Delete(fmt.Sprintf("team:obj:%d", this.Id))
	}

	return err
}
Esempio n. 2
0
func (this *Team) Update() (int64, error) {
	num, err := orm.NewOrm().Update(this)

	if err == nil && num > 0 {
		cache.Delete(fmt.Sprintf("team:obj:%d", this.Id))
	}

	return num, err
}
Esempio n. 3
0
func (this *Team) UpdateUsers(userIdstr string) error {
	if err := UnlinkByTeamId(this.Id); err != nil {
		return err
	}

	cache.Delete(fmt.Sprintf("t:uids:%d", this.Id))

	return PutUsersInTeam(this.Id, userIdstr)
}
Esempio n. 4
0
func UnlinkByTeamId(id int64) error {
	uids, err := Uids(id)
	if err == nil && len(uids) > 0 {
		for i := 0; i < len(uids); i++ {
			cache.Delete(fmt.Sprintf("u:tids:%d", uids[i]))
		}
	}
	_, err = orm.NewOrm().Raw("DELETE FROM `rel_team_user` WHERE `tid` = ?", id).Exec()
	return err
}
Esempio n. 5
0
func (this *Team) UpdateAdmins(userIdstr string) error {
	cache.Delete(fmt.Sprintf("t_admin:uids:%d", this.Id))
	uidArr := strings.Split(userIdstr, ",")
	for _, uidS := range uidArr {
		uId, _ := strconv.ParseInt(uidS, 10, 64)
		FlushTeamidCache(uId)
	}

	return PutAdminInTeam(this.Id, userIdstr)
}
Esempio n. 6
0
func (this *User) Remove() (int64, error) {
	num, err := DeleteUserById(this.Id)
	if err != nil {
		return num, err
	}

	cache.Delete(fmt.Sprintf("user:obj:%d", this.Id))
	cache.Delete(fmt.Sprintf("user:id:%s", this.Name))

	tids, err := Tids(this.Id)
	if err == nil && len(tids) > 0 {
		for i := 0; i < len(tids); i++ {
			cache.Delete(fmt.Sprintf("t:uids:%d", tids[i]))
		}
	}

	UnlinkByUserId(this.Id)

	return num, err
}
Esempio n. 7
0
func RemoveSessionByUid(uid int64) {
	var ss []Session
	Sessions().Filter("Uid", uid).All(&ss, "Id", "Sig")
	if ss == nil || len(ss) == 0 {
		return
	}

	for _, s := range ss {
		num, err := DeleteSessionById(s.Id)
		if err == nil && num > 0 {
			cache.Delete(fmt.Sprintf("session:obj:%s", s.Sig))
		}
	}
}
Esempio n. 8
0
func (this *Team) UpdateUsers(userIdstr string) error {
	if err := UnlinkByTeamId(this.Id); err != nil {
		return err
	}

	cache.Delete(fmt.Sprintf("t:uids:%d", this.Id))

	uidArr := strings.Split(userIdstr, ",")
	for _, uidS := range uidArr {
		uId, _ := strconv.ParseInt(uidS, 10, 64)
		FlushTeamidCache(uId)
	}

	return PutUsersInTeam(this.Id, userIdstr)
}
Esempio n. 9
0
func (this *User) Update() (int64, error) {
	modilist := make(map[string][]string)
	modilist["sn"] = []string{this.Cnname}
	modilist["mobile"] = []string{this.Phone}
	res, err := utils.Ldapmonify("10.10.3.102:389", "DC=lianjia,DC=com", "CN=updateuser,OU=SysUser,DC=lianjia,DC=com", "wqLTYYS8dpeUT26R", "mail", this.Email, modilist)
	if res != true || err != nil {
		fmt.Println("User Update Ldap Error: ", res, err)
		return 0, err
	}
	num, err := orm.NewOrm().Update(this)

	if err == nil && num > 0 {
		cache.Delete(fmt.Sprintf("user:obj:%d", this.Id))
	}

	return num, err
}
Esempio n. 10
0
func FlushTeamidCache(uid int64) {
	key := fmt.Sprintf("u:tids:%d", uid)
	cache.Delete(key)
}
Esempio n. 11
0
func (this *Team) UpdateAdmins(userIdstr string) error {
	cache.Delete(fmt.Sprintf("t_admin:uids:%d", this.Id))

	return PutAdminInTeam(this.Id, userIdstr)
}
Esempio n. 12
0
func ClearTeamCacheById(id int64) {
	key := fmt.Sprintf("team:obj:%d", id)
	go cache.Delete(key)
}