Exemple #1
0
func RolePerModuleDelete(id bson.ObjectId) ([]string, error) {
	perIDs := make([]string, 20)
	per, err := dal.RolePerInfo(id)
	if err != nil {
		return nil, err
	}
	count, err := dal.RolePersCountByParentID(id.Hex(), true)
	if err != nil {
		return nil, err
	}
	if count > 0 {
		err = dal.RolePerIsRefUpdate(id, true)
	} else {
		err = dal.RolePerDelete(id)
	}
	if err != nil {
		return nil, err
	}
	perIDs = append(perIDs, id.Hex())
	err = rolePerDelCheck(per.ParentPerID, perIDs)
	return perIDs, err
}
Exemple #2
0
func rolePerDelCheck(permissionID string, perIDs []string) error {
	per, err := dal.RolePerInfo(bson.ObjectIdHex(permissionID))
	if err != nil {
		return err
	}
	if !per.IsRef {
		return nil
	}
	count, err := dal.RolePersCountByParentID(permissionID, true)
	if err != nil {
		return err
	}
	if count == 0 {
		err = dal.RolePerDelete(bson.ObjectIdHex(permissionID))
		if err != nil {
			return err
		}
		perIDs = append(perIDs, permissionID)
		return rolePerDelCheck(per.ParentPerID, perIDs)
	}
	return nil

}