Skip to content
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

[18조 BE] 10주차 코드 리뷰 신청 #106

Merged
merged 120 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
2909348
feat : 지원서 조회 기능 추가
Nov 4, 2024
f49166a
Merge branch 'ApplyAndUser-10' of https://github.com/kakao-tech-campu…
Nov 4, 2024
66dbed6
feat : 코드 정렬
Nov 4, 2024
ba2a1b3
Merge pull request #71 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
minsu-cnu Nov 4, 2024
189ea6a
Merge pull request #72 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 4, 2024
d9b91a7
Merge pull request #73 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 4, 2024
d44cf7e
Update deploy.yml : 일부만 CI/CD
minsu-cnu Nov 4, 2024
542fc07
Update deploy.yml
minsu-cnu Nov 4, 2024
bf63953
Merge pull request #74 from kakao-tech-campus-2nd-step3/minsu-cnu-pat…
minsu-cnu Nov 4, 2024
3c7cf83
Update deploy.yml
minsu-cnu Nov 4, 2024
df81a64
Update deploy.yml : .ssh 디렉토리 생성 코드 추가
minsu-cnu Nov 4, 2024
0434333
Update deploy.yml : 호스트 키 검증 비활성화
minsu-cnu Nov 4, 2024
6ff9b99
Update deploy.yml : 경로 수정
minsu-cnu Nov 4, 2024
d6b183f
Update deploy.yml : 프로퍼티 active를 prod로 덮어씌우도록 설정
minsu-cnu Nov 5, 2024
aac5a81
chore: test 프로퍼티 active (배포 시 CI/CD 상 prod로 덮어씌움)
minsu-cnu Nov 5, 2024
93e056d
fix: Configuration 어노테이션 누락된 것 추가
minsu-cnu Nov 6, 2024
0f74546
feat: CORS 헤더의 Authorization 필드만 허용하도록 변경
minsu-cnu Nov 6, 2024
265b1bc
Merge pull request #75 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 6, 2024
bd8b850
Merge pull request #76 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 6, 2024
ba55f4f
Merge pull request #77 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 6, 2024
0f8fe71
feat: 원활한 프론트 배포 연동 테스트를 위해 임시로 토큰 만료 기간 설정 제거
minsu-cnu Nov 6, 2024
be10ab4
Merge pull request #78 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 6, 2024
51d6d5a
Merge pull request #79 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 6, 2024
c66a693
Merge pull request #80 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 6, 2024
94947cd
feat: 프론트엔드 오리진 수정
minsu-cnu Nov 7, 2024
6990cce
Merge pull request #81 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 7, 2024
8581db8
Merge pull request #82 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 7, 2024
fa45305
Merge pull request #83 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 7, 2024
b960b57
chore: 인증 헤더가 없는 API 요청에도 CORS 헤더를 반환하도록 설정
minsu-cnu Nov 8, 2024
f124a3a
Merge pull request #84 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 8, 2024
a3083e1
Merge pull request #85 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
892e649
Merge pull request #86 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
62b5797
chore: 클라이언트에서 Authorization 헤더에 접근을 허용 설정
minsu-cnu Nov 8, 2024
7927caa
Merge pull request #87 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 8, 2024
0ca557c
Merge pull request #88 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
ebf0d90
Merge pull request #89 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
9b25661
feat: 로그인 응답에 name 필드 추가
minsu-cnu Nov 8, 2024
1ebeb40
Merge pull request #90 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 8, 2024
a207834
Merge pull request #91 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
ccb2f6d
Merge pull request #92 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
2c1579a
Refactor: 주석 추가
pkyung Nov 8, 2024
a2df977
feat : Optional적용
Nov 8, 2024
904ee99
fix : 필요한 매개변수 추가
Nov 8, 2024
399ec67
feat : 생성자 추가
Nov 8, 2024
cb38fbe
refactor : 메서드명 변경
Nov 8, 2024
c57357b
fix : Optional변경으로 인한 예외 처리 및 요청데이터 변경
Nov 8, 2024
9a906af
feat : 테스트 코드 구현
Nov 8, 2024
2d2fc73
feat : repository변경으로 인한 코드 수정
Nov 8, 2024
4dafb3c
refactor : 코드정렬
Nov 8, 2024
7e705b1
refactor : salary Long으로 변환
alsswl Nov 8, 2024
26b0a1c
refactor : 메서드 명 변경
alsswl Nov 8, 2024
8eba530
test : 구인글 테스트코드 작성
alsswl Nov 8, 2024
46ddf46
test : 이력서 테스트코드 작성
alsswl Nov 8, 2024
8fb1782
Merge pull request #93 from kakao-tech-campus-2nd-step3/Contract-10
minsu-cnu Nov 8, 2024
6f41e7f
Merge pull request #94 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
minsu-cnu Nov 8, 2024
67e919c
Merge pull request #95 from kakao-tech-campus-2nd-step3/ResumeAndRecr…
minsu-cnu Nov 8, 2024
a5dfd26
feat : 예외처리 추가
alsswl Nov 8, 2024
29dd321
Merge branch 'Weekly-10' into ResumeAndRecruitment-10
alsswl Nov 8, 2024
156147e
Merge pull request #96 from kakao-tech-campus-2nd-step3/ResumeAndRecr…
minsu-cnu Nov 8, 2024
3ac9580
Merge pull request #97 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
a721e39
Merge pull request #98 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
54edb2b
fix : 에러처리
alsswl Nov 8, 2024
8428946
fix : test코드 오류 수정(전화번호 추가)
Nov 8, 2024
0813928
Merge pull request #100 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
0945bc3
Merge pull request #102 from kakao-tech-campus-2nd-step3/ResumeAndRec…
minsu-cnu Nov 8, 2024
d1cd99a
Merge pull request #101 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
minsu-cnu Nov 8, 2024
e3d5152
Fix: swagger 문제 해결
pkyung Nov 8, 2024
7036d3d
Merge pull request #103 from kakao-tech-campus-2nd-step3/Contract-10
minsu-cnu Nov 8, 2024
1a7de67
Merge pull request #104 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
a50bea8
Merge pull request #105 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
f7f711c
Update deploy.yml : 깃헙 액션 유동 IP를 GCP SSH 규칙에 자동 등록
minsu-cnu Nov 8, 2024
a68d243
Update deploy.yml
minsu-cnu Nov 8, 2024
3d24f64
Update deploy.yml
minsu-cnu Nov 8, 2024
9c33c43
Update deploy.yml
minsu-cnu Nov 8, 2024
994520a
Update deploy.yml
minsu-cnu Nov 8, 2024
23af08a
Update deploy.yml
minsu-cnu Nov 8, 2024
16458df
Update deploy.yml
minsu-cnu Nov 8, 2024
658a14c
Update deploy.yml
minsu-cnu Nov 8, 2024
cb76153
Update deploy.yml
minsu-cnu Nov 8, 2024
a7eae0d
Update deploy.yml
minsu-cnu Nov 8, 2024
538b424
fix : 요청데이터 415오류
Nov 8, 2024
68e1250
Merge pull request #107 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
minsu-cnu Nov 8, 2024
51f8629
Merge pull request #108 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
f9f96c4
Merge pull request #109 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
6213962
fix : 413오류문제
Nov 8, 2024
0b01411
Merge pull request #110 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
minsu-cnu Nov 8, 2024
2d380a5
Merge pull request #111 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 8, 2024
e2dcac8
Merge pull request #112 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 8, 2024
118e153
feat : 회사 get 반환값을 리스트로 변경
Nov 8, 2024
fa3ec64
Merge pull request #113 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
LeeTaek2T Nov 8, 2024
4679c53
Merge pull request #114 from kakao-tech-campus-2nd-step3/Weekly-10
LeeTaek2T Nov 8, 2024
27e446a
Merge pull request #115 from kakao-tech-campus-2nd-step3/Develop
LeeTaek2T Nov 8, 2024
fff5bf1
feat : 회사response 수정
Nov 8, 2024
da9404e
Merge pull request #116 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
LeeTaek2T Nov 8, 2024
2dd8ea5
Merge pull request #117 from kakao-tech-campus-2nd-step3/Weekly-10
LeeTaek2T Nov 8, 2024
651be1e
Merge pull request #118 from kakao-tech-campus-2nd-step3/Develop
LeeTaek2T Nov 8, 2024
1c1b26b
fix : test오류 해결
Nov 9, 2024
2d09e78
feat: 로그인 API가 프론트엔드의 로컬 환경과 배포 환경에서의 요청에 둘 다 대응할 수 있도록 로직 구현
minsu-cnu Nov 9, 2024
b1690c9
Merge pull request #119 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
minsu-cnu Nov 9, 2024
cb7daae
Merge branch 'Weekly-10' of github.com:kakao-tech-campus-2nd-step3/Te…
minsu-cnu Nov 9, 2024
b5ab5d4
Merge pull request #120 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 9, 2024
b252e96
Merge pull request #121 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 9, 2024
70f7e13
Merge pull request #122 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 9, 2024
013d152
feat : 필수정보 반환값 변경
Nov 10, 2024
7c750d8
Merge pull request #123 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
LeeTaek2T Nov 10, 2024
cb6e194
Merge pull request #124 from kakao-tech-campus-2nd-step3/Weekly-10
LeeTaek2T Nov 10, 2024
6561e87
Merge pull request #125 from kakao-tech-campus-2nd-step3/Develop
LeeTaek2T Nov 10, 2024
1ff34db
fix : Lob colum 추가
alsswl Nov 10, 2024
e2e4e19
fix : Lob colum 추가
alsswl Nov 10, 2024
e35cc36
fix : swagger doc으로 수정
alsswl Nov 10, 2024
993eb33
Merge pull request #127 from kakao-tech-campus-2nd-step3/resume10update
minsu-cnu Nov 10, 2024
af483f0
Merge branch 'Weekly-10' of github.com:kakao-tech-campus-2nd-step3/Te…
minsu-cnu Nov 10, 2024
4904be1
fix: swagger 라이브러리 충돌 해결 및 설정 변경
minsu-cnu Nov 10, 2024
75ba166
Merge pull request #128 from kakao-tech-campus-2nd-step3/Auth-10
minsu-cnu Nov 10, 2024
a8369d8
Merge pull request #129 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 10, 2024
1dfe252
Merge pull request #130 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 10, 2024
047ef5b
fix : pageable에 totalpage 추가
alsswl Nov 10, 2024
c9bbdac
Merge pull request #131 from kakao-tech-campus-2nd-step3/resume10update
minsu-cnu Nov 10, 2024
f184684
Merge pull request #132 from kakao-tech-campus-2nd-step3/Weekly-10
minsu-cnu Nov 10, 2024
b8ca305
Merge pull request #133 from kakao-tech-campus-2nd-step3/Develop
minsu-cnu Nov 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 58 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
java-version: '21'
distribution: 'adopt'

