diff --git a/src/main/java/org/runimo/runimo/hatch/controller/HatchController.java b/src/main/java/org/runimo/runimo/hatch/controller/HatchController.java index 724a594c..181b2d9b 100644 --- a/src/main/java/org/runimo/runimo/hatch/controller/HatchController.java +++ b/src/main/java/org/runimo/runimo/hatch/controller/HatchController.java @@ -3,6 +3,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.runimo.runimo.common.response.SuccessResponse; import org.runimo.runimo.hatch.controller.dto.response.HatchEggResponse; @@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "HATCH", description = "알 부화 API") @RequiredArgsConstructor @RestController public class HatchController { diff --git a/src/main/java/org/runimo/runimo/hatch/exception/HatchHttpResponseCode.java b/src/main/java/org/runimo/runimo/hatch/exception/HatchHttpResponseCode.java index b5d02981..dcbe8a82 100644 --- a/src/main/java/org/runimo/runimo/hatch/exception/HatchHttpResponseCode.java +++ b/src/main/java/org/runimo/runimo/hatch/exception/HatchHttpResponseCode.java @@ -9,14 +9,15 @@ public enum HatchHttpResponseCode implements CustomResponseCode { HATCH_EGG_NOT_READY("HEH4001", "부화 요청 알이 부화 가능한 상태가 아님", "부화 요청 알이 부화 가능한 상태가 아님", HttpStatus.BAD_REQUEST), HATCH_EGG_NOT_FOUND("HEH4041", "부화 요청 알이 존재하지 않음", "부화 요청 알이 존재하지 않음", HttpStatus.NOT_FOUND), + HATCH_USER_NOT_FOUND("HEH4042", "부화 요청 사용자가 존재하지 않음", "부화 요청 사용자가 존재하지 않음", + HttpStatus.NOT_FOUND), // TODO : 다르게 처리할 방법 고민해보기 HATCH_RUNIMO_NOT_FOUND_INTERNAL_ERROR("HEH5001", "[서버 내부 오류] 부화될 러니모가 존재하지 않음", "[서버 내부 오류] 부화될 러니모 존재하지 않음", HttpStatus.INTERNAL_SERVER_ERROR), HATCH_EGG_TYPE_NOT_FOUND_INTERNAL_ERROR("HEH5002", "[서버 내부 오류] 부화될 알 종류가 존재하지 않음", - "[서버 내부 오류] 부화될 알 종류가 존재하지 않음", HttpStatus.INTERNAL_SERVER_ERROR), - ; + "[서버 내부 오류] 부화될 알 종류가 존재하지 않음", HttpStatus.INTERNAL_SERVER_ERROR); private final String code; diff --git a/src/main/java/org/runimo/runimo/runimo/controller/RunimoController.java b/src/main/java/org/runimo/runimo/runimo/controller/RunimoController.java index 1d91d419..41115836 100644 --- a/src/main/java/org/runimo/runimo/runimo/controller/RunimoController.java +++ b/src/main/java/org/runimo/runimo/runimo/controller/RunimoController.java @@ -3,9 +3,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.runimo.runimo.common.response.SuccessResponse; import org.runimo.runimo.runimo.controller.dto.response.GetMyRunimoListResponse; +import org.runimo.runimo.runimo.controller.dto.response.GetRunimoTypeListResponse; import org.runimo.runimo.runimo.controller.dto.response.SetMainRunimoResponse; import org.runimo.runimo.runimo.exception.RunimoHttpResponseCode; import org.runimo.runimo.runimo.service.usecase.RunimoUsecase; @@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; +@Tag(name = "RUNIMO", description = "러니모 관련 API") @RequiredArgsConstructor @RestController public class RunimoController { @@ -26,7 +29,7 @@ public class RunimoController { @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "[MSH2001] 나의 보유 러니모 목록 조회 성공") }) - @GetMapping("/api/v1/runimos/my") + @GetMapping("/api/v1/users/me/runimos") public ResponseEntity> getMyRunimoList( @UserId Long userId) { GetMyRunimoListResponse response = runimoUsecase.getMyRunimoList(userId); @@ -38,6 +41,21 @@ public ResponseEntity> getMyRunimoList( ); } + @Operation(summary = "전체 러니모 종류 조회", description = "전체 러니모 종류를 조회합니다.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "[MSH2003] 전체 러니모 종류 조회 성공") + }) + @GetMapping("/api/v1/runimos/types/all") + public ResponseEntity> getRunimoTypeList() { + GetRunimoTypeListResponse response = runimoUsecase.getRunimoTypeList(); + + return ResponseEntity.ok().body( + SuccessResponse.of( + RunimoHttpResponseCode.GET_ALL_RUNIMO_TYPE_LIST_SUCCESS, + response) + ); + } + @Operation(summary = "대표 러니모 설정", description = "사용자의 대표 러니모를 설정합니다.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "[MSH2002] 대표 러니모 설정 성공"), diff --git a/src/main/java/org/runimo/runimo/runimo/controller/dto/response/GetRunimoTypeListResponse.java b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/GetRunimoTypeListResponse.java new file mode 100644 index 00000000..de19327f --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/GetRunimoTypeListResponse.java @@ -0,0 +1,11 @@ +package org.runimo.runimo.runimo.controller.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; + +@Schema(description = "전체 러니모 종류 조회 응답") +public record GetRunimoTypeListResponse( + List runimoGroups +) { + +} diff --git a/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoInfo.java b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoInfo.java index f73fc684..d44acf3c 100644 --- a/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoInfo.java +++ b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoInfo.java @@ -6,20 +6,17 @@ public record RunimoInfo( @Schema(description = "러니모 id", example = "0") Long id, - @Schema(description = "러니모 이름", example = "토끼") - String name, - - @Schema(description = "러니모 이미지 url", example = "http://...") - String imgUrl, - @Schema(description = "러니모 code", example = "R-101") String code, - @Schema(description = "러니모가 태어난 알 속성", example = "마당") - String eggType, + @Schema(description = "함께한 러닝 누적 횟수", example = "0") + Long totalRunCount, + + @Schema(description = "함께한 러닝 누적 거리", example = "0") + Long totalDistanceInMeters, - @Schema(description = "러니모 상세설명", example = "마당알에서 태어난 마당 토끼예요.") - String description + @Schema(description = "메인 러니모 여부", example = "true") + Boolean isMainRunimo ) { } diff --git a/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoTypeGroup.java b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoTypeGroup.java new file mode 100644 index 00000000..f9e60be9 --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoTypeGroup.java @@ -0,0 +1,15 @@ +package org.runimo.runimo.runimo.controller.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; + +@Schema(description = "전체 러니모 종류 조회 응답") +public record RunimoTypeGroup( + @Schema(description = "러니모가 태어난 알 속성", example = "마당") + String eggType, + + @Schema(description = "해당 알에서 태어나는 러니모 목록") + List runimoTypes +) { + +} diff --git a/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoTypeInfo.java b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoTypeInfo.java new file mode 100644 index 00000000..d276685b --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/controller/dto/response/RunimoTypeInfo.java @@ -0,0 +1,19 @@ +package org.runimo.runimo.runimo.controller.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; + +public record RunimoTypeInfo( + @Schema(description = "러니모 이름", example = "토끼") + String name, + + @Schema(description = "러니모 이미지 url", example = "http://...") + String imgUrl, + + @Schema(description = "러니모 code", example = "R-101") + String code, + + @Schema(description = "러니모 상세설명", example = "마당알에서 태어난 마당 토끼예요.") + String description +) { + +} diff --git a/src/main/java/org/runimo/runimo/runimo/exception/RunimoHttpResponseCode.java b/src/main/java/org/runimo/runimo/runimo/exception/RunimoHttpResponseCode.java index 3238275d..7f5e3cf7 100644 --- a/src/main/java/org/runimo/runimo/runimo/exception/RunimoHttpResponseCode.java +++ b/src/main/java/org/runimo/runimo/runimo/exception/RunimoHttpResponseCode.java @@ -6,9 +6,12 @@ public enum RunimoHttpResponseCode implements CustomResponseCode { GET_MY_RUNIMO_LIST_SUCCESS("MSH2001", "보유 러니모 목록 조회 성공", "보유 러니모 목록 조회 성공", HttpStatus.OK), SET_MAIN_RUNIMO_SUCCESS("MSH2002", "대표 러니모 설정 성공", "대표 러니모 설정 성공", HttpStatus.OK), + GET_ALL_RUNIMO_TYPE_LIST_SUCCESS("MSH2003", "전체 러니모 종류 조회 성공", "전체 러니모 종류 조회 성공", + HttpStatus.OK), USER_DO_NOT_OWN_RUNIMO("MSH4031", "요청 러니모의 소유자가 아님", "요청 러니모의 소유자가 아님", HttpStatus.FORBIDDEN), - RUNIMO_NOT_FOUND("MSH4041", "요청 러니모가 존재하지 않음", "요청 러니모가 존재하지 않음", HttpStatus.NOT_FOUND); + RUNIMO_NOT_FOUND("MSH4041", "요청 러니모가 존재하지 않음", "요청 러니모가 존재하지 않음", HttpStatus.NOT_FOUND), + ; private final String code; private final String clientMessage; diff --git a/src/main/java/org/runimo/runimo/runimo/repository/RunimoDefinitionRepository.java b/src/main/java/org/runimo/runimo/runimo/repository/RunimoDefinitionRepository.java index 15b647ce..150d75ad 100644 --- a/src/main/java/org/runimo/runimo/runimo/repository/RunimoDefinitionRepository.java +++ b/src/main/java/org/runimo/runimo/runimo/repository/RunimoDefinitionRepository.java @@ -1,10 +1,19 @@ package org.runimo.runimo.runimo.repository; +import java.util.List; import java.util.Optional; import org.runimo.runimo.runimo.domain.RunimoDefinition; +import org.runimo.runimo.runimo.service.model.RunimoTypeSimpleModel; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; public interface RunimoDefinitionRepository extends JpaRepository { Optional findByCode(String runimoCode); + + @Query(""" + select new org.runimo.runimo.runimo.service.model.RunimoTypeSimpleModel(rd.name, rd.imgUrl, rd.code, rd.type, rd.description) + from RunimoDefinition rd + """) + List findAllToSimpleModel(); } diff --git a/src/main/java/org/runimo/runimo/runimo/repository/RunimoRepository.java b/src/main/java/org/runimo/runimo/runimo/repository/RunimoRepository.java index 2b4c5ce6..96c3ae06 100644 --- a/src/main/java/org/runimo/runimo/runimo/repository/RunimoRepository.java +++ b/src/main/java/org/runimo/runimo/runimo/repository/RunimoRepository.java @@ -14,7 +14,7 @@ public interface RunimoRepository extends JpaRepository { boolean existsByUserIdAndRunimoDefinitionId(Long UserId, Long runimoDefinitionId); @Query(""" - select new org.runimo.runimo.runimo.service.model.RunimoSimpleModel(r.id, rd.name, rd.imgUrl, rd.code, rd.type, rd.description) + select new org.runimo.runimo.runimo.service.model.RunimoSimpleModel(r.id, rd.code, r.totalRunCount, r.totalDistanceInMeters) from Runimo r join RunimoDefinition rd on rd.id = r.runimoDefinitionId where r.userId = :userId diff --git a/src/main/java/org/runimo/runimo/runimo/service/model/RunimoSimpleModel.java b/src/main/java/org/runimo/runimo/runimo/service/model/RunimoSimpleModel.java index ef125751..3a9f234c 100644 --- a/src/main/java/org/runimo/runimo/runimo/service/model/RunimoSimpleModel.java +++ b/src/main/java/org/runimo/runimo/runimo/service/model/RunimoSimpleModel.java @@ -1,38 +1,22 @@ package org.runimo.runimo.runimo.service.model; import java.util.List; -import org.runimo.runimo.item.domain.EggType; import org.runimo.runimo.runimo.controller.dto.response.RunimoInfo; public record RunimoSimpleModel( Long id, - String name, - String imgUrl, String code, - String eggType, - String description + Long totalRunCount, + Long totalDistanceInMeters ) { - public RunimoSimpleModel(Long id, String name, String imgUrl, String code, String eggType, - String description) { - this.id = id; - this.name = name; - this.imgUrl = imgUrl; - this.code = code; - this.eggType = eggType; - this.description = description; + public static List toDtoList(List modelList, Long mainRunimoId) { + return modelList.stream().map(i -> + i.toDto(i.id.equals(mainRunimoId)) + ).toList(); } - public RunimoSimpleModel(Long id, String name, String imgUrl, String code, EggType eggType, - String description) { - this(id, name, imgUrl, code, eggType.name(), description); - } - - public static List toDtoList(List modelList) { - return modelList.stream().map(RunimoSimpleModel::toDto).toList(); - } - - private RunimoInfo toDto() { - return new RunimoInfo(id, name, imgUrl, code, eggType, description); + private RunimoInfo toDto(Boolean isMainRunimo) { + return new RunimoInfo(id, code, totalRunCount, totalDistanceInMeters, isMainRunimo); } } diff --git a/src/main/java/org/runimo/runimo/runimo/service/model/RunimoTypeSimpleModel.java b/src/main/java/org/runimo/runimo/runimo/service/model/RunimoTypeSimpleModel.java new file mode 100644 index 00000000..a772ffd3 --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/service/model/RunimoTypeSimpleModel.java @@ -0,0 +1,72 @@ +package org.runimo.runimo.runimo.service.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.runimo.runimo.item.domain.EggType; +import org.runimo.runimo.runimo.controller.dto.response.RunimoTypeGroup; +import org.runimo.runimo.runimo.controller.dto.response.RunimoTypeInfo; + +public record RunimoTypeSimpleModel( + String name, + String imgUrl, + String code, + String eggType, + String description +) { + + public RunimoTypeSimpleModel(String name, String imgUrl, String code, EggType eggType, + String description) { + this(name, imgUrl, code, eggType.getName(), description); + } + + public static List toDtoList(List modelList) { + Map> runimoDtoMap = toRunimoTypeMap( + modelList); + + List runimoTypeGroups = toRunimoTypeGroups( + runimoDtoMap); + + return runimoTypeGroups; + } + + private RunimoTypeInfo toDto() { + return new RunimoTypeInfo(name, imgUrl, code, description); + } + + + /** + * EggType enum 클래스 순서 기준으로 EggType 별 러니모 그룹목록 생성 + */ + private static List toRunimoTypeGroups( + Map> runimoDtoMap) { + + List runimoTypeGroups = new ArrayList<>(); + for (EggType eggType : EggType.values()) { + String key = eggType.getName(); + runimoTypeGroups.add(new RunimoTypeGroup(key, runimoDtoMap.get(key))); + } + + return runimoTypeGroups; + } + + /** + * EggType 별 러니모 분류 map 생성 + */ + private static Map> toRunimoTypeMap( + List modelList) { + + Map> runimoTypeDtos = new HashMap<>(); + for (RunimoTypeSimpleModel model : modelList) { + String key = model.eggType(); + if (!runimoTypeDtos.containsKey(key)) { + runimoTypeDtos.put(key, new ArrayList<>()); + } + runimoTypeDtos.get(key).add(model.toDto()); + } + + return runimoTypeDtos; + } + +} diff --git a/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecase.java b/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecase.java index c5ca8126..0b0b0920 100644 --- a/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecase.java +++ b/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecase.java @@ -1,6 +1,7 @@ package org.runimo.runimo.runimo.service.usecase; import org.runimo.runimo.runimo.controller.dto.response.GetMyRunimoListResponse; +import org.runimo.runimo.runimo.controller.dto.response.GetRunimoTypeListResponse; import org.runimo.runimo.runimo.controller.dto.response.SetMainRunimoResponse; public interface RunimoUsecase { @@ -8,4 +9,6 @@ public interface RunimoUsecase { GetMyRunimoListResponse getMyRunimoList(Long userId); SetMainRunimoResponse setMainRunimo(Long userId, Long runimoId); + + GetRunimoTypeListResponse getRunimoTypeList(); } diff --git a/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecaseImpl.java b/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecaseImpl.java index 2d5273c6..b6f61d1e 100644 --- a/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecaseImpl.java +++ b/src/main/java/org/runimo/runimo/runimo/service/usecase/RunimoUsecaseImpl.java @@ -3,7 +3,10 @@ import java.util.List; import java.util.NoSuchElementException; import lombok.RequiredArgsConstructor; +import org.runimo.runimo.hatch.exception.HatchException; +import org.runimo.runimo.hatch.exception.HatchHttpResponseCode; import org.runimo.runimo.runimo.controller.dto.response.GetMyRunimoListResponse; +import org.runimo.runimo.runimo.controller.dto.response.GetRunimoTypeListResponse; import org.runimo.runimo.runimo.controller.dto.response.SetMainRunimoResponse; import org.runimo.runimo.runimo.domain.Runimo; import org.runimo.runimo.runimo.exception.RunimoException; @@ -11,6 +14,7 @@ import org.runimo.runimo.runimo.repository.RunimoDefinitionRepository; import org.runimo.runimo.runimo.repository.RunimoRepository; import org.runimo.runimo.runimo.service.model.RunimoSimpleModel; +import org.runimo.runimo.runimo.service.model.RunimoTypeSimpleModel; import org.runimo.runimo.user.domain.User; import org.runimo.runimo.user.service.UserFinder; import org.springframework.stereotype.Service; @@ -21,13 +25,18 @@ @Service public class RunimoUsecaseImpl implements RunimoUsecase { - private final RunimoDefinitionRepository runimoDefinitionRepository; private final RunimoRepository runimoRepository; private final UserFinder userFinder; + private final RunimoDefinitionRepository runimoDefinitionRepository; public GetMyRunimoListResponse getMyRunimoList(Long userId) { - List runimos = runimoRepository.findAllByUserId(userId); - return new GetMyRunimoListResponse(RunimoSimpleModel.toDtoList(runimos)); + List models = runimoRepository.findAllByUserId(userId); + + User user = userFinder.findUserById(userId).orElseThrow(() -> HatchException.of( + HatchHttpResponseCode.HATCH_USER_NOT_FOUND)); + + return new GetMyRunimoListResponse( + RunimoSimpleModel.toDtoList(models, user.getMainRunimoId())); } @Transactional @@ -44,4 +53,10 @@ public SetMainRunimoResponse setMainRunimo(Long userId, Long runimoId) { return new SetMainRunimoResponse(runimoId); } + @Override + public GetRunimoTypeListResponse getRunimoTypeList() { + List models = runimoDefinitionRepository.findAllToSimpleModel(); + return new GetRunimoTypeListResponse(RunimoTypeSimpleModel.toDtoList(models)); + } + } diff --git a/src/test/java/org/runimo/runimo/runimo/controller/RunimoControllerTest.java b/src/test/java/org/runimo/runimo/runimo/controller/RunimoControllerTest.java index 7f135506..63fba97e 100644 --- a/src/test/java/org/runimo/runimo/runimo/controller/RunimoControllerTest.java +++ b/src/test/java/org/runimo/runimo/runimo/controller/RunimoControllerTest.java @@ -58,7 +58,7 @@ void tearDown() { .contentType(ContentType.JSON) .when() - .get("/api/v1/runimos/my") + .get("/api/v1/users/me/runimos") .then() .log().all() @@ -68,11 +68,42 @@ void tearDown() { .body("payload.runimos", hasSize(3)) .body("payload.runimos[0].id", equalTo(1)) - .body("payload.runimos[0].name", equalTo("강아지")) - .body("payload.runimos[0].img_url", equalTo("http://dummy1")) .body("payload.runimos[0].code", equalTo("R-101")) - .body("payload.runimos[0].egg_type", equalTo("MADANG")) - .body("payload.runimos[0].description", equalTo("마당-강아지예여")); + .body("payload.runimos[0].total_run_count", equalTo(3)) + .body("payload.runimos[0].total_distance_in_meters", equalTo(1000)) + .body("payload.runimos[0].is_main_runimo", equalTo(true)) + .body("payload.runimos[1].is_main_runimo", equalTo(false)); + } + + @Test + @Sql(scripts = "/sql/get_all_runimo_type_test_data.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) + void 전체_러니모_종류_조회_성공() { + String token = "Bearer " + jwtTokenFactory.generateAccessToken("test-user-uuid-1"); + + given() + .header("Authorization", token) + .contentType(ContentType.JSON) + + .when() + .get("/api/v1/runimos/types/all") + + .then() + .log().all() + .statusCode(HttpStatus.OK.value()) + + .body("code", equalTo("MSH2003")) + .body("payload.runimo_groups", hasSize(3)) + + .body("payload.runimo_groups[0].egg_type", equalTo("마당")) + .body("payload.runimo_groups[0].runimo_types", hasSize(4)) + .body("payload.runimo_groups[1].egg_type", equalTo("숲")) + .body("payload.runimo_groups[1].runimo_types", hasSize(4)) + + .body("payload.runimo_groups[0].runimo_types[0].name", equalTo("강아지")) + .body("payload.runimo_groups[0].runimo_types[0].img_url", equalTo("http://dummy1")) + .body("payload.runimo_groups[0].runimo_types[0].code", equalTo("R-101")) + .body("payload.runimo_groups[0].runimo_types[0].description", equalTo("마당-강아지예여")) + ; } @Test diff --git a/src/test/resources/sql/get_all_runimo_type_test_data.sql b/src/test/resources/sql/get_all_runimo_type_test_data.sql new file mode 100644 index 00000000..b5da0cbf --- /dev/null +++ b/src/test/resources/sql/get_all_runimo_type_test_data.sql @@ -0,0 +1,8 @@ +-- 사용자 +SET FOREIGN_KEY_CHECKS = 0; +TRUNCATE TABLE users; +INSERT INTO users (id, public_id, nickname, img_url, total_distance_in_meters, total_time_in_seconds, main_runimo_id, created_at, + updated_at) +VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', 10000, 3600, 1, NOW(), NOW()), + (2, 'test-user-uuid-2', 'Moon', 'https://example.com/images/user2.png', 5000, 1800, null, NOW(), NOW()); +SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file diff --git a/src/test/resources/sql/get_my_runimo_list_test_data.sql b/src/test/resources/sql/get_my_runimo_list_test_data.sql index 9c15666e..03c1fad7 100644 --- a/src/test/resources/sql/get_my_runimo_list_test_data.sql +++ b/src/test/resources/sql/get_my_runimo_list_test_data.sql @@ -1,10 +1,10 @@ -- 사용자 SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE users; -INSERT INTO users (id, public_id, nickname, img_url, total_distance_in_meters, total_time_in_seconds, created_at, +INSERT INTO users (id, public_id, nickname, img_url, total_distance_in_meters, total_time_in_seconds, main_runimo_id, created_at, updated_at) -VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', 10000, 3600, NOW(), NOW()), - (2, 'test-user-uuid-2', 'Moon', 'https://example.com/images/user2.png', 5000, 1800, NOW(), NOW()); +VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', 10000, 3600, 1, NOW(), NOW()), + (2, 'test-user-uuid-2', 'Moon', 'https://example.com/images/user2.png', 5000, 1800, null, NOW(), NOW()); SET FOREIGN_KEY_CHECKS = 1; -- 러니모 - 정적 데이터 @@ -15,10 +15,10 @@ SET FOREIGN_KEY_CHECKS = 1; -- (3, '오리', 'R-103', '마당 오리예여', 'http://dummy3', 'MADANG', NOW(), NOW()), -- (4, '늑대', 'R-104', '주인이 다른 마당 늑대예여', 'http://dummy4', 'MADANG', NOW(), NOW()); --- 사용자-알 맵핑 +-- 러니모 TRUNCATE TABLE runimo; -INSERT INTO runimo (id, user_id, runimo_definition_id, created_at, updated_at) -VALUES (1, 1, 1, NOW(), NOW()), - (2, 1, 2, NOW(), NOW()), - (3, 1, 3, NOW(), NOW()), - (4, 2, 4, NOW(), NOW()); \ No newline at end of file +INSERT INTO runimo (id, user_id, runimo_definition_id, total_run_count, total_distance_in_meters, created_at, updated_at) +VALUES (1, 1, 1, 3, 1000, NOW(), NOW()), + (2, 1, 2, 0, 0, NOW(), NOW()), + (3, 1, 3, 0, 0, NOW(), NOW()), + (4, 2, 4, 0, 0, NOW(), NOW()); \ No newline at end of file diff --git a/src/test/resources/sql/set_main_runimo_test_data.sql b/src/test/resources/sql/set_main_runimo_test_data.sql index 21c3f782..03c1fad7 100644 --- a/src/test/resources/sql/set_main_runimo_test_data.sql +++ b/src/test/resources/sql/set_main_runimo_test_data.sql @@ -1,10 +1,10 @@ -- 사용자 SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE users; -INSERT INTO users (id, public_id, nickname, img_url, total_distance_in_meters, total_time_in_seconds, created_at, +INSERT INTO users (id, public_id, nickname, img_url, total_distance_in_meters, total_time_in_seconds, main_runimo_id, created_at, updated_at) -VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', 10000, 3600, NOW(), NOW()), - (2, 'test-user-uuid-2', 'Moon', 'https://example.com/images/user2.png', 5000, 1800, NOW(), NOW()); +VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', 10000, 3600, 1, NOW(), NOW()), + (2, 'test-user-uuid-2', 'Moon', 'https://example.com/images/user2.png', 5000, 1800, null, NOW(), NOW()); SET FOREIGN_KEY_CHECKS = 1; -- 러니모 - 정적 데이터 @@ -15,10 +15,10 @@ SET FOREIGN_KEY_CHECKS = 1; -- (3, '오리', 'R-103', '마당 오리예여', 'http://dummy3', 'MADANG', NOW(), NOW()), -- (4, '늑대', 'R-104', '주인이 다른 마당 늑대예여', 'http://dummy4', 'MADANG', NOW(), NOW()); --- 사용자-러니모 맵핑 +-- 러니모 TRUNCATE TABLE runimo; -INSERT INTO runimo (id, user_id, runimo_definition_id, created_at, updated_at) -VALUES (1, 1, 1, NOW(), NOW()), - (2, 1, 2, NOW(), NOW()), - (3, 1, 3, NOW(), NOW()), - (4, 2, 4, NOW(), NOW()); \ No newline at end of file +INSERT INTO runimo (id, user_id, runimo_definition_id, total_run_count, total_distance_in_meters, created_at, updated_at) +VALUES (1, 1, 1, 3, 1000, NOW(), NOW()), + (2, 1, 2, 0, 0, NOW(), NOW()), + (3, 1, 3, 0, 0, NOW(), NOW()), + (4, 2, 4, 0, 0, NOW(), NOW()); \ No newline at end of file