Skip to content

Commit

Permalink
Refactor : 타임라인 API 응답 수정
Browse files Browse the repository at this point in the history
- 타임라인 관련 API 의 응답 부분을 수정했습니다.
- CareerEtc 엔티티를 추가했습니다.
- CareerEtc 생성, 수정, 삭제 API를 추가했습니다.
  • Loading branch information
hyeonda02 committed Dec 7, 2024
1 parent a771a28 commit ec0e315
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
import umc.kkijuk.server.member.domain.Member;
import umc.kkijuk.server.member.service.MemberService;

import java.util.List;


@Tag(name="basecareer",description = "활동 관련 API")
@Tag(name="Career",description = "활동 생성, 수정, 삭제 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/career")
Expand Down Expand Up @@ -191,29 +190,31 @@ public CareerResponse<ProjectResponse> updateProject(
baseCareerService.updateProject(requestMember, projectId, projectReqDto)
);
}
@GetMapping("")
@Operation(
summary = "활동 목록",
description = "활동을 조회합니다. query 값으로 category(카테고리 기준), year(연도 기준), 또는 all(전체 조회) 중 하나를 선택하여 요청해주세요." )
public CareerResponse<?> findAllCareersGroupedYear(
@PostMapping("/etc")
@Operation(summary = "커리어(기타) 생성", description = "주어진 정보를 바탕으로 활동을 추가합니다.")
public CareerResponse<EtcResponse> createEtc(
@Login LoginInfo loginInfo,
@RequestParam(name="status") String value
@Valid @RequestBody EtcReqDto etcReqDto
) {
Member requestMember = memberService.getById(loginInfo.getMemberId());
if(value.equals("category")){
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllCareerGroupedCategory(requestMember.getId())
);
}else if (value.equals("all")){
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllCareer(requestMember.getId())
);
}
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllCareerGroupedYear(requestMember.getId())
CareerResponseMessage.CAREER_CREATE_SUCCESS,
baseCareerService.createEtc(requestMember, etcReqDto)
);
}

@PatchMapping("/etc/{etcId}")
@Operation(summary = "커리어(기타) 수정", description = "활동 ID에 해당하는 활동을 수정합니다.")
@Parameter(name="etcId", description = "커리어(기타) Id, path variable 입니다.",example = "1")
public CareerResponse<EtcResponse> updateEtc(
@Login LoginInfo loginInfo,
@PathVariable Long etcId,
@Valid @RequestBody EtcReqDto etcReqDto
) {
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_UPDATE_SUCCESS,
baseCareerService.updateEtc(requestMember, etcId, etcReqDto)
);
}

Expand All @@ -233,20 +234,7 @@ public CareerResponse<Object> deleteBaseCareer(
);

}
@GetMapping("/{type}/{careerId}")
@Operation(summary = "활동 상세", description = "활동 ID에 해당하는 활동의 세부 내용과, 활동 기록을 조회합니다.")
@Parameter(name = "careerId", description = "활동 Id, path variable 입니다.", example = "1")
public CareerResponse<BaseCareerResponse> findCareer(
@Login LoginInfo loginInfo,
@PathVariable String type,
@PathVariable Long careerId
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findCareer(requestMember, careerId, type)
);
}

@PatchMapping("/{careerId}")
@Operation(summary = "활동 내역 수정", description = "활동 ID에 해당하는 활동에 활동 내역을 추가합니다.")
@Parameter(name = "careerId", description = "활동 Id, path variable 입니다.", example = "1")
Expand All @@ -262,83 +250,4 @@ public CareerResponse<BaseCareerResponse> createSummary(
);
}

@GetMapping("/find/detail")
@Operation(
summary = "활동 검색 - 활동 기록",
description = "활동기록을 주어진 조건에 맞추어 조회합니다. query 값으로 검색어(keyword)와 정렬 기준(new,old)을 요청해주세요. " )
public CareerResponse<List<FindDetailResponse>> findDetail(
@Login LoginInfo loginInfo,
@RequestParam(name="keyword")String keyword,
@RequestParam(name="sort") String sort
) {
Member reqeustMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllDetail(reqeustMember,keyword,sort)
);
}