- name : Override APPLICATION PROPERTIES
run : echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.properties

- name: Configure Production Properties
run: |
touch ./src/main/resources/application-prod.properties
Expand All @@ -47,7 +50,7 @@ jobs:
with:
name: team18-be-jar
path: build/libs/team18-be-0.0.1-SNAPSHOT.jar

deploy:
runs-on: ubuntu-latest
needs: build
Expand All @@ -58,21 +61,62 @@ jobs:
with:
name: team18-be-jar

- name: Deploy to GCP
- name: Authenticate with GCP
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}"

- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
minsu-cnu marked this conversation as resolved.
Show resolved Hide resolved

- name: Get GitHub Actions Runner IP
id: get_ip
run: |
# 필요한 패키지 설치
sudo apt-get update
sudo apt-get install -y google-cloud-cli
echo $(curl -s https://api64.ipify.org) > RUNNER_IP.txt

# GCP 인증
echo "${{ secrets.HIREHIGHER_GCP_KEY }}" | base64 --decode > ${HOME}/gcp-key.json
gcloud auth activate-service-account --key-file=${HOME}/gcp-key.json
- name: Add GitHub Actions IP to GCP Firewall
run: |
RUNNER_IP=$(cat RUNNER_IP.txt)

# 기존의 source-ranges 값 가져오기
EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "")

