Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ProfileController {
@Individual
@GetMapping("/individual")
public ResponseEntity<ApiResponse<IndividualProfileResponseDto>> getIndividualProfile(@UserId Long userId) {
IndividualProfileResponseDto profile = profileService.getMyProfile(userId);
IndividualProfileResponseDto profile = profileService.getIndividualProfile(userId);
return ResponseEntity.ok(ApiResponse.success(profile));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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())
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -43,7 +43,7 @@ public List<Career> toCareerList(List<IndividualProfileUpdateDto.CareerDto> 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<CompanyInformation> toCompanyInformationList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class CompanyProfileResponseDto {
public static class CompanyInformationDto {
private CompanyInformationType type; // 기업 정보 타입
private String value; // 기업 정보 값
private Boolean isPublic;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class CompanyProfileUpdateDto {
private String businessInformation; // 사업 정보

private List<CompanyInformationDto> companyInformations; // 기업 정보
private Boolean openInformation; // 기업 정보 공개 여부

private List<Specialization> specializations; // 기업 분야 (최대 2개)

@Getter
public static class CompanyInformationDto {
private CompanyInformationType type; // 기업 정보 타입
private String value; // 기업 정보 값
private Boolean isPublic; // 공개 여부 추가
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class IndividualProfileResponseDto {
public static class ContactDto {
private ContactType type; // 연락처 유형
private String value; // 연락처 값
private Boolean isPublic;
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class IndividualProfileUpdateDto {
private String selfIntroduction; // 자기소개

private List<ContactDto> contacts; // 개별 정보
private Boolean contactOpen; // 개별 정보 공개여부

private List<StackDto> stacks; // 보유 기술
private Boolean stackOpen; // 보유 기술 공개여부
Expand All @@ -34,6 +33,7 @@ public class IndividualProfileUpdateDto {
public static class ContactDto {
private ContactType type; // 연락처 타입
private String value; // 연락처 내용
private Boolean isPublic;
}

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ public CompanyProfile(User user, List<Specialization> 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<Specialization> specializations) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/brainpix/profile/entity/Contact.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@Getter
public class IndividualProfile extends Profile {
private String selfIntroduction;
private Boolean ContactOpen;
private Boolean CareerOpen;
private Boolean stackOpen;

Expand All @@ -34,17 +33,15 @@ public class IndividualProfile extends Profile {

@Builder
public IndividualProfile(User user, List<Specialization> 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;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/brainpix/profile/service/ProfileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Contact> contacts = converter.toContactList(updateDto.getContacts(), profile);
List<Contact> contacts = updateDto.getContacts().stream()
.map(dto -> new Contact(dto.getType(), dto.getValue(), profile, dto.getIsPublic()))
.toList();
contactRepository.saveAll(contacts);

// 보유 기술(Stack) 업데이트
Expand Down Expand Up @@ -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());
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protected void firstSignupProcess(User user) {
IndividualProfile profile = IndividualProfile.builder()
.user(user)
.specializationList(null)
.contactOpen(true)
.careerOpen(true)
.stackOpen(true)
.build();
Expand Down