diff --git a/src/main/java/com/brainpix/profile/controller/ProfileController.java b/src/main/java/com/brainpix/profile/controller/ProfileController.java index 888cb7f6..f7f70840 100644 --- a/src/main/java/com/brainpix/profile/controller/ProfileController.java +++ b/src/main/java/com/brainpix/profile/controller/ProfileController.java @@ -33,7 +33,7 @@ public class ProfileController { @Individual @GetMapping("/individual") public ResponseEntity> getIndividualProfile(@UserId Long userId) { - IndividualProfileResponseDto profile = profileService.getMyProfile(userId); + IndividualProfileResponseDto profile = profileService.getIndividualProfile(userId); return ResponseEntity.ok(ApiResponse.success(profile)); } diff --git a/src/main/java/com/brainpix/profile/converter/MyProfileConverter.java b/src/main/java/com/brainpix/profile/converter/MyProfileConverter.java index 470c46b3..8cdeeb0c 100644 --- a/src/main/java/com/brainpix/profile/converter/MyProfileConverter.java +++ b/src/main/java/com/brainpix/profile/converter/MyProfileConverter.java @@ -6,7 +6,9 @@ import com.brainpix.profile.dto.CompanyProfileResponseDto; import com.brainpix.profile.dto.IndividualProfileResponseDto; +import com.brainpix.profile.entity.CompanyInformation; import com.brainpix.profile.entity.CompanyProfile; +import com.brainpix.profile.entity.Contact; import com.brainpix.profile.entity.IndividualProfile; import com.brainpix.user.entity.Company; import com.brainpix.user.entity.User; @@ -26,11 +28,12 @@ public IndividualProfileResponseDto toDto(User user) { .name(user.getName()) .selfIntroduction(profile.getSelfIntroduction()) .contacts(profile.getContacts().stream() + .filter(Contact::getIsPublic) .map(contact -> IndividualProfileResponseDto.ContactDto.builder() .type(contact.getType()) .value(contact.getValue()) .build()) - .collect(Collectors.toList())) + .toList()) .stacks(profile.getStacks().stream() .map(stack -> IndividualProfileResponseDto.StackDto.builder() .stackName(stack.getStackName()) @@ -60,9 +63,11 @@ public CompanyProfileResponseDto toCompanyDto(Company user) { .selfIntroduction(profile.getSelfIntroduction()) .businessInformation(profile.getBusinessInformation()) .companyInformations(profile.getCompanyInformations().stream() + .filter(CompanyInformation::getIsPublic) .map(info -> CompanyProfileResponseDto.CompanyInformationDto.builder() .type(info.getCompanyInformationType()) .value(info.getValue()) + .isPublic(info.getIsPublic()) .build()) .collect(Collectors.toList())) .build(); diff --git a/src/main/java/com/brainpix/profile/converter/ProfileConverter.java b/src/main/java/com/brainpix/profile/converter/ProfileConverter.java index 6a9d4f5f..d77316a0 100644 --- a/src/main/java/com/brainpix/profile/converter/ProfileConverter.java +++ b/src/main/java/com/brainpix/profile/converter/ProfileConverter.java @@ -17,7 +17,7 @@ @Component public class ProfileConverter { public Contact toContact(IndividualProfileUpdateDto.ContactDto dto, IndividualProfile profile) { - return new Contact(dto.getType(), dto.getValue(), profile); + return new Contact(dto.getType(), dto.getValue(), profile, dto.getIsPublic()); } public Stack toStack(IndividualProfileUpdateDto.StackDto dto, IndividualProfile profile) { @@ -43,7 +43,7 @@ public List toCareerList(List dtoL public CompanyInformation toCompanyInformation(CompanyProfileUpdateDto.CompanyInformationDto dto, CompanyProfile profile) { - return new CompanyInformation(dto.getType(), dto.getValue(), profile); + return new CompanyInformation(dto.getType(), dto.getValue(), profile, dto.getIsPublic()); } public List toCompanyInformationList( diff --git a/src/main/java/com/brainpix/profile/dto/CompanyProfileResponseDto.java b/src/main/java/com/brainpix/profile/dto/CompanyProfileResponseDto.java index ac0e3192..43d575c0 100644 --- a/src/main/java/com/brainpix/profile/dto/CompanyProfileResponseDto.java +++ b/src/main/java/com/brainpix/profile/dto/CompanyProfileResponseDto.java @@ -26,6 +26,7 @@ public class CompanyProfileResponseDto { public static class CompanyInformationDto { private CompanyInformationType type; // 기업 정보 타입 private String value; // 기업 정보 값 + private Boolean isPublic; } } diff --git a/src/main/java/com/brainpix/profile/dto/CompanyProfileUpdateDto.java b/src/main/java/com/brainpix/profile/dto/CompanyProfileUpdateDto.java index 8f311af1..d57f7d73 100644 --- a/src/main/java/com/brainpix/profile/dto/CompanyProfileUpdateDto.java +++ b/src/main/java/com/brainpix/profile/dto/CompanyProfileUpdateDto.java @@ -15,7 +15,6 @@ public class CompanyProfileUpdateDto { private String businessInformation; // 사업 정보 private List companyInformations; // 기업 정보 - private Boolean openInformation; // 기업 정보 공개 여부 private List specializations; // 기업 분야 (최대 2개) @@ -23,5 +22,6 @@ public class CompanyProfileUpdateDto { public static class CompanyInformationDto { private CompanyInformationType type; // 기업 정보 타입 private String value; // 기업 정보 값 + private Boolean isPublic; // 공개 여부 추가 } } \ No newline at end of file diff --git a/src/main/java/com/brainpix/profile/dto/IndividualProfileResponseDto.java b/src/main/java/com/brainpix/profile/dto/IndividualProfileResponseDto.java index df774794..5c8c15df 100644 --- a/src/main/java/com/brainpix/profile/dto/IndividualProfileResponseDto.java +++ b/src/main/java/com/brainpix/profile/dto/IndividualProfileResponseDto.java @@ -38,6 +38,7 @@ public class IndividualProfileResponseDto { public static class ContactDto { private ContactType type; // 연락처 유형 private String value; // 연락처 값 + private Boolean isPublic; } @Getter diff --git a/src/main/java/com/brainpix/profile/dto/IndividualProfileUpdateDto.java b/src/main/java/com/brainpix/profile/dto/IndividualProfileUpdateDto.java index 5287f688..f5bdab37 100644 --- a/src/main/java/com/brainpix/profile/dto/IndividualProfileUpdateDto.java +++ b/src/main/java/com/brainpix/profile/dto/IndividualProfileUpdateDto.java @@ -20,7 +20,6 @@ public class IndividualProfileUpdateDto { private String selfIntroduction; // 자기소개 private List contacts; // 개별 정보 - private Boolean contactOpen; // 개별 정보 공개여부 private List stacks; // 보유 기술 private Boolean stackOpen; // 보유 기술 공개여부 @@ -34,6 +33,7 @@ public class IndividualProfileUpdateDto { public static class ContactDto { private ContactType type; // 연락처 타입 private String value; // 연락처 내용 + private Boolean isPublic; } @Getter diff --git a/src/main/java/com/brainpix/profile/entity/CompanyInformation.java b/src/main/java/com/brainpix/profile/entity/CompanyInformation.java index aab7e2fa..2fedc466 100644 --- a/src/main/java/com/brainpix/profile/entity/CompanyInformation.java +++ b/src/main/java/com/brainpix/profile/entity/CompanyInformation.java @@ -26,12 +26,14 @@ public class CompanyInformation { @ManyToOne private CompanyProfile companyProfile; + private Boolean isPublic; @Builder public CompanyInformation(CompanyInformationType companyInformationType, String value, - CompanyProfile companyProfile) { + CompanyProfile companyProfile, Boolean isPublic) { this.companyInformationType = companyInformationType; this.value = value; this.companyProfile = companyProfile; + this.isPublic = isPublic != null ? isPublic : true; } } diff --git a/src/main/java/com/brainpix/profile/entity/CompanyProfile.java b/src/main/java/com/brainpix/profile/entity/CompanyProfile.java index 19b19dbd..1d5d1b7f 100644 --- a/src/main/java/com/brainpix/profile/entity/CompanyProfile.java +++ b/src/main/java/com/brainpix/profile/entity/CompanyProfile.java @@ -39,10 +39,9 @@ public CompanyProfile(User user, List specializationList, String this.companyInformations = companyInformations != null ? companyInformations : new ArrayList<>(); } - public void update(String selfIntroduction, String businessInformation, Boolean openInformation) { + public void update(String selfIntroduction, String businessInformation) { this.selfIntroduction = selfIntroduction; this.businessInformation = businessInformation; - this.openInformation = openInformation; } public void updateSpecializations(List specializations) { diff --git a/src/main/java/com/brainpix/profile/entity/Contact.java b/src/main/java/com/brainpix/profile/entity/Contact.java index 0c737921..57fcad45 100644 --- a/src/main/java/com/brainpix/profile/entity/Contact.java +++ b/src/main/java/com/brainpix/profile/entity/Contact.java @@ -29,10 +29,12 @@ public class Contact extends BaseTimeEntity { @ManyToOne(fetch = FetchType.LAZY) private IndividualProfile individualProfile; + private Boolean isPublic; - public Contact(ContactType type, String value, IndividualProfile individualProfile) { + public Contact(ContactType type, String value, IndividualProfile individualProfile, Boolean isPublic) { this.type = type; this.value = value; this.individualProfile = individualProfile; + this.isPublic = isPublic; } } diff --git a/src/main/java/com/brainpix/profile/entity/IndividualProfile.java b/src/main/java/com/brainpix/profile/entity/IndividualProfile.java index b7ac7da5..2ffd39ea 100644 --- a/src/main/java/com/brainpix/profile/entity/IndividualProfile.java +++ b/src/main/java/com/brainpix/profile/entity/IndividualProfile.java @@ -19,7 +19,6 @@ @Getter public class IndividualProfile extends Profile { private String selfIntroduction; - private Boolean ContactOpen; private Boolean CareerOpen; private Boolean stackOpen; @@ -34,17 +33,15 @@ public class IndividualProfile extends Profile { @Builder public IndividualProfile(User user, List specializationList, String selfIntroduction, - Boolean contactOpen, Boolean careerOpen, Boolean stackOpen) { + Boolean careerOpen, Boolean stackOpen) { super(user, specializationList); this.selfIntroduction = selfIntroduction; - this.ContactOpen = contactOpen; this.CareerOpen = careerOpen; this.stackOpen = stackOpen; } - public void update(String selfIntroduction, Boolean contactOpen, Boolean careerOpen, Boolean stackOpen) { + public void update(String selfIntroduction, Boolean careerOpen, Boolean stackOpen) { this.selfIntroduction = selfIntroduction; - this.ContactOpen = contactOpen; this.CareerOpen = careerOpen; this.stackOpen = stackOpen; } diff --git a/src/main/java/com/brainpix/profile/service/ProfileService.java b/src/main/java/com/brainpix/profile/service/ProfileService.java index 23923695..226d1842 100644 --- a/src/main/java/com/brainpix/profile/service/ProfileService.java +++ b/src/main/java/com/brainpix/profile/service/ProfileService.java @@ -68,15 +68,16 @@ public void updateIndividualProfile(Long userId, IndividualProfileUpdateDto upda } // 자기소개와 공개 여부 업데이트 - profile.update(updateDto.getSelfIntroduction(), updateDto.getContactOpen(), - updateDto.getCareerOpen(), updateDto.getStackOpen()); + profile.update(updateDto.getSelfIntroduction(), updateDto.getCareerOpen(), updateDto.getStackOpen()); // 전문 분야 업데이트 profile.updateSpecializations(updateDto.getSpecializations()); // 연락처(Contact) 업데이트 contactRepository.deleteByIndividualProfile(profile); - List contacts = converter.toContactList(updateDto.getContacts(), profile); + List contacts = updateDto.getContacts().stream() + .map(dto -> new Contact(dto.getType(), dto.getValue(), profile, dto.getIsPublic())) + .toList(); contactRepository.saveAll(contacts); // 보유 기술(Stack) 업데이트 @@ -108,8 +109,7 @@ public void updateCompanyProfile(Long userId, CompanyProfileUpdateDto updateDto) } // 기업 소개, 사업 정보 및 공개 여부 업데이트 - profile.update(updateDto.getSelfIntroduction(), updateDto.getBusinessInformation(), - updateDto.getOpenInformation()); + profile.update(updateDto.getSelfIntroduction(), updateDto.getBusinessInformation()); // 기업 분야 업데이트 profile.updateSpecializations(updateDto.getSpecializations()); @@ -122,7 +122,7 @@ public void updateCompanyProfile(Long userId, CompanyProfileUpdateDto updateDto) } @Transactional(readOnly = true) - public IndividualProfileResponseDto getMyProfile(Long userId) { + public IndividualProfileResponseDto getIndividualProfile(Long userId) { User user = userRepository.findById(userId) .orElseThrow(() -> new BrainPixException(ProfileErrorCode.USER_NOT_FOUND)); return myconverter.toDto(user); diff --git a/src/main/java/com/brainpix/profile/service/PublicProfileService.java b/src/main/java/com/brainpix/profile/service/PublicProfileService.java index 73c0e98f..37e4b38e 100644 --- a/src/main/java/com/brainpix/profile/service/PublicProfileService.java +++ b/src/main/java/com/brainpix/profile/service/PublicProfileService.java @@ -65,8 +65,10 @@ public IndividualProfileResponseDto getPublicIndividualProfile(Long userId) { .userType(profileDto.getUserType()) .specializations(profileDto.getSpecializations()) .name(profileDto.getName()) - .selfIntroduction(profile.getCareerOpen() ? profileDto.getSelfIntroduction() : "") - .contacts(profile.getContactOpen() ? profileDto.getContacts() : Collections.emptyList()) + .selfIntroduction(profileDto.getSelfIntroduction()) + .contacts(profileDto.getContacts().stream() + .filter(IndividualProfileResponseDto.ContactDto::getIsPublic) + .toList()) .stacks(profile.getStackOpen() ? profileDto.getStacks() : Collections.emptyList()) .careers(profile.getCareerOpen() ? profileDto.getCareers() : Collections.emptyList()) .build(); @@ -92,8 +94,8 @@ public CompanyProfileResponseDto getPublicCompanyProfile(Long userId) { .userType(profileDto.getUserType()) .specializations(profileDto.getSpecializations()) .name(profileDto.getName()) - .selfIntroduction(profile.getOpenInformation() ? profileDto.getSelfIntroduction() : "") - .businessInformation(profile.getOpenInformation() ? profileDto.getBusinessInformation() : "") + .selfIntroduction(profileDto.getSelfIntroduction()) + .businessInformation(profileDto.getBusinessInformation()) .companyInformations(profile.getOpenInformation() ? profileDto.getCompanyInformations() : Collections.emptyList()) .build(); diff --git a/src/main/java/com/brainpix/security/service/IndividualSignUpService.java b/src/main/java/com/brainpix/security/service/IndividualSignUpService.java index 2fc62c36..94662ac2 100644 --- a/src/main/java/com/brainpix/security/service/IndividualSignUpService.java +++ b/src/main/java/com/brainpix/security/service/IndividualSignUpService.java @@ -24,7 +24,6 @@ protected void firstSignupProcess(User user) { IndividualProfile profile = IndividualProfile.builder() .user(user) .specializationList(null) - .contactOpen(true) .careerOpen(true) .stackOpen(true) .build();