Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #255

Merged
merged 9 commits into from
May 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import jakarta.validation.constraints.NotBlank;

public record SeniorChangeRequest(@NotBlank String major, @NotBlank String postgradu, @NotBlank String professor,
@NotBlank String lab, @NotBlank String field, @NotBlank String keyword) {
@NotBlank String lab, @NotBlank String field, @NotBlank String keyword, @NotBlank String chatLink) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public record SeniorSignUpRequest(@NotNull Long socialId, @NotBlank String phone
@Size(max = 6, message = "6κΈ€μžκΉŒμ§€ μž…λ ₯ κ°€λŠ₯ν•©λ‹ˆλ‹€.") @NotBlank String nickName,
Boolean marketingReceive, @NotBlank String major, @NotBlank String postgradu,
@NotBlank String professor, @NotBlank String lab, @NotBlank String field,
@NotBlank String keyword) {
@NotBlank String keyword, @NotBlank String chatLink) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.postgraduate.domain.payment.domain.entity.Payment;
import com.postgraduate.domain.salary.domain.entity.Salary;
import com.postgraduate.domain.senior.domain.entity.Info;
import com.postgraduate.domain.senior.domain.entity.Profile;
import com.postgraduate.domain.senior.domain.entity.Senior;
import com.postgraduate.domain.user.domain.entity.User;

