Skip to content

Commit

Permalink
Merge pull request #56 from kkijuk/feature/introduce
Browse files Browse the repository at this point in the history
  • Loading branch information
tape4 authored Nov 19, 2024
2 parents 42e5a18 + d6fa096 commit 271d450
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
import umc.kkijuk.server.introduce.common.BaseResponse;
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.record.controller.response.FileResponse;
import umc.kkijuk.server.record.controller.response.UrlResponse;
import umc.kkijuk.server.record.dto.FileReqDto;
import umc.kkijuk.server.record.dto.UrlReqDto;
import umc.kkijuk.server.record.service.FileService;
import umc.kkijuk.server.record.service.RecordService;

import java.util.HashMap;
import java.util.Map;


Expand All @@ -29,7 +26,7 @@
public class FileController {

private final FileService fileService;
private final MemberService memberService;
private final RecordService recordService;

@GetMapping(value="/file")
@Operation(summary = "이력서(S3)-추가 자료<첨부파일> 저장(presignedUrl 생성)", description = "S3에 접근하기 위한 Presigned URL을 반환합니다.")
Expand All @@ -42,17 +39,20 @@ public class FileController {
}

@PostMapping(value="/file")
@Operation(summary = "이력서(S3)-추가 자료<첨부파일>(keyName 저장)", description = "주어진 keyName을 바탕으로 해당 파일에 대한 정보를 저장합니다.")
@Operation(summary = "이력서(S3)-추가 자료<첨부파일>(keyName 저장)",
description = "주어진 keyName을 바탕으로 해당 파일에 대한 정보를 저장합니다.")
public ResponseEntity<BaseResponse<FileResponse>> createFile
(@Login LoginInfo loginInfo, @Valid @RequestBody FileReqDto request) {
FileResponse fileResponse = fileService.createFile(loginInfo.getMemberId(),request);
FileResponse fileResponse = fileService.saveFile(loginInfo.getMemberId(),
recordService.findByMemberId(loginInfo.getMemberId()).getId(), request);
return ResponseEntity
.status(HttpStatus.CREATED)
.body(new BaseResponse<>(HttpStatus.CREATED.value(), "파일 정보 저장 완료",fileResponse));
}

@GetMapping("/file/download")
@Operation(summary = "이력서(S3)-추가 자료<첨부파일> 조회(presignedUrl 생성)", description = "fileName에 해당하는 presigned URL을 반환합니다.")
@Operation(summary = "이력서(S3)-추가 자료<첨부파일> 조회(presignedUrl 생성)",
description = "fileName에 해당하는 presigned URL을 반환합니다.")
public ResponseEntity<BaseResponse<Map<String,String>>> getDownloadUrl
(@Login LoginInfo loginInfo, @RequestParam String fileName) {
Map<String, String> response = fileService.getDownloadUrl(loginInfo.getMemberId(), fileName);
Expand All @@ -73,19 +73,20 @@ public ResponseEntity<BaseResponse<FileResponse>> deleteFile(@Login LoginInfo lo
@PostMapping("/url")
@Operation(summary = "이력서-추가 자료<URL> 저장", description = "추가자료 중 URL을 저장합니다.")
public ResponseEntity<Object> saveUrl(@Login LoginInfo loginInfo, @RequestBody UrlReqDto urlReqDto){
UrlResponse urlResponse = fileService.saveUrl(loginInfo.getMemberId(), urlReqDto);
FileResponse fileResponse = fileService.saveUrl(loginInfo.getMemberId(),
recordService.findByMemberId(loginInfo.getMemberId()).getId(), urlReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "URL 저장 완료", urlResponse));
.body(new BaseResponse<>(HttpStatus.OK.value(), "URL 저장 완료", fileResponse));
}

@DeleteMapping("/url")
@Operation(summary = "이력서-추가 자료<URL> 삭제", description = "추가자료 중 URL을 삭제합니다.")
public ResponseEntity<Object> deleteUrl(@Login LoginInfo loginInfo, @RequestBody UrlReqDto urlReqDto) {
UrlResponse urlResponse = fileService.deleteUrl(loginInfo.getMemberId(), urlReqDto);
FileResponse fileResponse = fileService.deleteUrl(loginInfo.getMemberId(), urlReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "URL 제거 완료", urlResponse));
.body(new BaseResponse<>(HttpStatus.OK.value(), "URL 제거 완료", fileResponse));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public ResponseEntity<Object> save(
@GetMapping
@Operation(summary = "이력서 전체 조회")
public ResponseEntity<Object> get(@Login LoginInfo loginInfo){
Member requestMember = memberService.getById(loginInfo.getMemberId());
RecordResponse recordResponse = recordService.getRecord(requestMember);
RecordResponse recordResponse = recordService.getRecord(loginInfo.getMemberId());
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "이력서 전체 조회 완료", recordResponse));
Expand All @@ -54,9 +53,9 @@ public ResponseEntity<Object> get(@Login LoginInfo loginInfo){
@Operation(summary = "이력서 정보 수정")
public ResponseEntity<Object> update(
@Login LoginInfo loginInfo,
Long recordId, @RequestBody RecordReqDto recordReqDto){
Member requestMember = memberService.getById(loginInfo.getMemberId());
RecordResponse recordResponse = recordService.updateRecord(requestMember, recordId, recordReqDto);
@RequestBody RecordReqDto recordReqDto){
RecordResponse recordResponse = recordService.updateRecord(loginInfo.getMemberId(),
recordService.findByMemberId(loginInfo.getMemberId()).getId(), recordReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "이력서 수정 완료", recordResponse));
Expand All @@ -66,9 +65,10 @@ public ResponseEntity<Object> update(
@Operation(summary = "학력 생성")
public ResponseEntity<Object> saveEducation(
@Login LoginInfo loginInfo,
Long recordId, @RequestBody EducationReqDto educationReqDto){
@RequestBody EducationReqDto educationReqDto){
Member requestMember = memberService.getById(loginInfo.getMemberId());
EducationResponse educationResponse = recordService.saveEducation(requestMember, recordId, educationReqDto);
EducationResponse educationResponse = recordService.saveEducation(requestMember,
recordService.findByMemberId(loginInfo.getMemberId()).getId(), educationReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "학력 생성 완료", educationResponse));
Expand Down Expand Up @@ -101,9 +101,10 @@ public ResponseEntity<Object> deleteEducation(@Login LoginInfo loginInfo, Long e
@Operation(summary = "자격증 생성")
public ResponseEntity<Object> saveLicense(
@Login LoginInfo loginInfo,
Long recordId, @RequestBody LicenseReqDto licenseReqDto){
@RequestBody LicenseReqDto licenseReqDto){
Member requestMember = memberService.getById(loginInfo.getMemberId());
LicenseResponse licenseResponse = recordService.saveLicense(requestMember, recordId, licenseReqDto);
LicenseResponse licenseResponse = recordService.saveLicense(requestMember,
recordService.findByMemberId(loginInfo.getMemberId()).getId(), licenseReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "자격증 생성 완료", licenseResponse));
Expand Down Expand Up @@ -135,9 +136,10 @@ public ResponseEntity<Object> deleteLicense(@Login LoginInfo loginInfo, Long lic
@Operation(summary = "수상 생성")
public ResponseEntity<Object> saveAward(
@Login LoginInfo loginInfo,
Long recordId, @RequestBody AwardReqDto awardReqDto){
@RequestBody AwardReqDto awardReqDto){
Member requestMember = memberService.getById(loginInfo.getMemberId());
AwardResponse awardResponse = recordService.saveAward(requestMember, recordId, awardReqDto);
AwardResponse awardResponse = recordService.saveAward(requestMember,
recordService.findByMemberId(loginInfo.getMemberId()).getId(), awardReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "수상 생성 완료", awardResponse));
Expand Down Expand Up @@ -169,9 +171,10 @@ public ResponseEntity<Object> deleteAward(@Login LoginInfo loginInfo, Long award
@Operation(summary = "스킬 생성")
public ResponseEntity<Object> saveSkill(
@Login LoginInfo loginInfo,
Long recordId, @RequestBody SkillReqDto skillReqDto){
@RequestBody SkillReqDto skillReqDto){
Member requestMember = memberService.getById(loginInfo.getMemberId());
SkillResponse skillResponse = recordService.saveSkill(requestMember, recordId, skillReqDto);
SkillResponse skillResponse = recordService.saveSkill(requestMember,
recordService.findByMemberId(loginInfo.getMemberId()).getId(), skillReqDto);
return ResponseEntity
.status(HttpStatus.OK)
.body(new BaseResponse<>(HttpStatus.OK.value(), "스킬 생성 완료", skillResponse));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@
import lombok.Data;
import lombok.Getter;
import umc.kkijuk.server.record.domain.File;
import umc.kkijuk.server.record.domain.FileType;

@Data
@Getter
@Builder
@AllArgsConstructor
public class FileResponse {
private Long memberId;
private Long fileId;
private FileType fileType;
private String fileTitle;
private String keyName;
private String urlTitle;
private String url;

public FileResponse(File file){
this.memberId = file.getMemberId();
this.fileId = file.getId();
this.fileType = file.getFileType();
this.fileTitle = file.getFileTitle();
this.keyName = file.getKeyName();
this.urlTitle = file.getUrlTitle();
this.url = file.getUrl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public class RecordResponse {
private List<EmploymentResponse> employments;
private List<BaseCareerResponse> projects;
private List<EduCareerResponse> eduCareers;
private List<AwardResponse> awards;
private List<LicenseResponse> licenses;
private List<SkillResponse> skills;
private List<FileResponse> files;
private String name;
private LocalDate birthday;
private String phone;
Expand Down Expand Up @@ -67,7 +71,9 @@ public class RecordResponse {
@Builder
public RecordResponse(Record record, Member member, List<EducationResponse> educationList,
List<EmploymentResponse> employments, List<BaseCareerResponse> activitiesAndExperiences,
List<BaseCareerResponse> projects, List<EduCareerResponse> eduCareers) {
List<BaseCareerResponse> projects, List<EduCareerResponse> eduCareers,
List<AwardResponse> awards, List<LicenseResponse> licenses,
List<SkillResponse> skills, List<FileResponse> files) {
this.record_id=record.getId();
this.address = record.getAddress();
this.profileImageUrl=record.getProfileImageUrl();
Expand All @@ -76,6 +82,10 @@ public RecordResponse(Record record, Member member, List<EducationResponse> educ
this.activitiesAndExperiences = activitiesAndExperiences;
this.projects = projects;
this.eduCareers = eduCareers;
this.awards = awards;
this.licenses = licenses;
this.skills = skills;
this.files = files;
this.name = member.getName();
this.birthday=member.getBirthDate();
this.phone=member.getPhoneNumber();
Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions src/main/java/umc/kkijuk/server/record/domain/Award.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public void changeAwardInfo(String competitionName, String administer, String aw
this.awardName = awardName;
this.acquireDate = acquireDate;
}

public Long getMemberId() {
return this.record.getMemberId();
}
}
15 changes: 15 additions & 0 deletions src/main/java/umc/kkijuk/server/record/domain/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,26 @@ public class File extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
private Long memberId;

@ManyToOne
@JoinColumn(name = "record_id", nullable = false)
private Record record;

private FileType fileType;

@Column(length = 20)
private String fileTitle;

private String keyName;

private String urlTitle;

private String url;

public Long getMemberId() {
return this.record.getMemberId();
}
}
7 changes: 7 additions & 0 deletions src/main/java/umc/kkijuk/server/record/domain/FileType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.kkijuk.server.record.domain;

public enum FileType {
File,

URL
}
4 changes: 4 additions & 0 deletions src/main/java/umc/kkijuk/server/record/domain/License.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ public void changeLicenseInfo(LicenseTag licenseTag, String licenseName, String
this.acquireDate = acquireDate;
}

public Long getMemberId() {
return this.record.getMemberId();
}

}
5 changes: 4 additions & 1 deletion src/main/java/umc/kkijuk/server/record/domain/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.kkijuk.server.common.domian.base.BaseEntity;
import umc.kkijuk.server.common.domian.exception.ResourceNotFoundException;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -30,13 +31,15 @@ public class Record extends BaseEntity {
@OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true)
private List<License> licenses = new ArrayList<>();


@OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Award> awards = new ArrayList<>();

@OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Skill> skills = new ArrayList<>();

@OneToMany(mappedBy = "record", cascade = CascadeType.ALL, orphanRemoval = true)
private List<File> files = new ArrayList<>();

@Builder
public Record(Long memberId, String address, String profileImageUrl, List<Education> educations) {
this.memberId = memberId;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/umc/kkijuk/server/record/domain/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public void changeSkillInfo(SkillTag skillTag, String skillName, Workmanship wor
this.skillName = skillName;
this.workmanship = workmanship;
}

public Long getMemberId() {
return this.record.getMemberId();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.record.domain.Award;

import java.util.List;


public interface AwardRepository extends JpaRepository<Award, Long> {
List<Award> findByRecordId(Long recordId);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package umc.kkijuk.server.record.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.record.domain.Award;
import umc.kkijuk.server.record.domain.File;

import java.util.List;
import java.util.Optional;

public interface FileRepository extends JpaRepository<File,Long> {
Optional<File> findByMemberIdAndFileTitle(Long memberId, String fileTitle);
boolean existsByMemberIdAndFileTitle(Long memberId, String fileTitle);
boolean existsByMemberIdAndUrlTitle(Long memberId, String urlTitle);
Optional<File> findByMemberIdAndUrlTitle(Long memberId, String urlTitle);
List<File> findByRecordId(Long recordId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package umc.kkijuk.server.record.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.record.domain.Award;
import umc.kkijuk.server.record.domain.License;

import java.util.List;

public interface LicenseRepository extends JpaRepository<License, Long> {
List<License> findByRecordId(Long recordId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package umc.kkijuk.server.record.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.kkijuk.server.record.domain.Award;
import umc.kkijuk.server.record.domain.Skill;

import java.util.List;

public interface SkillRepository extends JpaRepository<Skill, Long> {
List<Skill> findByRecordId(Long recordId);
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package umc.kkijuk.server.record.service;


import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.record.controller.response.FileResponse;
import umc.kkijuk.server.record.controller.response.UrlResponse;
import umc.kkijuk.server.record.dto.FileReqDto;
import umc.kkijuk.server.record.dto.UrlReqDto;

import java.util.Map;

public interface FileService {
Map<String, String> getSignUrl (Long memberId, String fileName);
FileResponse createFile(Long memberId, FileReqDto request);
FileResponse saveFile(Long memberId, Long recordId, FileReqDto request);
Map<String, String> getDownloadUrl(Long memberId, String keyName);
FileResponse deleteFile(Long memberId, String fileName);
UrlResponse saveUrl(Long memberId, UrlReqDto urlReqDto);
UrlResponse deleteUrl(Long memberId, UrlReqDto urlReqDto);
FileResponse saveUrl(Long memberId, Long recordId, UrlReqDto urlReqDto);
FileResponse deleteUrl(Long memberId, UrlReqDto urlReqDto);
}
Loading

0 comments on commit 271d450

Please sign in to comment.