@GetMapping("/find/taglist")
@Operation(
summary = "활동 검색 - 태그 ( 검색 태그 조회 )",
description = "검색어를 포함하는 활동 태그들을 가나다 순으로 조회합니다. " +
"query 값으로 검색어(keyword)를 요청해주세요. " )
public CareerResponse<List<FindTagResponse>> findTag(
@Login LoginInfo loginInfo,
@RequestParam(name="keyword")String keyword
) {
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_SEARCH_SUCCESS,
baseCareerService.findAllTag(requestMember, keyword)
);
}

@GetMapping("/find/tag")
@Operation(
summary = "활동 검색 - 태그 ( 선택한 태그에 대한 활동 기록 조회 )",
description = "선택한 태그를 포함하는 활동 기록들을 조회합니다. " +
" query 값으로 태그의 ID 와 정렬 기준(new,old)을 요청해주세요. " )
public CareerResponse<List<FindDetailResponse>> findTagAndDetail(
@Login LoginInfo loginInfo,
@RequestParam(name="tagId") Long tagId,
@RequestParam(name="sort") String sort
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllDetailByTag(requestMember, tagId, sort)
);
}
@GetMapping("/find")
@Operation(
summary = "활동 검색 - 활동",
description = "활동을 주어진 조건에 맞추어 조회합니다. query 값으로 검색어(keyword)와 정렬 기준(new,old)을 요청해주세요. " )
public CareerResponse<List<FindCareerResponse>> findCareerWithKeyword(
@Login LoginInfo loginInfo,
@RequestParam(name = "keyword") String keyword,
@RequestParam(name = "sort") String sort
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findCareerWithKeyword(requestMember, keyword, sort)
);

}
@GetMapping("/timeline")
@Operation(
summary = "활동 타임라인",
description = "타임라인에 필요한 활동 정보들을 조회합니다.")
public CareerResponse<List<TimelineResponse>> findCareerForTimeline(
@Login LoginInfo loginInfo
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findCareerForTimeline(requestMember)
);

}

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

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import umc.kkijuk.server.career.controller.response.*;
import umc.kkijuk.server.career.service.BaseCareerService;
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 java.util.List;

@Tag(name="Search Career", description = "활동 조회 및 검색 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/career")
public class CareerSearchController {
private final BaseCareerService baseCareerService;
private final MemberService memberService;
@GetMapping("")
@Operation(
summary = "활동 목록",
description = "활동을 조회합니다. query 값으로 category(카테고리 기준), year(연도 기준), 또는 all(전체 조회) 중 하나를 선택하여 요청해주세요." )
public CareerResponse<?> findAllCareersGroupedYear(
@Login LoginInfo loginInfo,
@RequestParam(name="status") String value
) {
Member requestMember = memberService.getById(loginInfo.getMemberId());
if(value.equals("category")){
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllCareerGroupedCategory(requestMember.getId())
);
}else if (value.equals("all")){
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllCareer(requestMember.getId())
);
}
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllCareerGroupedYear(requestMember.getId())
);
}
@GetMapping("/{type}/{careerId}")
@Operation(summary = "활동 상세", description = "활동 ID에 해당하는 활동의 세부 내용과, 활동 기록을 조회합니다.")
@Parameter(name = "careerId", description = "활동 Id, path variable 입니다.", example = "1")
public CareerResponse<BaseCareerResponse> findCareer(
@Login LoginInfo loginInfo,
@PathVariable String type,
@PathVariable Long careerId
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findCareer(requestMember, careerId, type)
);
}
@GetMapping("/find/detail")
@Operation(
summary = "활동 검색 - 활동 기록",
description = "활동기록을 주어진 조건에 맞추어 조회합니다. query 값으로 검색어(keyword)와 정렬 기준(new,old)을 요청해주세요. " )
public CareerResponse<List<FindDetailResponse>> findDetail(
@Login LoginInfo loginInfo,
@RequestParam(name="keyword")String keyword,
@RequestParam(name="sort") String sort
) {
Member reqeustMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllDetail(reqeustMember,keyword,sort)
);
}

