Skip to content

Commit

Permalink
Merge pull request #329 from WE-ARE-RACCOONS/RAC-478
Browse files Browse the repository at this point in the history
RAC-478 feat : κ΄€λ¦¬μž νŽ˜μ΄μ§€ API
  • Loading branch information
ywj9811 authored Dec 16, 2024
2 parents 8eab504 + e622c87 commit ff57f1f
Show file tree
Hide file tree
Showing 42 changed files with 731 additions and 415 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.postgraduate.admin.application.dto.res;


import java.time.LocalDateTime;

public record WishResponse(
public record MatchingWishResponse(
Long wishId,
String nickName,
String field,
String postgradu,
String professor,
String lab,
String phoneNumber,
LocalDateTime createAt,
Boolean marketingReceive,
Boolean matchingReceive,
String major,
String field
LocalDateTime updatedAt
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record MatchingWishResponses(List<MatchingWishResponse> wishResponses) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

public record MentoringManageResponse(
List<MentoringInfo> mentoringInfo,
UserMentoringInfo userMentoringInfo
UserInfoBasic userInfoBasic,
List<MentoringInfo> mentoringInfo
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record PaymentInfos(List<PaymentInfo> paymentInfos) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.time.LocalDateTime;

public record SalaryInfo(
Long salaryId,
String nickName,
String phoneNumber,
Integer totalAmount,
Expand All @@ -12,7 +11,7 @@ public record SalaryInfo(
String accountNumber,
LocalDateTime salaryDoneDate
) {
public SalaryInfo(Long salaryId, String nickName, String phoneNumber, int totalAmount, LocalDateTime salaryDoneDate) {
this(salaryId, nickName, phoneNumber, totalAmount, null, null, null, salaryDoneDate);
public SalaryInfo(String nickName, String phoneNumber, int totalAmount, LocalDateTime salaryDoneDate) {
this(nickName, phoneNumber, totalAmount, null, null, null, salaryDoneDate);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record SalaryInfos(List<SalaryInfo> salaryInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record SeniorInfos(List<SeniorInfo> seniorInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record UnsettledSalaryInfos(List<UnSettledSalaryInfo> unSettledSalaryInfos) {
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package com.postgraduate.admin.application.dto.res;

import com.postgraduate.domain.member.user.domain.entity.constant.Status;

import java.time.LocalDateTime;

public record UserInfo(
Long userId,
String nickName,
String phoneNumber,
LocalDateTime createdAt,
Boolean marketingReceive,
Boolean matchingReceive,
Long wishId,
Status matchingStatus,
Boolean marketinRgeceive,
Boolean isSenior
) { }
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.postgraduate.admin.application.dto.res;

public record UserMentoringInfo(
public record UserInfoBasic(
String nickName,
String phoneNumber
) { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record UserInfos(List<UserInfo> userInfos) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.postgraduate.admin.application.dto.res;

import java.time.LocalDateTime;

public record WaitingWishResponse(
Long wishId,
String field,
String postgradu,
String professor,
String lab,
String phoneNumber,
LocalDateTime createAt
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.postgraduate.admin.application.dto.res;

import java.util.List;

public record WaitingWishResponses(List<WaitingWishResponse> wishResponses) {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.postgraduate.admin.application.mapper;

import com.postgraduate.admin.application.dto.res.*;
import com.postgraduate.domain.member.user.domain.entity.constant.Status;
import com.postgraduate.domain.member.user.domain.entity.MemberRole;
import com.postgraduate.domain.mentoring.domain.entity.Mentoring;
import com.postgraduate.domain.payment.domain.entity.Payment;
import com.postgraduate.domain.salary.domain.entity.Salary;
Expand All @@ -10,6 +10,7 @@
import com.postgraduate.domain.member.senior.domain.entity.Senior;
import com.postgraduate.domain.member.user.application.utils.UserUtils;
import com.postgraduate.domain.member.user.domain.entity.User;
import com.postgraduate.domain.wish.domain.entity.Wish;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -41,20 +42,18 @@ public CertificationDetailsResponse mapToCertificationInfo(Senior senior) {
);
}

public UserInfo mapToUserInfo(User user) {
public UserInfo mapToUserInfo(MemberRole memberRole) {
User user = memberRole.getUser();
return new UserInfo(
user.getUserId(),
user.getNickName(),
user.getPhoneNumber(),
user.getCreatedAt(),
user.getMarketingReceive(),
false,
1L, // todo : wish μ‚­μ œμ— λ”°λ₯Έ λ³€κ²½ ν•„μš”
Status.MATCHED,
false
user.isSenior()
);
}


public SeniorInfo mapToSeniorInfo(Salary salary) {
Senior senior = salary.getSenior();
Expand All @@ -66,7 +65,7 @@ public SeniorInfo mapToSeniorInfo(Salary salary) {
senior.getStatus(),
salary.getTotalAmount(),
user.getMarketingReceive(),
false //todo : wish μ‚­μ œμ— λ”°λ₯Έ μ„ λ°°μ—μ„œ ν›„λ°° νŒλ‹¨ 쑰건 μ‚­μ œ or μˆ˜μ • ν•„μš”
user.isJunior()
);
}

Expand Down Expand Up @@ -99,16 +98,16 @@ private MentoringInfo getMentoringInfo(Mentoring mentoring, User user) {
}


public UserMentoringInfo mapToUserMentoringInfo(User user) {
return new UserMentoringInfo(
public UserInfoBasic mapToUserMentoringInfo(User user) {
return new UserInfoBasic(
user.getNickName(),
user.getPhoneNumber()
);
}

public UserMentoringInfo mapToUserMentoringInfo(Senior senior) {
public UserInfoBasic mapToUserMentoringInfo(Senior senior) {
User user = senior.getUser();
return new UserMentoringInfo(
return new UserInfoBasic(
user.getNickName(),
user.getPhoneNumber()
);
Expand Down Expand Up @@ -140,10 +139,10 @@ public PaymentInfo mapToPaymentInfo(Payment payment) {
return getPaymentInfo(payment, null, user);
}

public SalaryInfoWithOutId mapToSalaryResponse(Senior senior, String accountNumber, Salary salary) {
public SalaryInfo mapToSalaryResponse(Senior senior, String accountNumber, Salary salary) {
User user = senior.getUser();
SalaryAccount account = salary.getAccount();
return new SalaryInfoWithOutId(
return new SalaryInfo(
user.getNickName(),
user.getPhoneNumber(),
salary.getTotalAmount(),
Expand All @@ -154,19 +153,9 @@ public SalaryInfoWithOutId mapToSalaryResponse(Senior senior, String accountNumb
);
}

public SalaryInfoWithOutId mapToSalaryResponse(Senior senior, Salary salary) {
User user = senior.getUser();
return new SalaryInfoWithOutId (
user.getNickName(),
user.getPhoneNumber(),
salary.getTotalAmount(),
salary.getSalaryDoneDate()
);
}

public SalaryInfoWithOutId mapToSalaryResponse(Salary salary) {
public SalaryInfo mapToSalaryResponse(Salary salary) {
User user = userUtils.getArchiveUser();
return new SalaryInfoWithOutId (
return new SalaryInfo(
user.getNickName(),
user.getPhoneNumber(),
salary.getTotalAmount(),
Expand Down Expand Up @@ -239,4 +228,29 @@ private static MentoringWithPaymentResponse getMentoringWithPaymentResponse(Ment
SHORT.getCharge()
);
}

public WaitingWishResponse mapToWaitingWish(Wish wish) {
return new WaitingWishResponse(
wish.getWishId(),
wish.getField(),
wish.getPostgradu(),
wish.getProfessor(),
wish.getLab(),
wish.getPhoneNumber(),
wish.getCreatedAt()
);
}

public MatchingWishResponse mapToMatchedWish(Wish wish) {
return new MatchingWishResponse(
wish.getWishId(),
wish.getField(),
wish.getPostgradu(),
wish.getProfessor(),
wish.getLab(),
wish.getPhoneNumber(),
wish.getCreatedAt(),
wish.getUpdatedAt()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.postgraduate.admin.application.usecase;

import com.postgraduate.admin.application.dto.res.MentoringManageResponse;
import com.postgraduate.admin.application.dto.res.UserMentoringInfo;
import com.postgraduate.admin.application.dto.res.UserInfoBasic;
import com.postgraduate.admin.application.dto.res.MentoringInfo;
import com.postgraduate.admin.application.mapper.AdminMapper;
import com.postgraduate.admin.domain.service.*;
Expand Down Expand Up @@ -36,8 +36,8 @@ public MentoringManageResponse seniorMentorings(Long seniorId) {
List<MentoringInfo> mentoringInfos = mentorings.stream()
.map(adminMapper::mapToMentoringInfoWithSenior)
.toList();
UserMentoringInfo seniorInfo = adminMapper.mapToUserMentoringInfo(senior);
return new MentoringManageResponse(mentoringInfos, seniorInfo);
UserInfoBasic seniorInfo = adminMapper.mapToUserMentoringInfo(senior);
return new MentoringManageResponse(seniorInfo, mentoringInfos);
}

@Transactional(readOnly = true)
Expand All @@ -47,8 +47,8 @@ public MentoringManageResponse userMentoringInfos(Long userId) {
List<MentoringInfo> mentoringInfos = mentorings.stream()
.map(adminMapper::mapToMentoringInfoWithUser)
.toList();
UserMentoringInfo userInfo = adminMapper.mapToUserMentoringInfo(user);
return new MentoringManageResponse(mentoringInfos, userInfo);
UserInfoBasic userInfo = adminMapper.mapToUserMentoringInfo(user);
return new MentoringManageResponse(userInfo, mentoringInfos);
}

public void refundMentoring(User user, Long mentoringId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.postgraduate.admin.application.usecase;

import com.postgraduate.admin.application.dto.res.MentoringWithPaymentResponse;
import com.postgraduate.admin.application.dto.res.PaymentInfo;
import com.postgraduate.admin.application.dto.res.PaymentInfos;
import com.postgraduate.admin.application.dto.res.PaymentWithMentoringQuery;
import com.postgraduate.admin.application.mapper.AdminMapper;
import com.postgraduate.admin.domain.service.AdminMentoringService;
Expand All @@ -11,11 +11,10 @@
import com.postgraduate.domain.payment.application.usecase.PaymentManageUseCase;
import com.postgraduate.domain.member.user.domain.entity.User;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import static com.postgraduate.domain.mentoring.domain.entity.constant.MentoringStatus.DONE;

@Service
Expand All @@ -29,15 +28,15 @@ public class AdminPaymentUseCase {
private final AdminMapper adminMapper;

@Transactional(readOnly = true)
public List<PaymentInfo> paymentInfos() {
List<PaymentWithMentoringQuery> all = adminPaymentService.allPayments();
return all.stream()
public PaymentInfos paymentInfos(Integer page) {
Page<PaymentWithMentoringQuery> all = adminPaymentService.allPayments(page);
return new PaymentInfos(all.stream()
.map(pm -> {
if (pm.mentoring().isEmpty())
return adminMapper.mapToPaymentInfo(pm.payment());
return adminMapper.mapToPaymentInfo(pm.payment(), pm.mentoring().get());
})
.toList();
.toList());
}

@Transactional(readOnly = true)
Expand Down
Loading

0 comments on commit ff57f1f

Please sign in to comment.