# 세미콜론 제거
EXCLUDE_IPS=$(echo $EXCLUDE_IPS | sed 's/;/,/g')

# GitHub Actions IP를 추가
gcloud compute firewall-rules update default-allow-ssh \
--allow tcp:22 \
--source-ranges="${EXCLUDE_IPS},${RUNNER_IP}/32"

- name: Configure SSH private key
run: |
touch ./key-hirehigher
echo "${{ secrets.HIREHIGHER_GCP_SSH_KEY }}" > ./key-hirehigher
chmod 600 ./key-hirehigher
minsu-cnu marked this conversation as resolved.
Show resolved Hide resolved

# GCP 프로젝트 설정
gcloud config set project fleet-point-420405
- name: Add GCP VM to known_hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H "${{ secrets.GCP_VM_IP }}" >> ~/.ssh/known_hosts

# GCP VM 인스턴스에 JAR 파일 전송
gcloud compute scp ./build/libs/team18-be-0.0.1-SNAPSHOT.jar hirehigher-api:/home/hirehigher/repository --zone asia-northeast3-a
- name: Deploy to GCP
run: |
# scp로 VM에 jar 파일 전송
scp -o StrictHostKeyChecking=no -i ./key-hirehigher ./team18-be-0.0.1-SNAPSHOT.jar hirehigher@${{ secrets.GCP_VM_IP }}:/home/hirehigher/repository

