@Override public int updateUserRoles(Integer userId, List<Integer> roleIdList) { deleteRolesByUserId(userId); if (roleIdList != null && roleIdList.size() > 0) { for (int roleId : roleIdList) { AdminUserRole adminUserRole = new AdminUserRole(); adminUserRole.setUserId(userId); adminUserRole.setRoleId(roleId); adminUserRoleMapper.insert(adminUserRole); } return roleIdList.size(); } return 0; }
@Override public int deleteRolesByUserId(Integer userId) { AdminUserRoleCriteria criteria = new AdminUserRoleCriteria(); criteria.createCriteria().andUserIdEqualTo(userId); return adminUserRoleMapper.deleteByExample(criteria); }