@GetMapping("/find/taglist")
@Operation(
summary = "활동 검색 - 태그 ( 검색 태그 조회 )",
description = "검색어를 포함하는 활동 태그들을 가나다 순으로 조회합니다. " +
"query 값으로 검색어(keyword)를 요청해주세요. " )
public CareerResponse<List<FindTagResponse>> findTag(
@Login LoginInfo loginInfo,
@RequestParam(name="keyword")String keyword
) {
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_SEARCH_SUCCESS,
baseCareerService.findAllTag(requestMember, keyword)
);
}

@GetMapping("/find/tag")
@Operation(
summary = "활동 검색 - 태그 ( 선택한 태그에 대한 활동 기록 조회 )",
description = "선택한 태그를 포함하는 활동 기록들을 조회합니다. " +
" query 값으로 태그의 ID 와 정렬 기준(new,old)을 요청해주세요. " )
public CareerResponse<List<FindDetailResponse>> findTagAndDetail(
@Login LoginInfo loginInfo,
@RequestParam(name="tagId") Long tagId,
@RequestParam(name="sort") String sort
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findAllDetailByTag(requestMember, tagId, sort)
);
}
@GetMapping("/find")
@Operation(
summary = "활동 검색 - 활동",
description = "활동을 주어진 조건에 맞추어 조회합니다. query 값으로 검색어(keyword)와 정렬 기준(new,old)을 요청해주세요. " )
public CareerResponse<List<FindCareerResponse>> findCareerWithKeyword(
@Login LoginInfo loginInfo,
@RequestParam(name = "keyword") String keyword,
@RequestParam(name = "sort") String sort
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findCareerWithKeyword(requestMember, keyword, sort)
);

}
@GetMapping("/timeline")
@Operation(
summary = "활동 타임라인",
description = "타임라인에 필요한 활동 정보들을 조회합니다.")
public CareerResponse<List<TimelineResponse>> findCareerForTimeline(
@Login LoginInfo loginInfo
){
Member requestMember = memberService.getById(loginInfo.getMemberId());
return CareerResponse.success(
CareerResponseMessage.CAREER_FINDALL_SUCCESS,
baseCareerService.findCareerForTimeline(requestMember)
);

}

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

import lombok.*;

@Data
@Getter
@Setter
@Builder
@AllArgsConstructor
public class CategoryResponse {
private int categoryId;
private String categoryKoName;
private String categoryEnName;

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

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

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

@Data
@Getter
@Setter
@Builder
@AllArgsConstructor
public class EtcResponse implements BaseCareerResponse{
private Long id;
private String category;
private String name;
private String alias;
private Boolean unknown;
private String summary;
private LocalDate startdate;
private LocalDate enddate;
private List<BaseCareerDetailResponse> detailList;

public EtcResponse(CareerEtc etc) {
this.id = etc.getId();
this.category = CareerType.ETC.getDescription();
this.name = etc.getName();
this.alias = etc.getAlias();
this.unknown = etc.getUnknown();
this.summary = etc.getSummary();
this.startdate = etc.getStartdate();
this.enddate = etc.getEnddate();
}

public EtcResponse(CareerEtc etc, List<BaseCareerDetail> details) {
this(etc);
this.detailList = details.stream()
.map(BaseCareerDetailResponse::new)
.collect(Collectors.toList());
}

@Override
public LocalDate getEndDate() {
return null;
}
}
Loading

0 comments on commit ec0e315

Please sign in to comment.