# GCP VM에서 배포 쉘 스크립트 실행
gcloud compute ssh hirehigher-api --zone asia-northeast3-a --command 'bash /home/hirehigher/repository/deploy.sh'
- name: Remove GitHub Actions IP from GCP Firewall
run: |
RUNNER_IP=$(cat RUNNER_IP.txt)

# 기존 firewall 규칙 가져오기
EXCLUDE_IPS=$(gcloud compute firewall-rules describe default-allow-ssh --format="get(sourceRanges)" || echo "")

# GitHub Actions IP를 제외한 source ranges 설정
NEW_SOURCE_RANGES=$(echo $EXCLUDE_IPS | sed "s/$RUNNER_IP\/32//g" | sed 's/;/,/g')

# 업데이트된 firewall 규칙 적용
gcloud compute firewall-rules update default-allow-ssh \
--source-ranges=$NEW_SOURCE_RANGES
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies {
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
runtimeOnly 'com.h2database:h2'
implementation 'jakarta.validation:jakarta.validation-api:3.0.2'
implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13.2'
implementation group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.13'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-03T19:16:36+0900",
date = "2024-11-10T20:46:08+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 21.0.3 (Eclipse Adoptium)"
)
@Component
Expand Down Expand Up @@ -60,7 +60,7 @@ public RecruitmentResponse toRecruitmentResponse(Recruitment recruitment, Recrui
String vietnameseTitle = null;
String companySize = null;
String area = null;
String salary = null;
Long salary = null;
String workDuration = null;
String workDays = null;
String workType = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-03T19:16:36+0900",
date = "2024-11-10T20:46:08+0900",
comments = "version: 1.5.3.Final, compiler: javac, environment: Java 21.0.3 (Eclipse Adoptium)"
)
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import team18.team18_be.apply.dto.request.ApplicationFormRequest;
import team18.team18_be.apply.dto.response.ApplicationFormResponse;
import team18.team18_be.apply.dto.response.ApplierPerRecruitmentResponse;
import team18.team18_be.apply.dto.response.MandatoryResponse;
import team18.team18_be.apply.dto.response.RecruitmentsOfApplierResponse;
import team18.team18_be.apply.service.ApplyService;
import team18.team18_be.auth.entity.User;
import team18.team18_be.config.resolver.LoginUser;


@RestController
@RequestMapping("/api/application")
@Tag(name = "지원 API")
Expand All @@ -42,6 +44,14 @@ public ResponseEntity<Void> createApplicationForm(
return ResponseEntity.created(location).build();
}

