@VisibleForTesting
    void validateNameUnique(List<MemberLevelDO> list, Long id, String name) {
        for (MemberLevelDO levelDO : list) {
            if (ObjUtil.notEqual(levelDO.getName(), name)) {
                continue;
            }
            if (id == null || !id.equals(levelDO.getId())) {
                throw exception(LEVEL_NAME_EXISTS, levelDO.getName());
            }
        }
    }
@Test
    public void testCreateLevel_nameUnique() {
        // 准备参数
        String name = randomString();

        // mock 数据
        memberlevelMapper.insert(randomLevelDO(o -> o.setName(name)));

        // 调用，校验异常
        List<MemberLevelDO> list = memberlevelMapper.selectList();
        assertServiceException(() -> levelService.validateNameUnique(list, null, name), LEVEL_NAME_EXISTS, name);
    }