Expand All @@ -21,7 +20,6 @@ public static ExpectedMentoringInfo mapToExpectedInfo(Mentoring mentoring) {
Senior senior = mentoring.getSenior();
User user = senior.getUser();
Info info = senior.getInfo();
Profile profile = senior.getProfile();
return new ExpectedMentoringInfo(
mentoring.getMentoringId(),
senior.getSeniorId(),
Expand All @@ -32,7 +30,7 @@ public static ExpectedMentoringInfo mapToExpectedInfo(Mentoring mentoring) {
info.getLab(),
mentoring.getDate(),
mentoring.getTerm(),
profile.getChatLink()
info.getChatLink()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public record SeniorProfileRequest(
@NotBlank
String target,
@NotBlank
String chatLink,
@NotBlank
String oneLiner,
@NotEmpty
List<AvailableCreateRequest> times
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,95 +44,73 @@ public static Senior mapToSenior(User user, SeniorChangeRequest request) {
}

private static Info mapToInfo(SeniorSignUpRequest request) {
String[] fields = request.field().split(",");
Set<String> fieldNames = Field.fieldNames();
Set<String> postgraduNames = Postgradu.postgraduNames();

Info.InfoBuilder infoBuilder = Info.builder()
return Info.builder()
.major(request.major())
.postgradu(request.postgradu())
.professor(request.professor())
.lab(request.lab())
.keyword(request.keyword())
.field(request.field())
.etcPostgradu(false)
.etcField(false)
.etcPostgradu(checkEtcPostgradu(request.postgradu()))
.etcField(checkEtcField(request.field()))
.chatLink(request.chatLink())
.totalInfo(request.major() + request.lab() + request.field()
+ request.professor() + request.postgradu() + request.keyword());

for (String field : fields) {
if (!fieldNames.contains(field)) {
infoBuilder.etcField(true);
break;
}
}
if (!postgraduNames.contains(request.postgradu()))
infoBuilder.etcPostgradu(true);

return infoBuilder.build();
+ request.professor() + request.postgradu() + request.keyword())
.build();
}

private static Info mapToInfo(SeniorChangeRequest request) {
String[] fields = request.field().split(",");
Set<String> fieldNames = Field.fieldNames();
Set<String> postgraduNames = Postgradu.postgraduNames();

Info.InfoBuilder infoBuilder = Info.builder()
return Info.builder()
.major(request.major())
.postgradu(request.postgradu())
.professor(request.professor())
.lab(request.lab())
.keyword(request.keyword())
.field(request.field())
.etcPostgradu(false)
.etcField(false)
.etcPostgradu(checkEtcPostgradu(request.postgradu()))
.etcField(checkEtcField(request.field()))
.chatLink(request.chatLink())
.totalInfo(request.major() + request.lab() + request.field()
+ request.professor() + request.postgradu() + request.keyword());

for (String field : fields) {
if (!fieldNames.contains(field)) {
infoBuilder.etcField(true);
break;
}
}
if (!postgraduNames.contains(request.postgradu()))
infoBuilder.etcPostgradu(true);

return infoBuilder.build();
+ request.professor() + request.postgradu() + request.keyword())
.build();
}

public static Info mapToInfo(Senior senior, SeniorMyPageProfileRequest request) {
Info info = senior.getInfo();
String[] fields = request.field().split(",");
Set<String> fieldNames = Field.fieldNames();

Info.InfoBuilder infoBuilder = Info.builder()
return Info.builder()
.major(info.getMajor())
.postgradu(info.getPostgradu())
.professor(info.getProfessor())
.lab(request.lab())
.keyword(request.keyword())
.field(request.field())
.etcPostgradu(false)
.etcField(false)
.etcPostgradu(info.getEtcPostgradu())
.etcField(checkEtcField(request.field()))
.chatLink(request.chatLink())
.totalInfo(info.getMajor() + request.lab() + request.field()
+ info.getProfessor() + info.getPostgradu() + request.keyword());
+ info.getProfessor() + info.getPostgradu() + request.keyword())
.build();
}

private static boolean checkEtcField(String requestField) {
String[] fields = requestField.split(",");
Set<String> fieldNames = Field.fieldNames();
for (String field : fields) {
if (!fieldNames.contains(field)) {
infoBuilder.etcField(true);
break;
}
if (!fieldNames.contains(field))
return true;
}
infoBuilder.etcPostgradu(info.getEtcPostgradu());
return false;
}

return infoBuilder.build();
private static boolean checkEtcPostgradu(String postgradu) {
Set<String> postgraduNames = Postgradu.postgraduNames();
return !postgraduNames.contains(postgradu);
}

public static Profile mapToProfile(SeniorProfileRequest profileRequest) {
return Profile.builder()
.info(profileRequest.info())
.chatLink(profileRequest.chatLink())
.oneLiner(profileRequest.oneLiner())
.target(profileRequest.target())
.build();
Expand All @@ -141,7 +119,6 @@ public static Profile mapToProfile(SeniorProfileRequest profileRequest) {
public static Profile mapToProfile(SeniorMyPageProfileRequest profileRequest) {
return Profile.builder()
.info(profileRequest.info())
.chatLink(profileRequest.chatLink())
.oneLiner(profileRequest.oneLiner())
.target(profileRequest.target())
.build();
Expand All @@ -162,7 +139,7 @@ public static SeniorMyPageProfileResponse mapToMyPageProfile(Senior senior, List
keyword,
profile.getInfo(),
profile.getTarget(),
profile.getChatLink(),
info.getChatLink(),
field,
profile.getOneLiner(),
times
Expand All @@ -178,7 +155,7 @@ public static SeniorMyPageProfileResponse mapToMyPageProfile(Senior senior) {
keyword,
null,
null,
null,
info.getChatLink(),
field,
null,
null
Expand Down Expand Up @@ -213,7 +190,7 @@ public static SeniorDetailResponse mapToSeniorDetail(Senior senior, List<Availab
isMine,
senior.getStatus().equals(APPROVE),
senior.getUser().getNickName(),
profile.getTerm(),
info.getTerm(),
senior.getUser().getProfile(),
info.getPostgradu(),
info.getMajor(),
Expand All @@ -230,7 +207,7 @@ public static SeniorDetailResponse mapToSeniorDetail(Senior senior, List<Availab
isMine,
senior.getStatus().equals(APPROVE),
senior.getUser().getNickName(),
30,
info.getTerm(),
senior.getUser().getProfile(),
info.getPostgradu(),
info.getMajor(),
Expand All @@ -244,16 +221,11 @@ public static SeniorDetailResponse mapToSeniorDetail(Senior senior, List<Availab
);
}

public static SeniorProfileResponse mapToSeniorProfileWithNull(User user, Senior senior) {
public static SeniorProfileResponse mapToSeniorProfile(User user, Senior senior) {
User seniorUser = senior.getUser();
Info info = senior.getInfo();
if (senior.getProfile() != null) {
Profile profile = senior.getProfile();
return new SeniorProfileResponse(seniorUser.getNickName(), seniorUser.getProfile(),
info.getPostgradu(), info.getMajor(), info.getLab(), profile.getTerm(), user.getUserId(), user.getPhoneNumber());
}
return new SeniorProfileResponse(seniorUser.getNickName(), seniorUser.getProfile(),
info.getPostgradu(), info.getMajor(), info.getLab(), 30, user.getUserId(), user.getPhoneNumber());
info.getPostgradu(), info.getMajor(), info.getLab(), info.getTerm(), user.getUserId(), user.getPhoneNumber());
}

public static SeniorSearchResponse mapToSeniorSearchWithStatus(Senior senior) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public AllSeniorSearchResponse getFieldSenior(String field, String postgradu, In
@Transactional(readOnly = true)
public SeniorProfileResponse getSeniorProfile(User user, Long seniorId) {
Senior senior = seniorGetService.bySeniorId(seniorId);
return mapToSeniorProfileWithNull(user, senior);
return mapToSeniorProfile(user, senior);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public class Info {

@Column(nullable = false, columnDefinition = "TEXT")
private String totalInfo; // λͺ¨λ“  Info정보 String으둜 κ°€μ§€λŠ” 컬럼 - κ²€μƒ‰μ‹œ μ‚¬μš©

@Column(columnDefinition = "TEXT")
private String chatLink;

@Builder.Default
private Integer term = 30;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@ public class Profile {

@Column(columnDefinition = "TEXT")
private String target;

@Column(columnDefinition = "TEXT")
private String chatLink;

@Builder.Default
private Integer term = 30;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void mentoringApply(User user) {

public void mentoringAccept(User user, Senior senior, String time) {
bizppurioSend.sendMessageWithExceptionHandling(() -> {
String chatLink = senior.getProfile().getChatLink();
String chatLink = senior.getInfo().getChatLink();
return mapper.mapToJuniorAcceptMessage(user, chatLink, time);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void mentoringApply(User user) {
public void mentoringAccept(Senior senior, String time) {
bizppurioSend.sendMessageWithExceptionHandling(() -> {
User user = senior.getUser();
String chatLink = senior.getProfile().getChatLink();
String chatLink = senior.getInfo().getChatLink();
return mapper.mapToSeniorAcceptMessage(user, chatLink, time);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void singUpSenior() throws Exception {
String request = objectMapper.writeValueAsString(
new SeniorSignUpRequest(anonymousUserSocialId, "01012345678", "μƒˆλ‘œμš΄λ‹‰λ„€μž„",
true, "전곡", "μ„œμšΈλŒ€ν•™κ΅", "ꡐ수", "연ꡬ싀",
"AI", "ν‚€μ›Œλ“œ")
"AI", "ν‚€μ›Œλ“œ", "chatLink")
);

mvc.perform(post("/auth/senior/signup")
Expand All @@ -244,7 +244,7 @@ void singUpSenior() throws Exception {
void singUpSenior(String empty) throws Exception {
String request = objectMapper.writeValueAsString(
new SeniorSignUpRequest(anonymousUserSocialId, "01012345678", "μƒˆλ‘œμš΄λ‹‰λ„€μž„",
true, empty, empty, empty, empty, empty, empty)
true, empty, empty, empty, empty, empty, empty, empty)
);

mvc.perform(post("/auth/senior/signup")
Expand All @@ -262,7 +262,7 @@ void changeSenior() throws Exception {

String request = objectMapper.writeValueAsString(
new SeniorChangeRequest("major", "field", "ꡐ수", "연ꡬ싀",
"AI", "ν‚€μ›Œλ“œ")
"AI", "ν‚€μ›Œλ“œ", "chatLink")
);

mvc.perform(post("/auth/senior/change")
Expand All @@ -284,7 +284,7 @@ void changeSenior(String empty) throws Exception {
String userAccessToken = jwtUtil.generateAccessToken(user.getUserId(), USER);

String request = objectMapper.writeValueAsString(
new SeniorChangeRequest(empty, empty, empty, empty, empty, empty)
new SeniorChangeRequest(empty, empty, empty, empty, empty, empty, empty)
);

mvc.perform(post("/auth/senior/change")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ void setUp() throws IOException {
User userOfSenior = new User(0L, 2L, "mail", "μ„ λ°°", "012", "profile", 0, Role.SENIOR, true, now(), now(), false);
userRepository.save(userOfSenior);

Info info = new Info("major", "μ„œμšΈλŒ€ν•™κ΅", "κ΅μˆ˜λ‹˜", "ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2", "λž©μ‹€", "인곡지λŠ₯", false, false, "인곡지λŠ₯,ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2");
Profile profile = new Profile("μ €λŠ”μš”", "ν•œμ€„μ†Œκ°œ", "λŒ€μƒ", "chatLink", 40);
Info info = new Info("major", "μ„œμšΈλŒ€ν•™κ΅", "κ΅μˆ˜λ‹˜", "ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2", "λž©μ‹€", "인곡지λŠ₯", false, false, "인곡지λŠ₯,ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2", "chatLink", 30);
Profile profile = new Profile("μ €λŠ”μš”", "ν•œμ€„μ†Œκ°œ", "λŒ€μƒ");
senior = new Senior(0L, userOfSenior, "certification", WAITING, 0, info, profile, now(), now());
seniorRepository.save(senior);

Expand Down Expand Up @@ -296,7 +296,7 @@ void getOtherSeniorMentoringDetail() throws Exception {
User otherUser = new User(-1L, 0L, "mail", "λ‹€λ₯Έ ν›„λ°°", "011", "profile", 0, Role.USER, true, now(), now(), false);
userRepository.save(otherUser);

Info info = new Info("major", "μ„œμšΈλŒ€ν•™κ΅", "κ΅μˆ˜λ‹˜", "ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2", "λž©μ‹€", "인곡지λŠ₯", false, false, "인곡지λŠ₯,ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2");
Info info = new Info("major", "μ„œμšΈλŒ€ν•™κ΅", "κ΅μˆ˜λ‹˜", "ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2", "λž©μ‹€", "인곡지λŠ₯", false, false, "인곡지λŠ₯,ν‚€μ›Œλ“œ1,ν‚€μ›Œλ“œ2", "chatLink", 30);
Senior otherSenior = new Senior(-1L, otherUser, "certification", WAITING, 0, info, null, now(), now());
seniorRepository.save(otherSenior);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void setUp() throws IOException {
User user = new User(0L, 1L, "mail", "ν›„λ°°", "011", "profile", 0, Role.SENIOR, true, now(), now(), false);
userRepository.save(user);

Info info = new Info("major", "postgradu", "κ΅μˆ˜λ‹˜", "keyword1,keyword2", "λž©μ‹€", "field", false, false, "field,keyword1,keyword2");
Profile profile = new Profile("μ €λŠ”μš”", "ν•œμ€„μ†Œκ°œ", "λŒ€μƒ", "chatLink", 40);
Info info = new Info("major", "postgradu", "κ΅μˆ˜λ‹˜", "keyword1,keyword2", "λž©μ‹€", "field", false, false, "field,keyword1,keyword2", "chatLink", 30);
Profile profile = new Profile("μ €λŠ”μš”", "ν•œμ€„μ†Œκ°œ", "λŒ€μƒ");
Senior senior = new Senior(0L, user, "certification", Status.APPROVE, 0, info, profile, now(), now());
seniorRepository.save(senior);

Expand Down
Loading
Loading