@Operation(summary = "특정 지원서 조회")
@GetMapping("/form/{applyId}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@GetMapping("/form/{applyId}")
@GetMapping("/{applyId}/form")

코드만 봤을 땐 이것이 더 어울려 보입니다.
자세한 도메인은 멘티님들이 더 잘 알고계시니 참고만 해주세요.

public ResponseEntity<ApplicationFormResponse> findApplicationForm(@PathVariable Long applyId,
@LoginUser User user) {
ApplicationFormResponse applicationFormResponse = applyService.findApplicationForm(applyId);
return ResponseEntity.ok(applicationFormResponse);
}

@Operation(summary = "구인글에 지원한 지원자 확인", description = "고용주가 자신이 올린 구인글에 누가 지원했는지 보여준다.")
@GetMapping("/{recruitmentId}")
public ResponseEntity<List<ApplierPerRecruitmentResponse>> searchApplicant(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package team18.team18_be.apply.dto.request;

public record ApplicationFormRequest(String name, String address, String applyMotivation) {
public record ApplicationFormRequest(String name,
String address,
String phoneNumber,
String motivation) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package team18.team18_be.apply.dto.response;

public record ApplicationFormResponse(
String name,
String address,
String phoneNumber,

String motivation
) {

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package team18.team18_be.apply.dto.response;

public record MandatoryResponse(boolean resumeExistence, boolean visaExistence,
boolean foreignerIdNumberExistence) {
boolean foreignerIdNumberExistence, boolean signExistence) {

}
7 changes: 7 additions & 0 deletions src/main/java/team18/team18_be/apply/entity/Apply.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public Apply(String status, User user, Recruitment recruitment) {
this.recruitment = recruitment;
}

public Apply(Long id, String status, User user, Recruitment recruitment) {
this.id = id;
this.status = status;
this.user = user;
this.recruitment = recruitment;
}

public Long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package team18.team18_be.apply.repository;


import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import team18.team18_be.apply.entity.ApplicationForm;
import team18.team18_be.apply.entity.Apply;

public interface ApplicationFormRepository extends JpaRepository<ApplicationForm, Long> {

ApplicationForm findByApply(Apply apply);
Optional<ApplicationForm> findByApply(Apply apply);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package team18.team18_be.apply.repository;

import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import team18.team18_be.apply.entity.Apply;
import team18.team18_be.auth.entity.User;
import team18.team18_be.recruitment.entity.Recruitment;

public interface ApplyRepository extends JpaRepository<Apply, Long> {

List<Apply> findByRecruitment(Recruitment recruitment);
Optional<List<Apply>> findByRecruitment(Recruitment recruitment);

List<Apply> findByUser(User user);
Optional<List<Apply>> findByUser(User user);
}
51 changes: 35 additions & 16 deletions src/main/java/team18/team18_be/apply/service/ApplyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.stereotype.Service;
import team18.team18_be.apply.ApplyStatusEnum.ApplyStatus;
import team18.team18_be.apply.dto.request.ApplicationFormRequest;
import team18.team18_be.apply.dto.response.ApplicationFormResponse;
import team18.team18_be.apply.dto.response.ApplierPerRecruitmentResponse;
import team18.team18_be.apply.dto.response.MandatoryResponse;
import team18.team18_be.apply.dto.response.RecruitmentsOfApplierResponse;
Expand All @@ -19,9 +20,9 @@
import team18.team18_be.resume.entity.Resume;
import team18.team18_be.resume.repository.ResumeRepository;
import team18.team18_be.userInformation.entity.Company;
import team18.team18_be.userInformation.entity.ForeignerInformation;
import team18.team18_be.userInformation.repository.CompanyRepository;
import team18.team18_be.userInformation.repository.ForeignerInformationRepository;
import team18.team18_be.userInformation.repository.SignRepository;

@Service
public class ApplyService {
Expand All @@ -32,18 +33,21 @@ public class ApplyService {
private final ResumeRepository resumeRepository;
private final CompanyRepository companyRepository;
private final ForeignerInformationRepository foreignerInformationRepository;
private final SignRepository signRepository;


public ApplyService(ApplicationFormRepository applicationFormRepository,
ApplyRepository applyRepository, RecruitmentRepository recruitmentRepository,
ResumeRepository resumeRepository, CompanyRepository companyRepository,
ForeignerInformationRepository foreignerInformationRepository) {
ForeignerInformationRepository foreignerInformationRepository,
SignRepository signRepository) {
this.applicationFormRepository = applicationFormRepository;
this.applyRepository = applyRepository;
this.recruitmentRepository = recruitmentRepository;
this.resumeRepository = resumeRepository;
this.companyRepository = companyRepository;
this.foreignerInformationRepository = foreignerInformationRepository;
this.signRepository = signRepository;
}

public Long createApplicationForm(ApplicationFormRequest applicationFormRequest,
Expand All @@ -53,17 +57,30 @@ public Long createApplicationForm(ApplicationFormRequest applicationFormRequest,
Apply apply = new Apply(status.getKoreanName(), user, recruitment);
Apply savedApply = applyRepository.save(apply);
ApplicationForm applicationForm = new ApplicationForm(applicationFormRequest.name(),
applicationFormRequest.address(), applicationFormRequest.address(),
applicationFormRequest.applyMotivation(), savedApply);
applicationFormRequest.address(), applicationFormRequest.phoneNumber(),
applicationFormRequest.motivation(), savedApply);
applicationFormRepository.save(applicationForm);
return savedApply.getId();
}

public ApplicationFormResponse findApplicationForm(Long applyId) {
Apply apply = applyRepository.findById(applyId)
.orElseThrow(() -> new NoSuchElementException("해당 지원서가 없습니다"));
ApplicationForm applicationForm = applicationFormRepository.findByApply(apply)
.orElseThrow(() -> new NoSuchElementException("해당 지원서가 없습니다."));
ApplicationFormResponse applicationFormResponse = new ApplicationFormResponse(
applicationForm.getName(), applicationForm.getAddress(), applicationForm.getPhoneNumber(),
applicationForm.getMotivation());
return applicationFormResponse;
}


public List<ApplierPerRecruitmentResponse> searchApplicant(Long recruitmentId, User user) {
Recruitment recruitment = findRecruitment(recruitmentId);

return applyRepository.findByRecruitment(recruitment).stream()
return applyRepository.findByRecruitment(recruitment)
.orElseThrow(() -> new NoSuchElementException("해당하는 지원이 없습니다."))
.stream()
.map(this::createApplierPerRecruitmentResponse)
.collect(Collectors.toList());
}
Expand All @@ -78,7 +95,9 @@ private ApplierPerRecruitmentResponse createApplierPerRecruitmentResponse(Apply
}

public List<RecruitmentsOfApplierResponse> searchMyAppliedRecruitments(User user) {
return applyRepository.findByUser(user).stream()
return applyRepository.findByUser(user)
.orElseThrow(() -> new NoSuchElementException("해당하는 지원이 없습니다."))
.stream()
.map(this::createMyAppliedRecruitments)
.collect(Collectors.toList());
}
Expand All @@ -96,13 +115,17 @@ private RecruitmentsOfApplierResponse createMyAppliedRecruitments(Apply apply) {
}

public MandatoryResponse checkMandatory(User user) {
ForeignerInformation foreignerInformation = foreignerInformationRepository.findByUser(user);
Resume resume = resumeRepository.findByUser(user);
boolean visaExistence = checkNull(foreignerInformation.getForeignerIdNumber());
boolean resumeExistence = checkNull(foreignerInformation.getVisaGenerateDate());
boolean foreignerIdNumberExistence = checkNull(resume);
boolean visaExistence = foreignerInformationRepository.findByUser(user)
.map(info -> info.getVisaGenerateDate() != null)
.orElse(false);
boolean foreignerIdNumberExistence = foreignerInformationRepository.findByUser(user)
.map(info -> info.getForeignerIdNumber() != null)
.orElse(false);
boolean resumeExistence = resumeRepository.findByUser(user) != null;
boolean signExistence = signRepository.findByUser(user).isPresent();

MandatoryResponse mandatoryResponse = new MandatoryResponse(resumeExistence, visaExistence,
foreignerIdNumberExistence);
foreignerIdNumberExistence, signExistence);
return mandatoryResponse;
}

Expand All @@ -111,8 +134,4 @@ private Recruitment findRecruitment(Long recruitmentId) {
.orElseThrow(() -> new NoSuchElementException("해당되는 구인글이 없습니다."));
return recruitment;
}

private boolean checkNull(Object object) {
return object != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
Expand Down Expand Up @@ -47,17 +48,20 @@ public AuthController(AuthService authService) {
@ApiResponse(responseCode = "500", description = "서버 내부 에러", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@PostMapping("/oauth")
public ResponseEntity<UserTypeResponse> login(@RequestBody CodeRequest codeRequest) {
public ResponseEntity<UserTypeResponse> login(@RequestBody CodeRequest codeRequest,
HttpServletRequest request) {
String referer = request.getHeader("Referer");
minsu-cnu marked this conversation as resolved.
Show resolved Hide resolved

OAuthJwtResponse oAuthJwtResponse = authService.getOAuthToken(codeRequest,
GOOGLE_TOKEN_URI);
GOOGLE_TOKEN_URI, referer);
LoginResponse loginResponse = authService.registerOAuth(oAuthJwtResponse,
GOOGLE_USER_INFO_URI);

HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(loginResponse.accessToken());

UserTypeResponse userTypeResponse = new UserTypeResponse(loginResponse.type(),
loginResponse.profileImage());
loginResponse.profileImage(), loginResponse.name());

return new ResponseEntity<>(userTypeResponse, headers, HttpStatus.OK);
minsu-cnu marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading
Loading