-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/#171 카테고리 API 수정 #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/#171 카테고리 API 수정 #172
Changes from 7 commits
2754125
85f0d76
faf0d2a
f354cf1
9de7f45
55eb838
becfb70
c08a34a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,5 +42,5 @@ jobs: | |
| context: . | ||
| file: ./Dockerfile | ||
| push: true | ||
| tags: woals2840/certi-server | ||
| tags: seongmin0229/certi-server | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package org.sopt.certi_server.domain.certification.dto.response; | ||
|
|
||
| import org.sopt.certi_server.domain.certification.entity.Certification; | ||
|
|
||
| public record CertificationRankResponse( | ||
| int rank, | ||
| String certificationName, | ||
| String certificationType | ||
| ) { | ||
| public CertificationRankResponse(int rank, Certification certification) { | ||
| this( | ||
| rank, | ||
| certification.getName(), | ||
| certification.getCertificationType() != null | ||
| ? certification.getCertificationType().getKoreanName() | ||
| : null | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,15 +17,19 @@ | |
| import org.sopt.certi_server.domain.major.entity.Major; | ||
| import org.sopt.certi_server.domain.major.repository.MajorRepository; | ||
| import org.sopt.certi_server.domain.user.entity.User; | ||
| import org.sopt.certi_server.domain.user.entity.enums.TrackType; | ||
| import org.sopt.certi_server.domain.user.service.UserService; | ||
| import org.sopt.certi_server.global.error.code.ErrorCode; | ||
| import org.sopt.certi_server.global.error.exception.NotFoundException; | ||
| import org.springframework.cache.annotation.CacheConfig; | ||
| import org.springframework.cache.annotation.Cacheable; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.*; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
|
|
@@ -45,6 +49,7 @@ public class CertificationService { | |
| private final CertificationJobRepository certificationJobRepository; | ||
| private final CertificationRepositoryCustomImpl certificationRepositoryCustomImpl; | ||
| private final UserService userService; | ||
| private final FavoriteRepository favoriteRepository; | ||
|
|
||
|
|
||
| @Cacheable( | ||
|
|
@@ -197,4 +202,36 @@ public CertificationListResponse getCertificationList(final Long userId, final b | |
|
|
||
| } | ||
|
|
||
| public List<CertificationRankResponse> getCertificationJob(final Long userId){ | ||
| User user = userService.getUser(userId); | ||
| String jobName = userService.getUserJob(userId).jobList().get(0); | ||
| Job job = jobRepository.findByName(jobName) | ||
| .orElseThrow(() -> new NotFoundException(ErrorCode.JOB_NOT_FOUND)); | ||
|
|
||
| Pageable top3 = PageRequest.of(0, 3); | ||
| List<Certification> certList = | ||
| favoriteRepository.findTopByJobOrderByFavoriteCount(job.getId(), top3); | ||
|
|
||
| AtomicInteger rank = new AtomicInteger(1); | ||
|
|
||
| return certList.stream() | ||
| .map(cert -> new CertificationRankResponse(rank.getAndIncrement(), cert)) | ||
| .toList(); | ||
| } | ||
|
|
||
| public List<CertificationRankResponse> getCertificationTrack(final Long userId){ | ||
| User user = userService.getUser(userId); | ||
| TrackType trackType = user.getTrack(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find src -name "User.java" -type f | head -20Repository: cerdeuk/CERTI-BE Length of output: 124 🏁 Script executed: cat -n src/main/java/org/sopt/certi_server/domain/certification/service/CertificationService.java | sed -n '220,235p'Repository: cerdeuk/CERTI-BE Length of output: 725 🏁 Script executed: rg -A 10 "TrackType.*track" src/main/java/org/sopt/certi_server/domain/user/entity/User.javaRepository: cerdeuk/CERTI-BE Length of output: 737 🏁 Script executed: rg "findTopCertificationsByTrack" src/main/java/org/sopt/certi_server/domain/certification/repository/Repository: cerdeuk/CERTI-BE Length of output: 42 🏁 Script executed: cat -n src/main/java/org/sopt/certi_server/domain/user/entity/User.java | sed -n '1,100p'Repository: cerdeuk/CERTI-BE Length of output: 3137 🏁 Script executed: rg "private TrackType track" -A 5 -B 2 src/main/java/org/sopt/certi_server/domain/user/entity/User.javaRepository: cerdeuk/CERTI-BE Length of output: 253 🏁 Script executed: rg "findTopCertifications" src/main/java/ --type javaRepository: cerdeuk/CERTI-BE Length of output: 405 🏁 Script executed: rg "getUser" src/main/java/org/sopt/certi_server/domain/user/service/UserService.java -A 10Repository: cerdeuk/CERTI-BE Length of output: 1473 🏁 Script executed: cat -n src/main/java/org/sopt/certi_server/domain/favorite/repository/FavoriteRepository.java | grep -A 15 "findTopCertificationsByTrack"Repository: cerdeuk/CERTI-BE Length of output: 224 🏁 Script executed: cat src/main/java/org/sopt/certi_server/domain/favorite/repository/FavoriteRepository.javaRepository: cerdeuk/CERTI-BE Length of output: 2065 트랙 타입이 null인 경우 쿼리가 올바르게 작동하지 않습니다 User 엔티티의 trackType이 null인 경우를 처리하거나, 사용자의 track이 반드시 존재해야 한다면 명시적으로 검증하세요. 🤖 Prompt for AI Agents |
||
|
|
||
| Pageable top3 = PageRequest.of(0, 3); | ||
|
|
||
| List<Certification> certificationList = favoriteRepository.findTopCertificationsByTrack(trackType, top3); | ||
|
|
||
| AtomicInteger rank = new AtomicInteger(1); | ||
|
|
||
| return certificationList.stream() | ||
| .map(c -> new CertificationRankResponse(rank.getAndIncrement(), c)) | ||
| .toList(); | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.