Skip to content

Commit

Permalink
test: 배포 환경 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
hseong3243 committed Apr 1, 2024
1 parent c110dd6 commit cba4dc0
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CD

on:
push:
branches: [ "main" ]
branches: [ "dev", "main", "test/find-animals" ]

jobs:
build:
Expand Down Expand Up @@ -45,14 +45,14 @@ jobs:
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://team07-bucket/anifriends/$GITHUB_SHA.zip
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://anifriends-s3/deploy/$GITHUB_SHA.zip

- name: Deploy
run: |
aws deploy create-deployment \
--application-name team07-deploy \
--application-name anifriends \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name team07 \
--deployment-group-name anifriends \
--file-exists-behavior OVERWRITE \
--s3-location bucket=team07-bucket,bundleType=zip,key=anifriends/$GITHUB_SHA.zip \
--s3-location bucket=anifriends-s3,bundleType=zip,key=deploy/$GITHUB_SHA.zip \
--region ap-northeast-2 \
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ public ResponseEntity<FindAnimalsResponse> findAnimals(
));
}

@GetMapping("/v1/animals")
public ResponseEntity<FindAnimalsResponse> findAnimalsV1_1(
Pageable pageable,
@ModelAttribute FindAnimalsRequest findAnimalsRequest
) {
return ResponseEntity.ok(animalService.findAnimalsV1_1(
findAnimalsRequest.type(),
findAnimalsRequest.active(),
findAnimalsRequest.neuteredFilter(),
findAnimalsRequest.age(),
findAnimalsRequest.gender(),
findAnimalsRequest.animalSize(),
pageable
));
}

@GetMapping("/v2/animals")
public ResponseEntity<FindAnimalsResponse> findAnimalsV2(
Pageable pageable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

import com.clova.anifriends.domain.animal.Animal;
import com.clova.anifriends.domain.animal.dto.request.RegisterAnimalRequest;
import com.clova.anifriends.domain.animal.dto.response.FindAnimalsResponse;
import com.clova.anifriends.domain.animal.dto.response.FindAnimalsResponse.FindAnimalResponse;
import com.clova.anifriends.domain.animal.repository.response.FindAnimalsResult;
import com.clova.anifriends.domain.common.PageInfo;
import com.clova.anifriends.domain.shelter.Shelter;
import java.util.List;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.data.domain.Page;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
public final class AnimalMapper {
Expand All @@ -23,4 +29,10 @@ public static Animal toAnimal(Shelter shelter, RegisterAnimalRequest registerAni
registerAnimalRequest.information(),
registerAnimalRequest.imageUrls());
}

public static FindAnimalsResponse resultToResponse(Page<FindAnimalsResult> animapPage) {
PageInfo pageInfo = PageInfo.of(animapPage.getTotalElements(), animapPage.hasNext());
List<FindAnimalResponse> content = animapPage.map(FindAnimalResponse::from).getContent();
return new FindAnimalsResponse(pageInfo, content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public Page<Animal> findAnimals(
) {
List<Animal> animals = query.selectFrom(animal)
.join(animal.shelter).fetchJoin()
.leftJoin(animal.shelter.image).fetchJoin()
.where(
animalTypeContains(type),
animalActiveContains(active),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ public FindAnimalsResponse findAnimals(
return FindAnimalsResponse.from(animalsWithPagination);
}

@Transactional(readOnly = true)
public FindAnimalsResponse findAnimalsV1_1(
AnimalType type,
AnimalActive active,
AnimalNeuteredFilter neuteredFilter,
AnimalAge age,
AnimalGender gender,
AnimalSize size,
Pageable pageable) {
Page<FindAnimalsResult> animapPage = animalRepository.findAnimalsV1_1(
type,
active,
neuteredFilter,
age,
gender,
size,
pageable
);
return AnimalMapper.resultToResponse(animapPage);
}

@Transactional(readOnly = true)
public FindAnimalsResponse findAnimalsV2(
AnimalType type,
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/backend-config

0 comments on commit cba4dc0

Please sign in to comment.