Search in sources :

Example 1 with IUserService

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);
}
Also used : UserDto(toby.jpa.dto.UserDto) Optional(java.util.Optional) IUserService(toby.jpa.service.IUserService) MusicDto(toby.jpa.dto.MusicDto) UserDto(toby.jpa.dto.UserDto) MusicDto(toby.jpa.dto.MusicDto)

Aggregations

Optional (java.util.Optional)1 MusicDto (toby.jpa.dto.MusicDto)1 UserDto (toby.jpa.dto.UserDto)1 IUserService (toby.jpa.service.IUserService)1