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 @@ -65,12 +65,14 @@ public static ReceivedSubstituteRequestResponseDto of(ReceivedSubstituteRequestL
))
.requester(WorkerInfo.of(
response.getRequesterId(),
response.getRequesterName()
response.getRequesterName(),
response.getRequesterProfileImageUrl()
))
.requestType(DescribedEnumDto.of(response.getRequestType(), SubstituteRequestType.describe()))
.acceptedWorker(ObjectUtils.isNotEmpty(response.getAcceptedWorkerId()) ? WorkerInfo.of(
response.getAcceptedWorkerId(),
response.getAcceptedWorkerName()
response.getAcceptedWorkerName(),
response.getAcceptedWorkerProfileImageUrl()
) : null)
.status(DescribedEnumDto.of(response.getStatus(), SubstituteRequestStatus.describe()))
.requestReason(response.getRequestReason())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ public static SubstituteRequestDetailResponseDto of(SentSubstituteRequestDetailR
))
.requester(WorkerInfo.of(
response.getRequesterId(),
response.getRequesterName()
response.getRequesterName(),
response.getRequesterProfileImageUrl()
))
.requestType(DescribedEnumDto.of(response.getRequestType(), SubstituteRequestType.describe()))
.targets(ObjectUtils.isNotEmpty(response.getTargets()) ?
.targets(ObjectUtils.isNotEmpty(response.getTargets()) ?
response.getTargets().stream()
.map(SubstituteRequestTargetResponseDto::of)
.toList() : null)
.acceptedWorker(ObjectUtils.isNotEmpty(response.getAcceptedWorkerId()) ? WorkerInfo.of(
response.getAcceptedWorkerId(),
response.getAcceptedWorkerName()
response.getAcceptedWorkerName(),
response.getAcceptedWorkerProfileImageUrl()
) : null)
.status(DescribedEnumDto.of(response.getStatus(), SubstituteRequestStatus.describe()))
.requestReason(response.getRequestReason())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static SubstituteRequestTargetResponseDto of(SubstituteRequestTargetInfo
return SubstituteRequestTargetResponseDto.builder()
.target(WorkerInfo.of(
targetInfo.getTargetWorkerId(),
targetInfo.getTargetWorkerName()
targetInfo.getTargetWorkerName(),
targetInfo.getProfileImageUrl()
))
.status(DescribedEnumDto.of(targetInfo.getStatus(), SubstituteRequestTargetStatus.describe()))
.rejectionReason(targetInfo.getRejectionReason())
Expand All @@ -41,7 +42,7 @@ public static SubstituteRequestTargetResponseDto of(SubstituteRequestTargetInfo

public static SubstituteRequestTargetResponseDto of(Long targetWorkerId, String targetWorkerName) {
return SubstituteRequestTargetResponseDto.builder()
.target(WorkerInfo.of(targetWorkerId, targetWorkerName))
.target(WorkerInfo.of(targetWorkerId, targetWorkerName, null))
.status(DescribedEnumDto.of(SubstituteRequestTargetStatus.PENDING, SubstituteRequestTargetStatus.describe()))
.rejectionReason(null)
.respondedAt(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ public class WorkerInfo {
@Schema(description = "근무자 이름", example = "홍길동")
private String workerName;

@Schema(description = "근무자 프로필 이미지 URL (미설정 시 null)", example = "https://cdn.alter-app.com/users/1/profile.png")
private String profileImageUrl;

public static WorkerInfo of(
Long workerId,
String workerName
String workerName,
String profileImageUrl
) {
return WorkerInfo.builder()
.workerId(workerId)
.workerName(workerName)
.profileImageUrl(profileImageUrl)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ public class UserWorkspaceWorkerResponseDto {
@Schema(description = "근무자 이름", example = "홍길동")
private String name;

@Schema(description = "근무자 프로필 이미지 URL (미설정 시 null)", example = "https://cdn.alter-app.com/users/1/profile.png")
private String profileImageUrl;

public static UserWorkspaceWorkerResponseDto of(UserWorkspaceWorkerResponse entity) {
return UserWorkspaceWorkerResponseDto.builder()
.id(entity.getId())
.name(entity.getName())
.profileImageUrl(entity.getProfileImageUrl())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public static ManagerSubstituteRequestResponseDto of(ManagerSubstituteRequestLis
))
.requester(ManagerWorkerInfo.of(
response.getRequesterId(),
response.getRequesterName()
response.getRequesterName(),
response.getRequesterProfileImageUrl()
))
.requestType(DescribedEnumDto.of(response.getRequestType(), SubstituteRequestType.describe()))
.acceptedWorker(ObjectUtils.isNotEmpty(response.getAcceptedWorkerId()) ? ManagerWorkerInfo.of(
response.getAcceptedWorkerId(),
response.getAcceptedWorkerName()
response.getAcceptedWorkerName(),
response.getAcceptedWorkerProfileImageUrl()
) : null)
.status(DescribedEnumDto.of(response.getStatus(), SubstituteRequestStatus.describe()))
.requestReason(response.getRequestReason())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ public class ManagerWorkerInfo {
@Schema(description = "근무자 이름", example = "홍길동")
private String workerName;

public static ManagerWorkerInfo of(Long workerId, String workerName) {
@Schema(description = "근무자 프로필 이미지 URL (미설정 시 null)", example = "https://cdn.alter-app.com/users/1/profile.png")
private String profileImageUrl;

public static ManagerWorkerInfo of(Long workerId, String workerName, String profileImageUrl) {
return ManagerWorkerInfo.builder()
.workerId(workerId)
.workerName(workerName)
.profileImageUrl(profileImageUrl)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ public class WorkspaceWorkerResponseDto {
@Schema(description = "근무자 성별", example = "GENDER_MALE")
private UserGender gender;

@Schema(description = "근무자 프로필 이미지 URL (미설정 시 null)", example = "https://cdn.alter-app.com/users/1/profile.png")
private String profileImageUrl;

public static WorkspaceWorkerResponseDto of(WorkspaceWorkerResponse entity) {
return WorkspaceWorkerResponseDto.builder()
.id(entity.getId())
.name(entity.getName())
.contact(entity.getContact())
.gender(entity.getGender())
.profileImageUrl(entity.getProfileImageUrl())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.dreamteam.alter.adapter.outbound.workspace.persistence.readonly.SentSubstituteRequestListResponse;
import com.dreamteam.alter.adapter.outbound.workspace.persistence.readonly.SentSubstituteRequestDetailResponse;
import com.dreamteam.alter.adapter.outbound.workspace.persistence.readonly.SubstituteRequestTargetInfo;
import com.dreamteam.alter.domain.file.entity.QFile;
import com.dreamteam.alter.domain.file.type.FileStatus;
import com.dreamteam.alter.domain.file.type.FileTargetType;
import com.dreamteam.alter.domain.user.entity.QUser;
import com.dreamteam.alter.domain.user.entity.User;
import com.dreamteam.alter.domain.workspace.entity.QWorkspaceWorker;
Expand Down Expand Up @@ -123,6 +126,7 @@ public long getReceivedRequestCount(User user, GetReceivedSubstituteRequestsFilt
.where(
workspaceCondition
.and(statusCondition(filter.getStatus()))
.and(substituteRequest.requesterId.ne(workspaceWorker.id))
.and(
substituteRequest.requestType.eq(SubstituteRequestType.ALL)
.or(JPAExpressions.selectFrom(QSubstituteRequestTarget.substituteRequestTarget)
Expand All @@ -147,6 +151,8 @@ public List<ReceivedSubstituteRequestListResponse> getReceivedRequestListWithCur
QWorkspaceWorker requesterWorker = new QWorkspaceWorker("requesterWorker");
QWorkspaceWorker acceptedWorker = new QWorkspaceWorker("acceptedWorker");
QWorkspaceWorker myWorker = new QWorkspaceWorker("myWorker");
QFile requesterFile = new QFile("requesterFile");
QFile acceptedFile = new QFile("acceptedFile");

BooleanExpression workspaceCondition;
if (ObjectUtils.isNotEmpty(filter.getWorkspaceId())) {
Expand Down Expand Up @@ -176,9 +182,11 @@ public List<ReceivedSubstituteRequestListResponse> getReceivedRequestListWithCur
workspace.businessName,
requesterWorker.id,
requesterUser.name,
requesterFile.fileUrl,
substituteRequest.requestType,
acceptedWorker.id,
acceptedUser.name,
acceptedFile.fileUrl,
substituteRequest.status,
substituteRequest.requestReason,
substituteRequest.createdAt,
Expand All @@ -190,8 +198,10 @@ public List<ReceivedSubstituteRequestListResponse> getReceivedRequestListWithCur
.join(workspaceShift.workspace, workspace)
.join(requesterWorker).on(requesterWorker.id.eq(substituteRequest.requesterId))
.join(requesterUser).on(requesterUser.id.eq(requesterWorker.user.id))
.leftJoin(requesterFile).on(fileConditions(requesterFile, requesterUser))
.leftJoin(acceptedWorker).on(acceptedWorker.id.eq(substituteRequest.acceptedWorkerId))
.leftJoin(acceptedUser).on(acceptedUser.id.eq(acceptedWorker.user.id))
.leftJoin(acceptedFile).on(fileConditions(acceptedFile, acceptedUser))
.join(workspaceWorker).on(
workspaceWorker.workspace.id.eq(workspace.id)
.and(workspaceWorker.user.eq(user))
Expand All @@ -200,6 +210,7 @@ public List<ReceivedSubstituteRequestListResponse> getReceivedRequestListWithCur
.where(
workspaceCondition
.and(statusCondition(filter.getStatus()))
.and(substituteRequest.requesterId.ne(workspaceWorker.id))
.and(
substituteRequest.requestType.eq(SubstituteRequestType.ALL)
.or(JPAExpressions.selectFrom(QSubstituteRequestTarget.substituteRequestTarget)
Expand Down Expand Up @@ -274,7 +285,9 @@ public Optional<SentSubstituteRequestDetailResponse> getSentRequestDetail(User u
QUser requesterUser = new QUser("requesterUser");
QWorkspaceWorker acceptedWorker = new QWorkspaceWorker("acceptedWorker");
QUser acceptedUser = new QUser("acceptedUser");

QFile requesterFile = new QFile("requesterFile");
QFile acceptedFile = new QFile("acceptedFile");

SentSubstituteRequestDetailResponse requestInfo = queryFactory
.select(Projections.bean(
SentSubstituteRequestDetailResponse.class,
Expand All @@ -287,9 +300,11 @@ public Optional<SentSubstituteRequestDetailResponse> getSentRequestDetail(User u
workspace.businessName.as("workspaceName"),
requesterWorker.id.as("requesterId"),
requesterUser.name.as("requesterName"),
requesterFile.fileUrl.as("requesterProfileImageUrl"),
substituteRequest.requestType.as("requestType"),
acceptedWorker.id.as("acceptedWorkerId"),
acceptedUser.name.as("acceptedWorkerName"),
acceptedFile.fileUrl.as("acceptedWorkerProfileImageUrl"),
substituteRequest.status.as("status"),
substituteRequest.requestReason.as("requestReason"),
substituteRequest.createdAt.as("createdAt"),
Expand All @@ -301,8 +316,10 @@ public Optional<SentSubstituteRequestDetailResponse> getSentRequestDetail(User u
.join(workspaceShift.workspace, workspace)
.join(requesterWorker).on(requesterWorker.id.eq(substituteRequest.requesterId))
.join(requesterUser).on(requesterUser.id.eq(requesterWorker.user.id))
.leftJoin(requesterFile).on(fileConditions(requesterFile, requesterUser))
.leftJoin(acceptedWorker).on(acceptedWorker.id.eq(substituteRequest.acceptedWorkerId))
.leftJoin(acceptedUser).on(acceptedUser.id.eq(acceptedWorker.user.id))
.leftJoin(acceptedFile).on(fileConditions(acceptedFile, acceptedUser))
.where(
substituteRequest.id.eq(requestId)
.and(requesterWorker.user.eq(user))
Expand All @@ -317,19 +334,22 @@ public Optional<SentSubstituteRequestDetailResponse> getSentRequestDetail(User u
QUser targetUser = new QUser("targetUser");
QWorkspaceWorker targetWorker = new QWorkspaceWorker("targetWorker");
QSubstituteRequestTarget substituteRequestTarget = new QSubstituteRequestTarget("substituteRequestTarget");
QFile targetFile = new QFile("targetFile");

List<SubstituteRequestTargetInfo> targets = queryFactory
.select(Projections.constructor(
SubstituteRequestTargetInfo.class,
targetWorker.id,
targetUser.name,
targetFile.fileUrl,
substituteRequestTarget.status,
substituteRequestTarget.rejectionReason,
substituteRequestTarget.respondedAt
))
.from(substituteRequestTarget)
.join(targetWorker).on(targetWorker.id.eq(substituteRequestTarget.targetWorkerId))
.join(targetUser).on(targetUser.id.eq(targetWorker.user.id))
.leftJoin(targetFile).on(fileConditions(targetFile, targetUser))
.where(substituteRequestTarget.substituteRequest.id.eq(requestId))
.orderBy(substituteRequestTarget.id.asc())
.fetch();
Expand Down Expand Up @@ -367,6 +387,8 @@ public List<ManagerSubstituteRequestListResponse> getManagerRequestListWithCurso
QUser acceptedUser = new QUser("acceptedUser");
QWorkspaceWorker requesterWorker = new QWorkspaceWorker("requesterWorker");
QWorkspaceWorker acceptedWorker = new QWorkspaceWorker("acceptedWorker");
QFile requesterFile = new QFile("requesterFile");
QFile acceptedFile = new QFile("acceptedFile");

return queryFactory
.select(Projections.constructor(
Expand All @@ -380,9 +402,11 @@ public List<ManagerSubstituteRequestListResponse> getManagerRequestListWithCurso
workspace.businessName,
requesterWorker.id,
requesterUser.name,
requesterFile.fileUrl,
substituteRequest.requestType,
acceptedWorker.id,
acceptedUser.name,
acceptedFile.fileUrl,
substituteRequest.status,
substituteRequest.requestReason,
substituteRequest.createdAt,
Expand All @@ -394,8 +418,10 @@ public List<ManagerSubstituteRequestListResponse> getManagerRequestListWithCurso
.join(workspaceShift.workspace, workspace)
.join(requesterWorker).on(requesterWorker.id.eq(substituteRequest.requesterId))
.join(requesterUser).on(requesterUser.id.eq(requesterWorker.user.id))
.leftJoin(requesterFile).on(fileConditions(requesterFile, requesterUser))
.leftJoin(acceptedWorker).on(acceptedWorker.id.eq(substituteRequest.acceptedWorkerId))
.leftJoin(acceptedUser).on(acceptedUser.id.eq(acceptedWorker.user.id))
.leftJoin(acceptedFile).on(fileConditions(acceptedFile, acceptedUser))
.where(
ObjectUtils.isNotEmpty(workspaceId) ? workspace.id.eq(workspaceId) : null,
managerRequestStatusCondition(status),
Expand Down Expand Up @@ -489,4 +515,12 @@ public List<SubstituteRequest> findAllPendingTargetRequestsByTargetWorkerId(Long
)
.fetch();
}

private BooleanExpression[] fileConditions(QFile file, QUser user) {
return new BooleanExpression[] {
file.targetType.eq(FileTargetType.USER_PROFILE),
file.targetId.eq(user.id.stringValue()),
file.status.eq(FileStatus.ATTACHED)
};
}
}
Loading
Loading