def remove_user_from_group(cls, user_name, group_name): user = UserBusiness.find_user_by_name(user_name) user_group = UsergroupBusiness.find_group_by_name(group_name) user.group.remove(user_group) user.modified_date = date_time print(user.name + "-从用户组-" + user_group.name + '-移除成功!') db.session.commit()
def add_user_into_group(cls, user_name, group_name): user = UserBusiness.find_user_by_name(user_name) user_group = UsergroupBusiness.find_group_by_name(group_name) user.group.append(user_group) user.modified_date = date_time print (user.name + "--添加到用户组--" + user_group.name + '--成功!') db.session.commit()
def find_role_by_user_name(cls, user_name): user = UserBusiness.find_user_by_name(user_name) if user is not None: for role in user.roles: yield role pass
def remove_user_by_role_name(cls, user_name, role_name): user = UserBusiness.find_user_by_name(user_name) RoleBusiness.add_user_by_role_name(user, role_name)
def find_group_by_user_name(cls, username): user = UserBusiness.find_user_by_name(username) for group in user.group: if group is not None: yield group
def user_update(cls, user_name, data): user = UserBusiness.find_user_by_name(user_name) user_obj = UserBusiness.update_user(user.id, data) print(user_obj.name + '--更新成功 !!!') return user_obj