Skip to content

Commit

Permalink
Merge branch 'develop' into feature/career-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tape4 authored Nov 11, 2024
2 parents 47c34e7 + 5b3bb87 commit e8cb213
Show file tree
Hide file tree
Showing 32 changed files with 589 additions and 44 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/CICD_DEVELOP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,26 @@ jobs:
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: |
Server successfully updated to Commit[${{ steps.slug.outputs.sha7 }}] on branch ${{ github.ref_name }}
Commit message: ${{ github.event.head_commit.message }}
:o: Server successfully updated!
Commit: [${{ github.sha }}]
Branch: ${{ github.ref_name }}
Commit Link: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
GitHub Action Link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
GitHub Action Link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
failure_notification:
name: Failure Notification
runs-on: ubuntu-latest
if: failure()

steps:
- name: Discord Webhook Action on Failure
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: |
:x: A job failed in the CI/CD pipeline!
Commit: [${{ github.sha }}]
Branch: ${{ github.ref_name }}
Commit Link: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
GitHub Action Link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
Please check the logs for more details.
21 changes: 3 additions & 18 deletions .github/workflows/CI_MVP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,9 @@ name: CI FOR MVP

on:
push:
branches:
- mvp/apply
- mvp/member
- mvp/career
- mvp/portfolio
- feature/record
- feature/home
- feature/recruit-tag
- feature/login
- feature/login-memberTest
- refactor/career
- feature/login-recruit
- fix/record
- feature/errorFix
- fix/credential
- feature/dashboard
- feature/career-refactor
- feature/introduce
branches-ignore:
- main
- develop

jobs:
CI:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.persistence.AttributeConverter;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;

