Skip to content

Commit 0997170

Browse files
authored
[FIX] 프로필 관련 API 들 스웨거 설정 + Dto 타입 수정 (#161)
* [REFACT] 스웨거 태그 추가. * [REFACT] 응답 타입 수정 * [REFACT] 스웨거 태그 추가 + SwaggerPageable 추가 * [REFACT] 응답 타입 수정 * [REFACT] 마이페이지 기본에서 '내 아이디어 조회' 응답값에 식별자 추가. * [REFACT] 분야 응답 타입 수정. * [REFACT] 스웨거 태그 추가 * [REFACT] 마감기한 분까지만 받고록 수정 + 시작날짜/종료날짜 역직렬화
1 parent 3b9620d commit 0997170

13 files changed

+104
-46
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.brainpix.post.dto;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
6+
@Getter
7+
@AllArgsConstructor
8+
public class MyDefaultPageIdeaListDto {
9+
private Long id;
10+
private String title;
11+
}

src/main/java/com/brainpix/profile/controller/MyPageController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88

99
import com.brainpix.api.ApiResponse;
1010
import com.brainpix.api.CommonPageResponse;
11+
import com.brainpix.api.swagger.SwaggerPageable;
12+
import com.brainpix.post.dto.MyDefaultPageIdeaListDto;
1113
import com.brainpix.profile.dto.MyPageResponseDto;
1214
import com.brainpix.profile.service.MyPageService;
1315
import com.brainpix.security.authorization.AllUser;
1416
import com.brainpix.security.authorization.UserId;
1517

1618
import io.swagger.v3.oas.annotations.Operation;
19+
import io.swagger.v3.oas.annotations.tags.Tag;
1720
import lombok.RequiredArgsConstructor;
1821

1922
@RestController
2023
@RequestMapping("/my-page")
24+
@Tag(name = "마이페이지 기본 화면 조회", description = "마이페이지 기본 화면 조회 관련 API")
2125
@RequiredArgsConstructor
2226
public class MyPageController {
2327

@@ -33,8 +37,9 @@ public ResponseEntity<ApiResponse<MyPageResponseDto>> getMyPage(@UserId Long use
3337

3438
@AllUser
3539
@Operation(summary = "'내 아이디어' 조회", description = "특정 사용자가 작성한 아이디어 목록을 페이징 처리하여 조회합니다")
40+
@SwaggerPageable
3641
@GetMapping("/ideas")
37-
public ResponseEntity<ApiResponse<CommonPageResponse<String>>> getMyIdeas(
42+
public ResponseEntity<ApiResponse<CommonPageResponse<MyDefaultPageIdeaListDto>>> getMyIdeas(
3843
@UserId Long userId,
3944
Pageable pageable) {
4045
return ResponseEntity.ok(

src/main/java/com/brainpix/profile/controller/ProfileController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import com.brainpix.security.authorization.UserId;
1919

2020
import io.swagger.v3.oas.annotations.Operation;
21+
import io.swagger.v3.oas.annotations.tags.Tag;
2122
import lombok.RequiredArgsConstructor;
2223

2324
@RestController
2425
@RequestMapping("/profile")
26+
@Tag(name = "본인 프로필 조회/수정 API", description = "개인/기업 본인시 소유한 계정의 프로필을 조회 및 수정 API 입니다.")
2527
@RequiredArgsConstructor
2628
public class ProfileController {
2729

src/main/java/com/brainpix/profile/controller/PublicProfileController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import com.brainpix.api.ApiResponse;
1212
import com.brainpix.api.CommonPageResponse;
13+
import com.brainpix.api.swagger.SwaggerPageable;
1314
import com.brainpix.profile.dto.CompanyProfileResponseDto;
1415
import com.brainpix.profile.dto.IndividualProfileResponseDto;
1516
import com.brainpix.profile.dto.PublicProfileResponseDto;
@@ -18,10 +19,12 @@
1819
import com.brainpix.security.authorization.UserId;
1920

2021
import io.swagger.v3.oas.annotations.Operation;
22+
import io.swagger.v3.oas.annotations.tags.Tag;
2123
import lombok.RequiredArgsConstructor;
2224

2325
@RestController
2426
@RequestMapping("/public-profile") // 기존 마이페이지 조회 API와 구별
27+
@Tag(name = "상대방 프로필 조회 API", description = "상대방 계정의 프로필을 조회 API 입니다.")
2528
@RequiredArgsConstructor
2629
public class PublicProfileController {
2730

@@ -53,6 +56,7 @@ public ResponseEntity<ApiResponse<CompanyProfileResponseDto>> getPublicCompanyPr
5356
@AllUser
5457
@Operation(summary = "사용자 게시글 조회", description = "특정 사용자가 작성한 공개 게시글을 조회합니다.")
5558
@GetMapping
59+
@SwaggerPageable
5660
public ResponseEntity<ApiResponse<CommonPageResponse<PublicProfileResponseDto.PostPreviewDto>>> getPostsByUser(
5761
@UserId Long userId,
5862
@PageableDefault(sort = "createdDate", direction = Sort.Direction.DESC) Pageable pageable) {

src/main/java/com/brainpix/profile/converter/MyProfileConverter.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,26 @@ public IndividualProfileResponseDto toDto(User user) {
2020
return IndividualProfileResponseDto.builder()
2121
.userType("개인")
2222
.specializations(profile.getSpecializationList().stream()
23-
.map(Enum::name)
24-
.collect(Collectors.joining("/"))) // 전문 분야를 '/'로 구분
23+
.toList())
2524
.name(user.getName())
2625
.selfIntroduction(profile.getSelfIntroduction())
2726
.contacts(profile.getContacts().stream()
2827
.map(contact -> IndividualProfileResponseDto.ContactDto.builder()
29-
.type(contact.getType().name())
28+
.type(contact.getType())
3029
.value(contact.getValue())
3130
.build())
3231
.collect(Collectors.toList()))
3332
.stacks(profile.getStacks().stream()
3433
.map(stack -> IndividualProfileResponseDto.StackDto.builder()
3534
.stackName(stack.getStackName())
36-
.proficiency(stack.getStackProficiency().name())
35+
.proficiency(stack.getStackProficiency())
3736
.build())
3837
.collect(Collectors.toList()))
3938
.careers(profile.getCareers().stream()
4039
.map(career -> IndividualProfileResponseDto.CareerDto.builder()
4140
.content(career.getCareerContent())
42-
.startDate(career.getStartDate().toString())
43-
.endDate(career.getEndDate().toString())
41+
.startDate(career.getStartDate())
42+
.endDate(career.getEndDate())
4443
.build())
4544
.collect(Collectors.toList()))
4645
.build();
@@ -52,14 +51,13 @@ public CompanyProfileResponseDto toCompanyDto(Company user) {
5251
return CompanyProfileResponseDto.builder()
5352
.userType("기업")
5453
.specializations(profile.getSpecializationList().stream()
55-
.map(Enum::name)
56-
.collect(Collectors.joining("/"))) // 기업 분야를 '/'로 구분
54+
.toList())
5755
.name(user.getName())
5856
.selfIntroduction(profile.getSelfIntroduction())
5957
.businessInformation(profile.getBusinessInformation())
6058
.companyInformations(profile.getCompanyInformations().stream()
6159
.map(info -> CompanyProfileResponseDto.CompanyInformationDto.builder()
62-
.type(info.getCompanyInformationType().name())
60+
.type(info.getCompanyInformationType())
6361
.value(info.getValue())
6462
.build())
6563
.collect(Collectors.toList()))

src/main/java/com/brainpix/profile/converter/ProfileConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.brainpix.profile.converter;
22

3-
import java.time.YearMonth;
43
import java.util.List;
54
import java.util.stream.Collectors;
65

@@ -26,7 +25,7 @@ public Stack toStack(IndividualProfileUpdateDto.StackDto dto, IndividualProfile
2625
}
2726

2827
public Career toCareer(IndividualProfileUpdateDto.CareerDto dto, IndividualProfile profile) {
29-
return new Career(dto.getContent(), YearMonth.parse(dto.getStartDate()), YearMonth.parse(dto.getEndDate()),
28+
return new Career(dto.getContent(), dto.getStartDate(), dto.getEndDate(),
3029
profile);
3130
}
3231

src/main/java/com/brainpix/profile/converter/ProfilePostConverter.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,17 @@ public class ProfilePostConverter {
1717
*/
1818
public PublicProfileResponseDto.PostPreviewDto toRequestTaskPreviewDto(RequestTask task, long savedCount) {
1919
String openScope = parseOpenScope(task.getPostAuth());
20-
String dDayString = task.getDeadline().toString();
2120
String writerName = getDisplayName(task.getWriter());
2221

2322
return PublicProfileResponseDto.PostPreviewDto.builder()
2423
.postId(task.getId())
2524
.openScope(openScope)
26-
.categoryName("요청 과제 > " + task.getSpecialization())
25+
.specialization(task.getSpecialization())
2726
.title(task.getTitle())
2827
.writerName(writerName)
2928
.savedCount(savedCount)
3029
.viewCount(task.getViewCount())
31-
.deadline(dDayString)
30+
.deadline(task.getDeadline())
3231
.thumbnailImage(task.getFirstImage())
3332
.writerImageUrl(task.getWriter().getProfileImage())
3433
.build();
@@ -44,7 +43,7 @@ public PublicProfileResponseDto.PostPreviewDto toIdeaMarketPreviewDto(IdeaMarket
4443
return PublicProfileResponseDto.PostPreviewDto.builder()
4544
.postId(market.getId())
4645
.openScope(openScope)
47-
.categoryName("아이디어 마켓 > " + market.getSpecialization())
46+
.specialization(market.getSpecialization())
4847
.title(market.getTitle())
4948
.writerName(writerName)
5049
.savedCount(savedCount)
@@ -65,19 +64,18 @@ public PublicProfileResponseDto.PostPreviewDto toCollaborationHubPreviewDto(Coll
6564
long totalMembers = hub.getCollaborations().stream()
6665
.mapToLong(rec -> rec.getGathering().getTotalQuantity())
6766
.sum();
68-
String dDayString = hub.getDeadline().toString();
6967
String openScope = parseOpenScope(hub.getPostAuth());
7068
String writerName = getDisplayName(hub.getWriter());
7169

7270
return PublicProfileResponseDto.PostPreviewDto.builder()
7371
.postId(hub.getId())
7472
.openScope(openScope)
75-
.categoryName("협업 광장 > " + hub.getSpecialization())
73+
.specialization(hub.getSpecialization())
7674
.title(hub.getTitle())
7775
.writerName(writerName)
7876
.savedCount(savedCount)
7977
.viewCount(hub.getViewCount())
80-
.deadline(dDayString)
78+
.deadline(hub.getDeadline())
8179
.thumbnailImage(hub.getFirstImage())
8280
.currentMembers(currentMembers)
8381
.totalMembers(totalMembers)

src/main/java/com/brainpix/profile/dto/CompanyProfileResponseDto.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
import java.util.List;
44

5+
import com.brainpix.profile.entity.CompanyInformationType;
6+
import com.brainpix.profile.entity.Specialization;
7+
58
import lombok.Builder;
69
import lombok.Getter;
710

811
@Getter
912
@Builder
1013
public class CompanyProfileResponseDto {
1114
private String userType; // 개인/기업
12-
private String specializations; // 기업 분야 (e.g., "IT/디자인")
15+
private List<Specialization> specializations;
1316
private String name; // 기업 이름
1417
private String selfIntroduction; // 기업 소개
1518
private String businessInformation; // 사업 정보
@@ -19,7 +22,7 @@ public class CompanyProfileResponseDto {
1922
@Getter
2023
@Builder
2124
public static class CompanyInformationDto {
22-
private String type; // 기업 정보 타입
25+
private CompanyInformationType type; // 기업 정보 타입
2326
private String value; // 기업 정보 값
2427
}
2528

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,62 @@
11
package com.brainpix.profile.dto;
22

3+
import java.time.YearMonth;
34
import java.util.List;
45

6+
import org.springframework.format.annotation.DateTimeFormat;
7+
8+
import com.brainpix.profile.entity.ContactType;
9+
import com.brainpix.profile.entity.Specialization;
10+
import com.brainpix.profile.entity.StackProficiency;
11+
import com.fasterxml.jackson.annotation.JsonFormat;
12+
13+
import io.swagger.v3.oas.annotations.media.Schema;
514
import lombok.Builder;
615
import lombok.Getter;
716

817
@Getter
918
@Builder
1019
public class IndividualProfileResponseDto {
1120
private String userType; // 개인/기업
12-
private String specializations; // 전문 분야 (e.g., "IT/디자인")
21+
private List<Specialization> specializations; // 전문 분야 (e.g., "IT/디자인")
1322
private String name; // 사용자 이름
1423
private String selfIntroduction; // 자기소개
1524

16-
private List<ContactDto> contacts; // 개별 정보
17-
private List<StackDto> stacks; // 보유 기술
18-
private List<CareerDto> careers; // 경력 사항
25+
@Builder.Default
26+
private List<ContactDto> contacts = List.of(); // 기본값 빈 리스트
27+
28+
@Builder.Default
29+
private List<StackDto> stacks = List.of();
30+
31+
@Builder.Default
32+
private List<CareerDto> careers = List.of();
1933

2034
@Getter
2135
@Builder
2236
public static class ContactDto {
23-
private String type; // 연락처 유형
37+
private ContactType type; // 연락처 유형
2438
private String value; // 연락처 값
2539
}
2640

2741
@Getter
2842
@Builder
2943
public static class StackDto {
3044
private String stackName; // 스택 이름
31-
private String proficiency; // 숙련도 (상/중/하)
45+
private StackProficiency proficiency; // 숙련도 (상/중/하)
3246
}
3347

3448
@Getter
3549
@Builder
3650
public static class CareerDto {
3751
private String content; // 경력 내용
38-
private String startDate; // 시작 날짜
39-
private String endDate; // 종료 날짜
52+
@Schema(type = "string", example = "yyyy-MM")
53+
@DateTimeFormat(pattern = "yyyy-MM")
54+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM")
55+
private YearMonth startDate; // 시작 날짜
56+
@Schema(type = "string", example = "yyyy-MM")
57+
@DateTimeFormat(pattern = "yyyy-MM")
58+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM")
59+
private YearMonth endDate; // 종료 날짜
4060
}
4161

4262
}

src/main/java/com/brainpix/profile/dto/IndividualProfileUpdateDto.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package com.brainpix.profile.dto;
22

3+
import java.time.YearMonth;
34
import java.util.List;
45

6+
import org.springframework.format.annotation.DateTimeFormat;
7+
58
import com.brainpix.profile.entity.ContactType;
69
import com.brainpix.profile.entity.Specialization;
710
import com.brainpix.profile.entity.StackProficiency;
11+
import com.fasterxml.jackson.annotation.JsonFormat;
812

13+
import io.swagger.v3.oas.annotations.media.Schema;
914
import lombok.Getter;
1015

1116
@Getter
@@ -40,7 +45,13 @@ public static class StackDto {
4045
@Getter
4146
public static class CareerDto {
4247
private String content; // 경력 내용
43-
private String startDate; // 시작 날짜 (YYYY-MM)
44-
private String endDate; // 종료 날짜 (YYYY-MM)
48+
@Schema(type = "string", example = "yyyy-MM")
49+
@DateTimeFormat(pattern = "yyyy-MM")
50+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM")
51+
private YearMonth startDate; // 시작 날짜 (YYYY-MM)
52+
@Schema(type = "string", example = "yyyy-MM")
53+
@DateTimeFormat(pattern = "yyyy-MM")
54+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM")
55+
private YearMonth endDate; // 종료 날짜 (YYYY-MM)
4556
}
4657
}

0 commit comments

Comments
 (0)