Skip to content

Commit

Permalink
Refactor : CareerDetail 연관관계 및 서비스 로직 수정
Browse files Browse the repository at this point in the history
- Career 엔티티들과 CareerDetail 간의 연관관계를 수정하였습니다.
- 연관관계 변경에 따른 관련 서비스 코드를 수정하였습니다.
- 활동 검색 기능에서 category 응답 방식을 개선하였습니다.
  • Loading branch information
hyeonda02 committed Dec 9, 2024
1 parent 6d6c8c0 commit 32de963
Show file tree
Hide file tree
Showing 18 changed files with 326 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public EtcResponse(CareerEtc etc, List<BaseCareerDetail> details) {

@Override
public LocalDate getEndDate() {
return null;
return enddate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import lombok.*;
import umc.kkijuk.server.career.domain.BaseCareer;
import umc.kkijuk.server.detail.controller.response.BaseCareerDetailResponse;
import umc.kkijuk.server.detail.domain.CareerType;

import java.time.LocalDate;
import java.util.List;

@Data
@Getter
Expand All @@ -12,19 +15,21 @@
@AllArgsConstructor
public class FindCareerResponse {
private Long careerId;
private String careerType;
private String careerTitle;
private String careerAlias;
private LocalDate startdate;
private LocalDate enddate;
private CategoryResponse category;

public FindCareerResponse(BaseCareer career, String careerType){
this.careerId = career.getId();
this.careerType = careerType;
this.careerTitle = career.getName();
this.careerAlias = career.getAlias();
this.startdate = career.getStartdate();
this.enddate = career.getEnddate();

public FindCareerResponse(Long careerId, String careerTitle, String careerAlias,
LocalDate startdate, LocalDate enddate, CareerType type){
this.careerId = careerId;
this.careerTitle = careerTitle;
this.careerAlias = careerAlias;
this.startdate = startdate;
this.enddate = enddate;
this.category = new CategoryResponse(type.getId(),type.getDescription(),type.name());
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package umc.kkijuk.server.career.controller.response;

import lombok.*;
import umc.kkijuk.server.career.domain.BaseCareer;
import umc.kkijuk.server.detail.controller.response.BaseCareerDetailResponse;
import umc.kkijuk.server.detail.domain.CareerType;


import java.time.LocalDate;
Expand All @@ -14,16 +16,26 @@
@AllArgsConstructor
public class FindDetailResponse implements BaseCareerResponse {
private Long careerId;
private String careerType;
private CategoryResponse category;
private String careerTitle;
private String careerAlias;
private LocalDate startdate;
private LocalDate enddate;
private List<BaseCareerDetailResponse> detailList;


@Override
public LocalDate getEndDate() {
return this.enddate;
}

public FindDetailResponse(Long careerId, String careerTitle, String careerAlias, LocalDate startdate, LocalDate enddate,
List<BaseCareerDetailResponse> detailList, CareerType type){
this.careerId = careerId;
this.careerTitle = careerTitle;
this.careerAlias = careerAlias;
this.startdate = startdate;
this.enddate = enddate;
this.detailList = detailList;
this.category = new CategoryResponse(type.getId(),type.getDescription(),type.name());
}
}
16 changes: 11 additions & 5 deletions src/main/java/umc/kkijuk/server/career/domain/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Activity extends BaseCareer {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String organizer;
private String role;
private int teamSize;
private int contribution;
private Boolean isTeam;

@OneToMany(mappedBy = "activity", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "activity", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();
// @Convert(converter = LongListConverter.class)
// private List<Long> details = new ArrayList<>();

@Override
public Long getId() {
return id;
Expand All @@ -32,19 +36,21 @@ public Long getId() {
public void setSummary(String summary) {
super.setSummary(summary);
}

@Builder
public Activity(Long memberId, String name, String alias, Boolean unknown,
LocalDate startdate, LocalDate enddate, String organizer,
String role, int teamSize, int contribution,
Boolean isTeam) {
super(memberId, name, alias, unknown,startdate, enddate);
super(memberId, name, alias, unknown, startdate, enddate);
this.organizer = organizer;
this.role = role;
this.teamSize = teamSize;
this.contribution = contribution;
this.isTeam = isTeam;
}
public void updateActivity(String name, String alias, Boolean unknown,LocalDate startdate,

public void updateActivity(String name, String alias, Boolean unknown, LocalDate startdate,
LocalDate enddate, String organizer, String role, int teamSize,
int contribution, Boolean isTeam) {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/umc/kkijuk/server/career/domain/CareerEtc.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public class CareerEtc extends BaseCareer{
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy = "etc", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "etc", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();

@Override
public Long getId() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/umc/kkijuk/server/career/domain/Circle.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class Circle extends BaseCareer{
private Boolean location;
private String role;

@OneToMany(mappedBy = "circle", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "circle", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();
@Override
public Long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class Competition extends BaseCareer{
private int contribution;
private Boolean isTeam;

@OneToMany(mappedBy = "competition", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "competition", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();
@Override
public Long getId() {
return id;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/umc/kkijuk/server/career/domain/EduCareer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class EduCareer extends BaseCareer {
private String organizer;
private int time;

@OneToMany(mappedBy = "eduCareer", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "eduCareer", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();
@Override
public Long getId() {
return id;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/umc/kkijuk/server/career/domain/Employment.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class Employment extends BaseCareer{
private String position;
private String field;

@OneToMany(mappedBy = "employment", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "employment", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();
@Override
public Long getId() {
return id;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/umc/kkijuk/server/career/domain/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class Project extends BaseCareer{
@Enumerated(EnumType.STRING)
private ProjectType location;

@OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
private List<BaseCareerDetail> detailList = new ArrayList<>();
// @OneToMany(mappedBy = "project", cascade = CascadeType.ALL)
// private List<BaseCareerDetail> detailList = new ArrayList<>();
@Override
public Long getId() {
return id;
Expand Down
Loading

0 comments on commit 32de963

Please sign in to comment.