Example #1
0
func defaultCreator(prc *godis.PipeClient, u_id, id uint64) error {
	key := fmt.Sprintf("user:%d:permission:%d", u_id, id)
	_, rerr := prc.Setbit(key, VIEW, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, UPDATE, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, MODERATE, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, ADD_TOPIC, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, UPDATE_TOPIC, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, DELETE_TOPIC, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, ADD_POST, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, UPDATE_POST, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, DELETE_POST, 1)
	if rerr != nil {
		return rerr
	}
	return nil
}
Example #2
0
func defaultDiscussion(prc *godis.PipeClient, id uint64) error {
	key := fmt.Sprintf("permission:%d", id)
	_, rerr := prc.Setbit(key, VIEW, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, ADD_TOPIC, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, UPDATE_TOPIC, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, DELETE_TOPIC, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, ADD_POST, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, UPDATE_POST, 1)
	if rerr != nil {
		return rerr
	}
	_, rerr = prc.Setbit(key, DELETE_POST, 1)
	if rerr != nil {
		return rerr
	}
	return nil
}