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 @@ -29,16 +29,7 @@ public InternalUserDetails getInternalUser(Long userId) {
List<InternalUserDetails> users = fetchInternalUsers(Collections.singletonList(userId));
return convertUserDetailsWithRoleToTeam(users.get(0));
}

/**
* 단일 내부 사용자 조회 (role 변환 없이 원본 team 정보 반환)
*/
public InternalUserDetails getInternalUserWithOriginalTeam(Long userId) {
validateUserId(userId);
List<InternalUserDetails> users = fetchInternalUsers(Collections.singletonList(userId));
return users.get(0);
}


/**
* 다중 내부 사용자 조회
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public ResponseEntity<List<InternalPopularPostResponse>> getPopularPosts() {
public ResponseEntity<InternalMemberProfileResponse> getUserProfile(
@Parameter(description = "조회할 멤버 ID", example = "1") @RequestParam String memberId) {
Member member = memberService.getMemberById(Long.valueOf(memberId));
InternalUserDetails userDetails = platformService.getInternalUserWithOriginalTeam(Long.valueOf(memberId));
InternalUserDetails userDetails = platformService.getInternalUser(Long.valueOf(memberId));

List<CardinalInfoResponse> activityResponses = userDetails.soptActivities()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ public ResponseEntity<MemberProfileResponse> updateUserProfile (
@Parameter(hidden = true) @AuthenticationPrincipal Long userId,
@Valid @RequestBody MemberProfileUpdateRequest request
) {
val normalTeamNameRequest = request.activities().stream().filter(activity ->
ActivityTeam.hasActivityTeam(activity.team())).count();
if (request.activities().size() != normalTeamNameRequest) {
throw new ClientBadRequestException("잘못된 솝트 활동 팀 이름입니다.");
}

val currentCount = request.careers().stream().filter(c -> c.isCurrent()).count();
if (currentCount > 1) throw new ClientBadRequestException("현재 직장이 2개 이상입니다.");
val member = memberService.updateMemberProfile(userId, request);
Expand All @@ -149,7 +145,7 @@ public ResponseEntity<MemberProfileSpecificResponse> getUserProfile (
@PathVariable Long id,
@Parameter(hidden = true) @AuthenticationPrincipal Long userId
) {
MemberProfileSpecificResponse response = memberService.getMemberProfile(id, userId, false);
MemberProfileSpecificResponse response = memberService.getMemberProfile(id, userId);
sortProfileCareer(response);
return ResponseEntity.status(HttpStatus.OK).body(response);
}
Expand All @@ -159,7 +155,7 @@ public ResponseEntity<MemberProfileSpecificResponse> getUserProfile (
public ResponseEntity<MemberProfileSpecificResponse> getMyProfile (
@Parameter(hidden = true) @AuthenticationPrincipal Long userId
) {
MemberProfileSpecificResponse response = memberService.getMemberProfile(userId, userId, true);
MemberProfileSpecificResponse response = memberService.getMemberProfile(userId, userId);
sortProfileCareer(response);
return ResponseEntity.status(HttpStatus.OK).body(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public enum ActivityTeam {
NO_TEAM("해당 없음"),
MEDIA_TEAM("미디어팀"),
OPERATION_TEAM("운영팀"),
MAKERS("메이커스팀");
MAKERS("메이커스");

final String teamName;
ActivityTeam(String teamName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.sopt.makers.internal.member.domain.MemberLink;
import org.sopt.makers.internal.member.domain.MemberReport;
import org.sopt.makers.internal.member.domain.UserFavor;
import org.sopt.makers.internal.member.domain.enums.ActivityTeam;
import org.sopt.makers.internal.member.domain.enums.OrderByCondition;
import org.sopt.makers.internal.member.dto.ActivityVo;
import org.sopt.makers.internal.member.dto.MemberProfileProjectDao;
Expand Down Expand Up @@ -130,13 +131,10 @@ public List<MemberResponse> getMemberByName(String name) {
}

@Transactional(readOnly = true)
public MemberProfileSpecificResponse getMemberProfile(Long profileId, Long viewerId ,Boolean isForUpdate) {
public MemberProfileSpecificResponse getMemberProfile(Long profileId, Long viewerId) {
Member member = getMemberHasProfileById(profileId);
boolean isMine = Objects.equals(profileId, viewerId);
// 내 프로필 조회 (수정 목적)인 경우 원본 team 정보 사용, 일반 프로필 조회인 경우 role 변환된 team 정보 사용
InternalUserDetails userDetails = isForUpdate
? platformService.getInternalUserWithOriginalTeam(profileId)
: platformService.getInternalUser(profileId);
InternalUserDetails userDetails = platformService.getInternalUser(profileId);
List<MemberProfileProjectDao> memberProfileProjects = getMemberProfileProjects(profileId);
val activityMap = getMemberProfileActivity(userDetails.soptActivities(), memberProfileProjects);
val soptActivity = getMemberProfileProjects(userDetails.soptActivities(), memberProfileProjects);
Expand Down Expand Up @@ -671,6 +669,56 @@ private JsonNode createSlackRequest(Long id, String name, String idealType) {
return rootNode;
}

/**
* 임원진 직책 여부 확인
* - "회장", "부회장", "총무"와 정확히 일치하거나
* - "파트장"을 포함하거나 (예: "기획 파트장", "디자인 파트장")
* - "팀장"을 포함하면 (예: "운영팀 팀장", "미디어팀 팀장")
* 임원진으로 간주
*/
private boolean isExecutivePosition(String team) {
if (team == null || team.isEmpty()) {
return false;
}
return team.equals("회장")
|| team.equals("부회장")
|| team.equals("총무")
|| team.contains("파트장")
|| team.contains("팀장");
}

