Skip to content

Commit

Permalink
Merge pull request #42 from woowacourse-teams/be/feat/#41-update-clie…
Browse files Browse the repository at this point in the history
…nt-requirement

[BE-FEAT] 수정 요청 사항 반영
  • Loading branch information
dwax1324 authored Jul 19, 2024
2 parents d4c9efd + 5f36ec1 commit 065cda5
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Entity
@Getter
@Table(name = "pokemon_ability")
Expand All @@ -27,8 +28,14 @@ public class PokemonAbility {
@Column(name = "name", nullable = false)
private String name;

@Column(name = "short_description", nullable = false)
private String shortDescription;
@Column(name = "ko_name", nullable = false)
private String koName;

@Column(name = "description", nullable = false)
private String description;

@Column(name = "detail_description", nullable = false)
private String detailDescription;

@OneToMany(mappedBy = "pokemonAbility", fetch = FetchType.LAZY)
private List<PokemonAbilityMapping> pokemonAbilityMappings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.pokerogue.helper.ability.domain.PokemonAbility;

public record PokemonAbilityResponse(Long id, String name, String shortDescription) {
public record PokemonAbilityResponse(Long id, String name, String description) {

public static PokemonAbilityResponse from(PokemonAbility pokemonAbility) {
return new PokemonAbilityResponse(pokemonAbility.getId(), pokemonAbility.getName(),
pokemonAbility.getShortDescription());
return new PokemonAbilityResponse(pokemonAbility.getId(), pokemonAbility.getKoName(),
pokemonAbility.getDescription());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import com.pokerogue.helper.ability.domain.PokemonAbility;
import com.pokerogue.helper.ability.dto.PokemonAbilityResponse;
import com.pokerogue.helper.ability.repository.PokemonAbilityRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class PokemonAbilityService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Pokemon {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "pokemon_number", nullable = false)
private Long pokemonNumber;
@Column(name = "pokedex_number", nullable = false)
private Long pokedexNumber;

@Column(name = "name", nullable = false)
private String name;
Expand All @@ -47,6 +47,15 @@ public class Pokemon {
@Column(name = "defense", nullable = false)
private Integer defense;

@Column(name = "special_attack", nullable = false)
private Integer specialAttack;

@Column(name = "special_defense", nullable = false)
private Integer specialDefense;

@Column(name = "total_stats", nullable = false)
private Integer totalStats;

@Column(name = "image", nullable = false)
private String image;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@ public class PokemonTypeMapping {
@ManyToOne
@JoinColumn(name = "pokemon_type_id", nullable = false)
private PokemonType pokemonType;

public String getCircleTypeImage() {
return pokemonType.getCircleImage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

public record PokedexResponse(Long pokedexNumber, String name, String pokemonImage,
List<PokemonTypeResponse> pokemonTypeResponses, List<String> pokemonAbilityNames,
Integer weight, Integer height) {
Integer weight, Integer height, Integer attack, Integer defense,
Integer specialAttack, Integer specialDefense, Integer hp, Integer totalStats) {

public static PokedexResponse of(Pokemon pokemon, List<PokemonTypeResponse> pokemonTypeResponses,
List<String> pokemonAbilityNames) {
return new PokedexResponse(pokemon.getPokemonNumber(), pokemon.getName(), pokemon.getImage(),
pokemonTypeResponses, pokemonAbilityNames, pokemon.getWeight(), pokemon.getHeight());
return new PokedexResponse(pokemon.getPokedexNumber(), pokemon.getName(), pokemon.getImage(),
pokemonTypeResponses, pokemonAbilityNames, pokemon.getWeight(), pokemon.getHeight(),
pokemon.getAttack(), pokemon.getDefense(), pokemon.getSpecialAttack(), pokemon.getSpecialDefense(),
pokemon.getHp(), pokemon.getTotalStats());
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.pokerogue.helper.pokemon.dto;

import com.pokerogue.helper.pokemon.domain.Pokemon;
import com.pokerogue.helper.type.dto.PokemonTypeResponse;

import java.util.List;

public record PokemonResponse(Long id, Long pokedexNumber, String name, String image, List<String> pokemonTypeImages) {
public record PokemonResponse(Long id, Long pokedexNumber, String name, String image,
List<PokemonTypeResponse> pokemonTypeResponses) {

public static PokemonResponse of(Pokemon pokemon, List<String> pokemonTypeImages) {
return new PokemonResponse(pokemon.getId(), pokemon.getPokemonNumber(), pokemon.getName(), pokemon.getImage(),
pokemonTypeImages);
public static PokemonResponse of(Pokemon pokemon, List<PokemonTypeResponse> pokemonTypeResponses) {
return new PokemonResponse(pokemon.getId(), pokemon.getPokedexNumber(), pokemon.getName(), pokemon.getImage(),
pokemonTypeResponses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import com.pokerogue.helper.pokemon.dto.PokemonResponse;
import com.pokerogue.helper.pokemon.repository.PokemonRepository;
import com.pokerogue.helper.type.dto.PokemonTypeResponse;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class PokemonService {
Expand All @@ -30,11 +31,12 @@ public List<PokemonResponse> findPokemons() {
private PokemonResponse toPokemonResponse(Pokemon pokemon) {
List<PokemonTypeMapping> pokemonTypeMappings = pokemon.getPokemonTypeMappings();

List<String> pokemonTypeImages = pokemonTypeMappings.stream()
.map(PokemonTypeMapping::getCircleTypeImage)
List<PokemonTypeResponse> pokemonTypeResponses = pokemonTypeMappings.stream()
.map(PokemonTypeMapping::getPokemonType)
.map(PokemonTypeResponse::from)
.toList();

return PokemonResponse.of(pokemon, pokemonTypeImages);
return PokemonResponse.of(pokemon, pokemonTypeResponses);
}

public PokedexResponse findPokedexDetails(Long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ public class PokemonType {
@Column(name = "name", nullable = false)
private String name;

@Column(name = "long_image", nullable = false)
private String longImage;
@Column(name = "ko_name", nullable = false)
private String koName;

@Column(name = "circle_image", nullable = false)
private String circleImage;

@Column(name = "square_image", nullable = false)
private String squareImage;
@Column(name = "image", nullable = false)
private String image;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
public record PokemonTypeResponse(String pokemonTypeName, String pokemonTypeLogo) {

public static PokemonTypeResponse from(PokemonType pokemonType) {
return new PokemonTypeResponse(pokemonType.getName(), pokemonType.getCircleImage());
return new PokemonTypeResponse(pokemonType.getName(), pokemonType.getImage());
}
}

0 comments on commit 065cda5

Please sign in to comment.