Skip to content

Commit

Permalink
Feat: 회원 맞춤 기술스택 조회 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonseon12 committed Jan 22, 2024
1 parent c88dd81 commit 5c2cf53
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
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;
import kernel.jdon.skill.dto.response.FindListDataBySkillResponse;
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;

Expand All @@ -33,24 +34,11 @@ public ResponseEntity<CommonResponse> getHotSkillList() {
}

@GetMapping("/api/v1/skills/member")
public ResponseEntity<CommonResponse> getMemberSkillList() {
public ResponseEntity<CommonResponse> getMemberSkillList(@LoginUser SessionUserInfo sessionUser) {
Long memberId = sessionUser.getId();
FindListMemberSkillResponse findMemberSkillList = skillService.findMemberSkillList(memberId);

List<FindMemberSkillResponse> 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}")
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import kernel.jdon.skill.dto.object.FindMemberSkillDto;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -13,5 +14,5 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class FindListMemberSkillResponse {
private List<FindMemberSkillResponse> skillList;
private List<FindMemberSkillDto> skillList;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<FindHotSkillDto> findHotSkillList();

List<FindMemberSkillDto> findMemberSkillList(Long memberId);
}
Original file line number Diff line number Diff line change
@@ -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.*;

Expand All @@ -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
Expand All @@ -21,14 +24,25 @@ public List<FindHotSkillDto> 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<FindMemberSkillDto> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -22,6 +24,12 @@ public FindListHotSkillResponse findHotSkillList() {
return new FindListHotSkillResponse(findHotSkillList);
}

public FindListMemberSkillResponse findMemberSkillList(Long memberId) {
List<FindMemberSkillDto> findMemberSkillList = skillRepository.findMemberSkillList(memberId);

return new FindListMemberSkillResponse(findMemberSkillList);
}

public FindListJobCategorySkillResponse findJobCategorySkillList(Long jobCategoryId) {
List<FindJobCategorySkillResponse> findJobCategorySkillList = skillRepository.findAllByJobCategoryId(jobCategoryId)
.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 5c2cf53

Please sign in to comment.