@Component
public class StringListToStringConverter implements AttributeConverter<List<String>, String> {
private static final ObjectMapper mapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class RecruitController {
private final ReviewService reviewService;
private final MemberService memberService;

// private final Member requestMember = Member.builder()
// .id(LoginUser.get().getId())
// .build();

@Operation(
summary = "지원 공고 생성",
description = "주어진 정보를 바탕으로 지원 공고 데이터를 생성합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package umc.kkijuk.server.recruit.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import umc.kkijuk.server.login.argumentresolver.Login;
import umc.kkijuk.server.login.controller.dto.LoginInfo;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.member.service.MemberService;
import umc.kkijuk.server.recruit.controller.port.RecruitSearchService;
import umc.kkijuk.server.recruit.controller.response.RecruitReviewListByKeywordResponse;

@Tag(name = "Search Recruit", description = "공고 검색 API")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/recruit")
public class RecruitSearchController {

private final RecruitSearchService recruitSearchService;
private final MemberService memberService;

@Operation(
summary = "공고 이름 & 태그 / 공고 후기 기준으로 검색",
description = "입력받은 텍스트에 대하여, 공고 제목, 공고 태그, 혹은 공고 후기에 포함하는 모든 공고를 검색합니다. 정렬기준은 최신순입니다.")
@GetMapping
public ResponseEntity<RecruitReviewListByKeywordResponse> findRecruitsByKeyword(
@Login LoginInfo loginInfo,
@RequestParam String keyword) {

Member requestMember = memberService.getById(loginInfo.getMemberId());
RecruitReviewListByKeywordResponse result = recruitSearchService.findRecruitByKeyword(requestMember, keyword);

return ResponseEntity
.ok()
.body(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import umc.kkijuk.server.common.LoginUser;
import umc.kkijuk.server.login.argumentresolver.Login;
import umc.kkijuk.server.login.controller.dto.LoginInfo;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.member.service.MemberService;
import umc.kkijuk.server.recruit.controller.response.RecruitTagResponse;

import java.util.ArrayList;
import java.util.List;

@Tag(name = "recruitTag", description = "모집 공고 태그 API")
Expand All @@ -22,11 +20,6 @@
public class RecruitTagController {
private final MemberService memberService;

// private final Member requestMember = Member.builder()
// .id(LoginUser.get().getId())
// .recruitTags(new ArrayList<>(List.of("인턴", "정규직", "대외활동", "동아리")))
// .build();

@Operation(
summary = "지원 공고 태그",
description = "사용자의 지원 공고 태그 정보들을 요청합니다")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package umc.kkijuk.server.recruit.controller.port;

import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.recruit.controller.response.RecruitReviewListByKeywordResponse;

public interface RecruitSearchService {

public RecruitReviewListByKeywordResponse findRecruitByKeyword(Member requestMember, String keyword);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package umc.kkijuk.server.recruit.controller.port;

import org.springframework.transaction.annotation.Transactional;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.recruit.domain.*;

Expand All @@ -9,7 +8,6 @@
import java.util.List;

public interface RecruitService {
@Transactional
Recruit create(Member member, RecruitCreate recruitCreate);

Recruit update(Member member, Long recruitId, RecruitUpdate recruitUpdate);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package umc.kkijuk.server.recruit.controller.response;

import lombok.Builder;
import lombok.Getter;
import umc.kkijuk.server.recruit.domain.Recruit;
import umc.kkijuk.server.recruit.domain.RecruitStatus;

import java.time.LocalDateTime;
import java.util.List;

@Getter
@Builder
public class RecruitByKeyword {
private final Long recruitId;
private final String recruitTitle;
private final List<String> tags;
private final LocalDateTime startTime;
private final LocalDateTime endTime;
private final RecruitStatus status;

public static RecruitByKeyword from(Recruit recruit) {
return RecruitByKeyword.builder()
.recruitId(recruit.getId())
.recruitTitle(recruit.getTitle())
.tags(recruit.getTags())
.startTime(recruit.getStartTime())
.endTime(recruit.getEndTime())
.status(recruit.getStatus())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package umc.kkijuk.server.recruit.controller.response;

import lombok.Builder;
import lombok.Getter;
import umc.kkijuk.server.recruit.domain.RecruitListByMonthDto;
import umc.kkijuk.server.recruit.domain.RecruitStatus;
import umc.kkijuk.server.recruit.domain.ValidRecruitDto;

import java.util.Map;
import java.util.function.Consumer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Builder;
import lombok.Getter;
import umc.kkijuk.server.recruit.domain.RecruitListByMonthDto;
import umc.kkijuk.server.recruit.domain.RecruitStatus;

import java.util.ArrayList;
import java.util.Comparator;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package umc.kkijuk.server.recruit.controller.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import umc.kkijuk.server.recruit.domain.Recruit;
import umc.kkijuk.server.review.domain.RecruitReviewDto;
import umc.kkijuk.server.review.controller.response.ReviewByKeyword;

import java.util.ArrayList;
import java.util.List;

@Getter
@Builder
public class RecruitReviewListByKeywordResponse {
@Schema(description = "검색 키워드", example = "2024-07-19")
private final String keyword;

@Schema(description = "검색 키워드가 제목 또는 태그에 포함된 공고 목록")
private final List<RecruitByKeyword> recruitResult;

@Schema(description = "검색 키워드가 review에 포함된 공고 목록")
private final List<ReviewByKeyword> reviewResult;

public static RecruitReviewListByKeywordResponse from(String keyword, List<Recruit> recruits, List<RecruitReviewDto> reviews) {
List<ReviewByKeyword> reviewResult = new ArrayList<>();

for (RecruitReviewDto recruitReviewDto : reviews) {
ReviewByKeyword existingReview = reviewResult.stream()
.filter(r -> r.getRecruitId().equals(recruitReviewDto.getRecruitId()))
.findFirst()
.orElse(null);

if (existingReview == null) reviewResult.add(ReviewByKeyword.from(recruitReviewDto));
else existingReview.addReview(recruitReviewDto);
}


return RecruitReviewListByKeywordResponse.builder()
.keyword(keyword)
.recruitResult(recruits.stream().map(RecruitByKeyword::from).toList())
.reviewResult(reviewResult)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package umc.kkijuk.server.recruit.controller.response;

import lombok.Builder;
import lombok.Getter;
import umc.kkijuk.server.recruit.domain.ValidRecruitDto;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public interface RecruitJpaRepository extends JpaRepository<RecruitEntity, Long>
List<RecruitEntity> findAllByMemberIdAndActive(Long memberId, boolean active);
@Query(value = "SELECT * FROM recruit as e WHERE e.member_id = :memberId AND e.active = true AND YEAR(e.end_time) = :year AND MONTH(e.end_time) = :month", nativeQuery = true)
List<RecruitEntity> findAllByMemberIdAndMonth(@Param("memberId") Long memberId, @Param("year") Integer year, @Param("month") Integer month);

@Query(value = "SELECT * FROM recruit as r WHERE r.member_id = :memberId AND r.active = true AND" +
"(r.title LIKE %:keyword% OR r.tags LIKE %:keyword%) ORDER BY r.end_time DESC ", nativeQuery = true)
List<RecruitEntity> findRecruitByMemberIdAndTitleOrTagsContaining(@Param("memberId") Long memberId,
@Param("keyword") String keyword);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,10 @@ public List<Recruit> findAllActiveRecruitByMemberIdAndMonth(Long memberId, Integ
return recruitJpaRepository.findAllByMemberIdAndMonth(memberId, year, month)
.stream().map(RecruitEntity::toModel).toList();
}

@Override
public List<Recruit> searchRecruitByKeyword(Long memberId, String keyword) {
return recruitJpaRepository.findRecruitByMemberIdAndTitleOrTagsContaining(memberId, keyword)
.stream().map(RecruitEntity::toModel).toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package umc.kkijuk.server.recruit.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.recruit.controller.port.RecruitSearchService;
import umc.kkijuk.server.recruit.controller.response.RecruitReviewListByKeywordResponse;
import umc.kkijuk.server.recruit.domain.Recruit;
import umc.kkijuk.server.review.domain.RecruitReviewDto;
import umc.kkijuk.server.recruit.service.port.RecruitRepository;
import umc.kkijuk.server.review.service.port.ReviewRepository;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class RecruitSearchServiceImpl implements RecruitSearchService {
private final RecruitRepository recruitRepository;
private final ReviewRepository reviewRepository;

public RecruitReviewListByKeywordResponse findRecruitByKeyword(Member requestMember, String keyword) {
List<Recruit> recruits = recruitRepository.searchRecruitByKeyword(requestMember.getId(), keyword);
List<RecruitReviewDto> reviews = reviewRepository.findReviewByKeyword(requestMember.getId(), keyword);

for (RecruitReviewDto review : reviews) {
log.info("keyword: {}, result: {}", keyword, review.getReviewContent());
}

return RecruitReviewListByKeywordResponse.from(keyword, recruits, reviews);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public interface RecruitRepository {
List<Recruit> findAllActiveRecruitByMemberIdAndEndTimeAfter(Long memberId, LocalDateTime endTime);
List<Recruit> findAllActiveRecruitByMemberId(Long memberId);
List<Recruit> findAllActiveRecruitByMemberIdAndMonth(Long memberId, Integer year, Integer month);
List<Recruit> searchRecruitByKeyword(Long memberId, String searchQuery);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import umc.kkijuk.server.login.argumentresolver.Login;
Expand All @@ -28,10 +29,6 @@ public class ReviewController {
private final RecruitService recruitService;
private final MemberService memberService;

// private final Member requestMember = Member.builder()
// .id(LoginUser.get().getId())
// .build();

@Operation(
summary = "지원 공고 후기 추가",
description = "주어진 지원 공고에 후기를 생성합니다")
Expand All @@ -47,7 +44,7 @@ public ResponseEntity<ReviewIdResponse> create(
Review review = reviewService.create(requestMember, recruit, reviewCreate);

return ResponseEntity
.ok()
.status(HttpStatus.CREATED)
.body(ReviewIdResponse.from(review));
}

Expand Down
Loading

0 comments on commit e8cb213

Please sign in to comment.