diff --git a/module-api/src/main/java/kernel/jdon/coffeechat/service/CoffeeChatService.java b/module-api/src/main/java/kernel/jdon/coffeechat/service/CoffeeChatService.java index 41569eeb7..ec9967d37 100644 --- a/module-api/src/main/java/kernel/jdon/coffeechat/service/CoffeeChatService.java +++ b/module-api/src/main/java/kernel/jdon/coffeechat/service/CoffeeChatService.java @@ -12,9 +12,9 @@ import kernel.jdon.coffeechat.dto.response.UpdateCoffeeChatResponse; import kernel.jdon.coffeechat.error.CoffeeChatErrorCode; import kernel.jdon.coffeechat.repository.CoffeeChatRepository; -import kernel.jdon.error.code.api.MemberErrorCode; import kernel.jdon.global.exception.ApiException; import kernel.jdon.member.domain.Member; +import kernel.jdon.member.error.MemberErrorCode; import kernel.jdon.member.repository.MemberRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/module-api/src/main/java/kernel/jdon/skill/controller/SkillController.java b/module-api/src/main/java/kernel/jdon/skill/controller/SkillController.java index ebab8ffb5..4765454f1 100644 --- a/module-api/src/main/java/kernel/jdon/skill/controller/SkillController.java +++ b/module-api/src/main/java/kernel/jdon/skill/controller/SkillController.java @@ -9,7 +9,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import kernel.jdon.auth.dto.SessionUserInfo; import kernel.jdon.dto.response.CommonResponse; +import kernel.jdon.global.annotation.LoginUser; import kernel.jdon.skill.dto.response.FindCompanyBySkillResponse; import kernel.jdon.skill.dto.response.FindJdResponse; import kernel.jdon.skill.dto.response.FindLectureResponse; @@ -17,7 +19,6 @@ import kernel.jdon.skill.dto.response.FindListHotSkillResponse; import kernel.jdon.skill.dto.response.FindListJobCategorySkillResponse; import kernel.jdon.skill.dto.response.FindListMemberSkillResponse; -import kernel.jdon.skill.dto.response.FindMemberSkillResponse; import kernel.jdon.skill.service.SkillService; import lombok.RequiredArgsConstructor; @@ -33,24 +34,11 @@ public ResponseEntity getHotSkillList() { } @GetMapping("/api/v1/skills/member") - public ResponseEntity getMemberSkillList() { + public ResponseEntity getMemberSkillList(@LoginUser SessionUserInfo sessionUser) { + Long memberId = sessionUser.getId(); + FindListMemberSkillResponse findMemberSkillList = skillService.findMemberSkillList(memberId); - List findMemberSkillResponseList = new ArrayList<>(); - for (long i = 1; i <= 5; i++) { - FindMemberSkillResponse findMemberSkillResponse = FindMemberSkillResponse.builder() - .skillId(i) - .keyword("member_skill_" + i) - .build(); - - findMemberSkillResponseList.add(findMemberSkillResponse); - } - - FindListMemberSkillResponse findListMemberSkillResponse = - FindListMemberSkillResponse.builder() - .skillList(findMemberSkillResponseList) - .build(); - - return ResponseEntity.ok(CommonResponse.of(findListMemberSkillResponse)); + return ResponseEntity.ok(CommonResponse.of(findMemberSkillList)); } @GetMapping("/api/v1/skills/job-category/{jobCategoryId}") diff --git a/module-api/src/main/java/kernel/jdon/skill/dto/object/FindMemberSkillDto.java b/module-api/src/main/java/kernel/jdon/skill/dto/object/FindMemberSkillDto.java new file mode 100644 index 000000000..b3202a3c2 --- /dev/null +++ b/module-api/src/main/java/kernel/jdon/skill/dto/object/FindMemberSkillDto.java @@ -0,0 +1,22 @@ +package kernel.jdon.skill.dto.object; + +import com.querydsl.core.annotations.QueryProjection; + +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class FindMemberSkillDto { + private Long skillId; + private String keyword; + + @QueryProjection + public FindMemberSkillDto(Long skillId, String keyword) { + this.skillId = skillId; + this.keyword = keyword; + } +} diff --git a/module-api/src/main/java/kernel/jdon/skill/dto/response/FindHotSkillResponse.java b/module-api/src/main/java/kernel/jdon/skill/dto/response/FindHotSkillResponse.java deleted file mode 100644 index d36e69573..000000000 --- a/module-api/src/main/java/kernel/jdon/skill/dto/response/FindHotSkillResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package kernel.jdon.skill.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class FindHotSkillResponse { - private String keyword; - - public static FindHotSkillResponse of(String keyword) { - return new FindHotSkillResponse(keyword); - } -} diff --git a/module-api/src/main/java/kernel/jdon/skill/dto/response/FindListMemberSkillResponse.java b/module-api/src/main/java/kernel/jdon/skill/dto/response/FindListMemberSkillResponse.java index aac31495c..a4a8fd36d 100644 --- a/module-api/src/main/java/kernel/jdon/skill/dto/response/FindListMemberSkillResponse.java +++ b/module-api/src/main/java/kernel/jdon/skill/dto/response/FindListMemberSkillResponse.java @@ -2,6 +2,7 @@ import java.util.List; +import kernel.jdon.skill.dto.object.FindMemberSkillDto; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -13,5 +14,5 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) @AllArgsConstructor public class FindListMemberSkillResponse { - private List skillList; + private List skillList; } diff --git a/module-api/src/main/java/kernel/jdon/skill/dto/response/FindMemberSkillResponse.java b/module-api/src/main/java/kernel/jdon/skill/dto/response/FindMemberSkillResponse.java deleted file mode 100644 index 5b4bebbd4..000000000 --- a/module-api/src/main/java/kernel/jdon/skill/dto/response/FindMemberSkillResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package kernel.jdon.skill.dto.response; - -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Builder -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor -public class FindMemberSkillResponse { - private Long skillId; - private String keyword; -} diff --git a/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryCustom.java b/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryCustom.java index 12bc93868..4e5d709dd 100644 --- a/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryCustom.java +++ b/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryCustom.java @@ -3,7 +3,10 @@ import java.util.List; import kernel.jdon.skill.dto.object.FindHotSkillDto; +import kernel.jdon.skill.dto.object.FindMemberSkillDto; public interface SkillRepositoryCustom { List findHotSkillList(); + + List findMemberSkillList(Long memberId); } diff --git a/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryImpl.java b/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryImpl.java index 0507a06ec..d64672dfb 100644 --- a/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryImpl.java +++ b/module-api/src/main/java/kernel/jdon/skill/repository/SkillRepositoryImpl.java @@ -1,5 +1,6 @@ package kernel.jdon.skill.repository; +import static kernel.jdon.memberskill.domain.QMemberSkill.*; import static kernel.jdon.skill.domain.QSkill.*; import static kernel.jdon.skillhistory.domain.QSkillHistory.*; @@ -8,7 +9,9 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import kernel.jdon.skill.dto.object.FindHotSkillDto; +import kernel.jdon.skill.dto.object.FindMemberSkillDto; import kernel.jdon.skill.dto.object.QFindHotSkillDto; +import kernel.jdon.skill.dto.object.QFindMemberSkillDto; import lombok.RequiredArgsConstructor; @RequiredArgsConstructor @@ -21,14 +24,25 @@ public List findHotSkillList() { final int hotSkillKeywordCount = 10; return jpaQueryFactory - .select(new QFindHotSkillDto(skill.id, skill.keyword)) - .from(skillHistory) - .innerJoin(skill) - .on(skillHistory.jobCategory.id.eq(skill.jobCategory.id) - .and(skillHistory.keyword.eq(skill.keyword))) - .groupBy(skill.id, skill.keyword) - .orderBy(skill.keyword.count().desc()) - .limit(hotSkillKeywordCount) - .fetch(); + .select(new QFindHotSkillDto(skill.id, skill.keyword)) + .from(skillHistory) + .innerJoin(skill) + .on(skillHistory.jobCategory.id.eq(skill.jobCategory.id) + .and(skillHistory.keyword.eq(skill.keyword))) + .groupBy(skill.id, skill.keyword) + .orderBy(skill.keyword.count().desc()) + .limit(hotSkillKeywordCount) + .fetch(); + } + + @Override + public List findMemberSkillList(Long memberId) { + return jpaQueryFactory + .select(new QFindMemberSkillDto(skill.id, skill.keyword)) + .from(memberSkill) + .leftJoin(skill) + .on(memberSkill.skill.id.eq(skill.id)) + .where(memberSkill.member.id.eq(memberId)) + .fetch(); } } diff --git a/module-api/src/main/java/kernel/jdon/skill/service/SkillService.java b/module-api/src/main/java/kernel/jdon/skill/service/SkillService.java index 54d663dcc..5dd4d87d7 100644 --- a/module-api/src/main/java/kernel/jdon/skill/service/SkillService.java +++ b/module-api/src/main/java/kernel/jdon/skill/service/SkillService.java @@ -5,9 +5,11 @@ import org.springframework.stereotype.Service; import kernel.jdon.skill.dto.object.FindHotSkillDto; +import kernel.jdon.skill.dto.object.FindMemberSkillDto; import kernel.jdon.skill.dto.response.FindJobCategorySkillResponse; import kernel.jdon.skill.dto.response.FindListHotSkillResponse; import kernel.jdon.skill.dto.response.FindListJobCategorySkillResponse; +import kernel.jdon.skill.dto.response.FindListMemberSkillResponse; import kernel.jdon.skill.repository.SkillRepository; import lombok.RequiredArgsConstructor; @@ -22,6 +24,12 @@ public FindListHotSkillResponse findHotSkillList() { return new FindListHotSkillResponse(findHotSkillList); } + public FindListMemberSkillResponse findMemberSkillList(Long memberId) { + List findMemberSkillList = skillRepository.findMemberSkillList(memberId); + + return new FindListMemberSkillResponse(findMemberSkillList); + } + public FindListJobCategorySkillResponse findJobCategorySkillList(Long jobCategoryId) { List findJobCategorySkillList = skillRepository.findAllByJobCategoryId(jobCategoryId) .stream() diff --git a/module-domain/src/main/java/kernel/jdon/memberskill/domain/MemberSkill.java b/module-domain/src/main/java/kernel/jdon/memberskill/domain/MemberSkill.java index 2b7af59f1..6928407e8 100644 --- a/module-domain/src/main/java/kernel/jdon/memberskill/domain/MemberSkill.java +++ b/module-domain/src/main/java/kernel/jdon/memberskill/domain/MemberSkill.java @@ -1,13 +1,6 @@ package kernel.jdon.memberskill.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; +import jakarta.persistence.*; import kernel.jdon.member.domain.Member; import kernel.jdon.skill.domain.Skill; import lombok.Builder;