use of toby.jpa.service.IUserService in project toby-bot by ml404.
the class UserDtoHelper method calculateUserDto.
public static UserDto calculateUserDto(long guildId, long discordId, boolean isSuperUser, IUserService userService, int introVolume) {
Optional<UserDto> dbUserDto = userService.listGuildUsers(guildId).stream().filter(userDto -> userDto.getGuildId().equals(guildId) && userDto.getDiscordId().equals(discordId)).findFirst();
if (dbUserDto.isEmpty()) {
UserDto userDto = new UserDto();
userDto.setDiscordId(discordId);
userDto.setGuildId(guildId);
userDto.setSuperUser(isSuperUser);
MusicDto musicDto = new MusicDto(userDto.getDiscordId(), userDto.getGuildId(), null, introVolume, null);
userDto.setMusicDto(musicDto);
return userService.createNewUser(userDto);
}
return userService.getUserById(discordId, guildId);
}
Aggregations