Skip to content

Commit

Permalink
Feature: 직군 별 기술 스택 조회하기 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonseon12 committed Jan 18, 2024
1 parent 77e2470 commit 5a482fb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import kernel.jdon.dto.response.CommonResponse;
import kernel.jdon.skill.dto.response.FindCompanyBySkillResponse;
import kernel.jdon.skill.dto.response.FindJdResponse;
import kernel.jdon.skill.dto.response.FindJobCategorySkillResponse;
import kernel.jdon.skill.dto.response.FindLectureResponse;
import kernel.jdon.skill.dto.response.FindListDataBySkillResponse;
import kernel.jdon.skill.dto.response.FindListHotSkillResponse;
Expand Down Expand Up @@ -56,21 +55,8 @@ public ResponseEntity<CommonResponse> getMemberSkillList() {

@GetMapping("/api/v1/skills/job-category/{jobCategoryId}")
public ResponseEntity<CommonResponse> getJobCategorySkillList(@PathVariable Long jobCategoryId) {

List<FindJobCategorySkillResponse> findJobCategorySkillResponseList = new ArrayList<>();
for (long i = 1; i <= 5; i++) {
FindJobCategorySkillResponse findJobCategorySkillResponse = FindJobCategorySkillResponse.builder()
.skillId(i)
.keyword("jobCategory_skill_" + i)
.build();

findJobCategorySkillResponseList.add(findJobCategorySkillResponse);
}

FindListJobCategorySkillResponse findListJobCategorySkillResponse =
FindListJobCategorySkillResponse.builder()
.skillList(findJobCategorySkillResponseList)
.build();
skillService.findJobCategorySkillList(jobCategoryId);

return ResponseEntity.ok(CommonResponse.of(findListJobCategorySkillResponse));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kernel.jdon.skill.dto.response;

import kernel.jdon.skill.domain.Skill;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -13,4 +14,11 @@
public class FindJobCategorySkillResponse {
private Long skillId;
private String keyword;

public static FindJobCategorySkillResponse of(Skill skill) {
return FindJobCategorySkillResponse.builder()
.skillId(skill.getId())
.keyword(skill.getKeyword())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package kernel.jdon.skill.repository;

public interface SkillRepository extends SkillDomainRepository, SkillRepositoryCustom {
import java.util.List;

import org.springframework.data.jpa.repository.Query;

import kernel.jdon.skill.domain.Skill;

public interface SkillRepository extends SkillDomainRepository, SkillRepositoryCustom {
@Query("select s from Skill s where s.keyword != '기타' and s.jobCategory.id = :jobCategoryId")
List<Skill> findAllByJobCategoryId(Long jobCategoryId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import org.springframework.stereotype.Service;

import kernel.jdon.skill.dto.object.FindHotSkillDto;
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.repository.SkillRepository;
import lombok.RequiredArgsConstructor;

Expand All @@ -19,4 +21,14 @@ public FindListHotSkillResponse findHotSkillList() {

return new FindListHotSkillResponse(findHotSkillList);
}

public FindListJobCategorySkillResponse findJobCategorySkillList(Long jobCategoryId) {
List<FindJobCategorySkillResponse> findJobCategorySkillList = skillRepository.findAllByJobCategoryId(jobCategoryId)
.stream()
.map(FindJobCategorySkillResponse::of)
.toList();


return new FindListJobCategorySkillResponse(findJobCategorySkillList);
}
}

0 comments on commit 5a482fb

Please sign in to comment.