-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from KCY-Fit-a-Pet/feat/39
โจ ๋ฐ๋ ค๋๋ฌผ ์์ /์ญ์ API ๋ฐ ์ฌ์ฉ์ ์ค์ ์ด๋ฆ ๋ฐํ API
- Loading branch information
Showing
25 changed files
with
350 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...nal-api/src/main/java/kr/co/fitapet/api/apis/notification/controller/NotificationApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kr.co.fitapet.api.apis.notification.controller; | ||
|
||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "์๋ฆผ API") | ||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v2/notifications") | ||
public class NotificationApi { | ||
} |
11 changes: 11 additions & 0 deletions
11
...al-api/src/main/java/kr/co/fitapet/api/apis/notification/usecase/NotificationUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package kr.co.fitapet.api.apis.notification.usecase; | ||
|
||
import kr.co.fitapet.common.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@UseCase | ||
@RequiredArgsConstructor | ||
public class NotificationUseCase { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
fitapet-app-external-api/src/main/java/kr/co/fitapet/api/apis/pet/dto/PetDetailRes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package kr.co.fitapet.api.apis.pet.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; | ||
import kr.co.fitapet.domain.domains.pet.domain.Pet; | ||
import kr.co.fitapet.domain.domains.pet.type.GenderType; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Objects; | ||
|
||
public record PetDetailRes( | ||
Long id, | ||
String petName, | ||
String petProfileImage, | ||
GenderType gender, | ||
Boolean neutered, | ||
@JsonSerialize(using = LocalDateSerializer.class) | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") | ||
LocalDate birthdate, | ||
String species, | ||
String feed | ||
) { | ||
public static PetDetailRes from(Pet pet) { | ||
return new PetDetailRes( | ||
pet.getId(), | ||
pet.getPetName(), | ||
Objects.toString(pet.getPetProfileImg(), ""), | ||
pet.getGender(), | ||
pet.isNeutered(), | ||
pet.getBirthdate(), | ||
pet.getSpecies(), | ||
Objects.toString(pet.getFeed(), "") | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...pp-external-api/src/main/java/kr/co/fitapet/api/apis/pet/mapper/PetImageSearchMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package kr.co.fitapet.api.apis.pet.mapper; | ||
|
||
import kr.co.fitapet.common.annotation.Mapper; | ||
import kr.co.fitapet.domain.domains.memo.service.MemoSearchService; | ||
import kr.co.fitapet.domain.domains.pet.domain.Pet; | ||
import kr.co.fitapet.domain.domains.pet.service.PetSearchService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@Mapper | ||
@RequiredArgsConstructor | ||
public class PetImageSearchMapper { | ||
private final PetSearchService petSearchService; | ||
private final MemoSearchService memoSearchService; | ||
|
||
/** | ||
* ๋ฐ๋ ค๋๋ฌผ ํ๋กํ ์ด๋ฏธ์ง์ ๋ฉ๋ชจ์ ๋ฑ๋ก๋ ๋ชจ๋ ์ด๋ฏธ์ง ์กฐํ | ||
*/ | ||
@Transactional(readOnly = true) | ||
public List<String> findPetProfileImageAndMemoImageUrls(Long petId) { | ||
List<String> images = new ArrayList<>(); | ||
|
||
Pet pet = petSearchService.findPetById(petId); | ||
if (pet.getPetProfileImg() != null) | ||
images.add(pet.getPetProfileImg()); | ||
List<Long> memoIds = memoSearchService.findMemoIdsByPetId(pet.getId()); | ||
List<String> memoImageUrls = memoSearchService.findMemoImageUrlsByMemoIds(memoIds); | ||
images.addAll(memoImageUrls); | ||
|
||
return images; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...c/main/java/kr/co/fitapet/domain/domains/memo/repository/MemoImageQueryDslRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package kr.co.fitapet.domain.domains.memo.repository; | ||
|
||
import java.util.List; | ||
|
||
public interface MemoImageQueryDslRepository { | ||
List<String> findMemoImageUrlsByMemoIds(List<Long> memoIds); | ||
} |
28 changes: 28 additions & 0 deletions
28
...in/java/kr/co/fitapet/domain/domains/memo/repository/MemoImageQueryDslRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kr.co.fitapet.domain.domains.memo.repository; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import kr.co.fitapet.domain.domains.memo.domain.QMemo; | ||
import kr.co.fitapet.domain.domains.memo.domain.QMemoImage; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class MemoImageQueryDslRepositoryImpl implements MemoImageQueryDslRepository { | ||
private final JPAQueryFactory queryFactory; | ||
private final QMemo memo = QMemo.memo; | ||
private final QMemoImage memoImage = QMemoImage.memoImage; | ||
|
||
@Override | ||
public List<String> findMemoImageUrlsByMemoIds(List<Long> memoIds) { | ||
return queryFactory | ||
.select(memoImage.imgUrl) | ||
.from(memoImage) | ||
.where(memoImage.memo.id.in(memoIds)) | ||
.fetch(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.