/**
* 가공된 team 값을 Platform 원본 team 값으로 역변환
* PlatformService.convertRoleToTeamValue의 역변환
*
* - "회장", "부회장", "총무", "파트장" 포함 → null
* - "팀장" 포함 (예: "운영팀 팀장") → "운영팀"
* - 그 외 → 원본 그대로 반환
*/
private String convertTeamToOriginalValue(String team) {
if (team == null || team.isEmpty()) {
return null;
}

// 회장, 부회장, 총무는 원본 team이 null
if (team.equals("회장") || team.equals("부회장") || team.equals("총무")) {
return null;
}

// "기획 파트장", "디자인 파트장" 등 → 원본 team은 null
if (team.contains("파트장")) {
return null;
}

// "운영팀 팀장", "미디어팀 팀장" 등 → " 팀장" 제거
if (team.contains("팀장")) {
return team.replace(" 팀장", "");
}

// 일반 팀 (미디어팀, 운영팀 등)은 그대로 반환
return team;
}

@Transactional
public Member updateMemberProfile(Long id, MemberProfileUpdateRequest request) {
val userDetails = platformService.getInternalUser(id);
Expand All @@ -679,21 +727,40 @@ public Member updateMemberProfile(Long id, MemberProfileUpdateRequest request) {
.stream()
.collect(Collectors.toMap(SoptActivity::generation, Function.identity()));

List<PlatformUserUpdateRequest.SoptActivityRequest> soptActivitiesForPlatform = request.activities()
.stream()
.map(requestActivity -> {
SoptActivity dbActivity = dbActivityMap.get(requestActivity.generation());
List<PlatformUserUpdateRequest.SoptActivityRequest> soptActivitiesForPlatform = new ArrayList<>();

if (dbActivity == null) {
throw new ClientBadRequestException(
"요청된 활동 기수 정보(" + requestActivity.generation() + ")가 유저의 기존 정보와 일치하지 않습니다.");
}
for (val requestActivity : request.activities()) {
SoptActivity dbActivity = dbActivityMap.get(requestActivity.generation());

return new PlatformUserUpdateRequest.SoptActivityRequest(dbActivity.activityId(),
requestActivity.team());
})
.toList();
if (dbActivity == null) {
throw new ClientBadRequestException(
"요청된 활동 기수 정보(" + requestActivity.generation() + ")가 유저의 기존 정보와 일치하지 않습니다.");
}

// 임원진 기수는 원본 team 값으로 역변환하여 전송 (업데이트하지 않음)
if (isExecutivePosition(dbActivity.team())) {
String originalTeam = convertTeamToOriginalValue(dbActivity.team());
soptActivitiesForPlatform.add(
new PlatformUserUpdateRequest.SoptActivityRequest(
dbActivity.activityId(),
originalTeam // Platform 원본 team 값으로 역변환
)
);
continue;
}

// 일반 팀만 ActivityTeam 검증
if (!ActivityTeam.hasActivityTeam(requestActivity.team())) {
throw new ClientBadRequestException("잘못된 솝트 활동 팀 이름입니다.");
}

soptActivitiesForPlatform.add(
new PlatformUserUpdateRequest.SoptActivityRequest(
dbActivity.activityId(),
requestActivity.team()
)
);
}
val platformRequest = new PlatformUserUpdateRequest(request.name(), request.profileImage(),
request.birthday() != null ? request.birthday().format(DateTimeFormatter.ISO_LOCAL_DATE) : null,
request.phone() != null && !request.phone().isBlank() ? request.phone() : userDetails.phone(),
Expand Down