Skip to content

Commit

Permalink
Merge pull request #537 from sopt-makers/develop
Browse files Browse the repository at this point in the history
RELEASE 2024/11/06 21:48:00
  • Loading branch information
jun02160 authored Nov 6, 2024
2 parents 49baa82 + 08cd7ef commit d25bb8d
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.sopt.makers.internal.member.service.MemberRetriever;
import org.springframework.stereotype.Service;

import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class SmsChatSender implements MessageSender {
Expand All @@ -20,7 +22,7 @@ public void sendMessage(Member sender, Member receiver, String content, String r
"연결을 원하신다면 멤버의 전화번호로 직접 연락해 주세요.\n\n" +
"- 이름: " + sender.getName() + "\n" +
"- 연락처: " + replyInfo + "\n" +
"- 파트: " + memberRetriever.concatPartAndGeneration(sender.getId()) + "\n" +
"- 파트: " + String.join(", ", memberRetriever.concatPartAndGeneration(sender.getId())) + "\n" +
"- 멤버 프로필 링크: https://playground.sopt.org/members/" + sender.getId() + "\n\n" +
"- 이런 내용이 궁금해요\n" +
content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.sopt.makers.internal.exception.ClientBadRequestException;
import org.sopt.makers.internal.external.MakersCrewClient;
import org.sopt.makers.internal.mapper.MemberMapper;
import org.sopt.makers.internal.member.controller.dto.response.MemberInfoResponse;
import org.sopt.makers.internal.member.mapper.MemberResponseMapper;
import org.sopt.makers.internal.member.service.coffeechat.CoffeeChatService;
import org.sopt.makers.internal.service.MemberService;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -60,6 +62,7 @@ public class MemberController {
private final MemberService memberService;
private final CoffeeChatService coffeeChatService;
private final MemberMapper memberMapper;
private final MemberResponseMapper memberResponseMapper;
private final InfiniteScrollUtil infiniteScrollUtil;
private final MakersCrewClient makersCrewClient;
@Operation(summary = "유저 id로 조회 API")
Expand All @@ -72,11 +75,12 @@ public ResponseEntity<MemberResponse> getMember (@PathVariable Long id) {

@Operation(summary = "자신의 토큰으로 조회 API")
@GetMapping("/me")
public ResponseEntity<MemberResponse> getMyInformation (
public ResponseEntity<MemberInfoResponse> getMyInformation (
@Parameter(hidden = true) @AuthenticationPrincipal InternalMemberDetails memberDetails
) {
val member = memberService.getMemberById(memberDetails.getId());
val response = memberMapper.toResponse(member);
val isCoffeeChatActivate = coffeeChatService.isCoffeeChatExist(member.getId());
val response = memberResponseMapper.toMemberInfoResponse(member, isCoffeeChatActivate);
return ResponseEntity.status(HttpStatus.OK).body(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public record CoffeeChatInfo(

@Schema(required = true)
@NotBlank(message = "커피챗 주제는 필수 입력 값입니다.")
@Size(max = 200, message = "커피챗 주제는 200자를 초과할 수 없습니다.")
@Size(max = 1000, message = "커피챗 주제는 1000자를 초과할 수 없습니다.")
String topic,

@Schema(required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public record CoffeeChatDetailResponse(

String introduction,

List<String> sections,

List<String> topicTypeList,

String topic,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sopt.makers.internal.member.controller.dto.response;

public record MemberInfoResponse(

Long id,

String name,

Integer generation,

String profileImage,

Boolean hasProfile,

Boolean editActivitiesAble,

Boolean hasCoffeeChat
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.sopt.makers.internal.member.mapper;

import lombok.RequiredArgsConstructor;
import org.sopt.makers.internal.domain.Member;
import org.sopt.makers.internal.member.controller.dto.response.MemberInfoResponse;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class MemberResponseMapper {

public MemberInfoResponse toMemberInfoResponse(Member member, Boolean isCoffeeChatActive) {

return new MemberInfoResponse(
member.getId(),
member.getName(),
member.getGeneration(),
member.getProfileImage(),
member.getHasProfile(),
member.getEditActivitiesAble(),
isCoffeeChatActive
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.sopt.makers.internal.member.controller.coffeechat.dto.response.CoffeeChatDetailResponse;
import org.sopt.makers.internal.member.controller.coffeechat.dto.response.CoffeeChatResponse.CoffeeChatVo;
import org.sopt.makers.internal.member.domain.coffeechat.CoffeeChat;
import org.sopt.makers.internal.member.domain.coffeechat.CoffeeChatSection;
import org.sopt.makers.internal.member.domain.coffeechat.CoffeeChatTopicType;
import org.sopt.makers.internal.member.repository.coffeechat.dto.CoffeeChatInfoDto;
import org.sopt.makers.internal.member.repository.coffeechat.dto.RecentCoffeeChatInfoDto;
Expand Down Expand Up @@ -54,6 +55,7 @@ public CoffeeChatDetailResponse toCoffeeChatDetailResponse(CoffeeChat coffeeChat
member.getIsPhoneBlind() ? null : member.getPhone(),
member.getEmail(),
coffeeChat.getIntroduction(),
coffeeChat.getSection().stream().map(CoffeeChatSection::getTitle).toList(),
coffeeChat.getCoffeeChatTopicType().stream().map(CoffeeChatTopicType::getTitle).toList(),
coffeeChat.getTopic(),
coffeeChat.getMeetingType().getTitle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public List<RecentCoffeeChatInfoDto> findRecentCoffeeChatInfo() {
return queryFactory
.select(Projections.constructor(
RecentCoffeeChatInfoDto.class,
coffeeChat.member.id,
member.id,
coffeeChat.coffeeChatBio,
coffeeChat.coffeeChatTopicType,
member.profileImage,
Expand All @@ -41,9 +41,20 @@ public List<RecentCoffeeChatInfoDto> findRecentCoffeeChatInfo() {
member.university,
coffeeChatHistory.createdAt
))
.from(coffeeChat)
.leftJoin(member).on(coffeeChat.member.id.eq(member.id))
.join(coffeeChatHistory).on(coffeeChat.member.id.eq(coffeeChatHistory.receiver.id))
.from(coffeeChatHistory)
.join(coffeeChat).on(
coffeeChatHistory.receiver.id.eq(coffeeChat.member.id)
.and(coffeeChat.isCoffeeChatActivate.eq(true))
)
.join(member).on(coffeeChat.member.id.eq(member.id))
.where(
coffeeChatHistory.createdAt.eq(
JPAExpressions
.select(coffeeChatHistory.createdAt.max())
.from(coffeeChatHistory)
.where(coffeeChatHistory.receiver.id.eq(member.id))
)
)
.orderBy(coffeeChatHistory.createdAt.desc())
.limit(6)
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.RequiredArgsConstructor;
import org.sopt.makers.internal.domain.Member;
import org.sopt.makers.internal.exception.NotFoundDBEntityException;
import org.sopt.makers.internal.member.repository.soptactivity.dto.SoptActivityInfoDto;
import org.sopt.makers.internal.repository.MemberRepository;
import org.sopt.makers.internal.member.repository.soptactivity.MemberSoptActivityRepository;
import org.springframework.stereotype.Component;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public boolean existsCoffeeChat(Member member) {
return coffeeChatRepository.existsCoffeeChatByMember(member);
}

public CoffeeChat findCoffeeChatAndCheckIsActivated(Member member) {
public CoffeeChat findCoffeeChatAndCheckIsActivated(Member member, Boolean isMine) {
return coffeeChatRepository.findCoffeeChatByMember(member)
.filter(coffeeChat -> coffeeChat.getIsCoffeeChatActivate() || coffeeChat.getMember().equals(member))
.filter(coffeeChat -> coffeeChat.getIsCoffeeChatActivate() || isMine)
.orElseThrow(() -> new NotFoundDBEntityException("커피챗 정보를 확인할 수 없는 유저입니다. member id: " + member.getId()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public CoffeeChatDetailResponse getCoffeeChatDetail (Long memberId, Long detailM
memberRetriever.checkExistsMemberById(memberId);

Member member = memberRetriever.findMemberById(detailMemberId);
CoffeeChat coffeeChat = coffeeChatRetriever.findCoffeeChatAndCheckIsActivated(member);
CoffeeChat coffeeChat = coffeeChatRetriever.findCoffeeChatAndCheckIsActivated(member, memberId.equals(detailMemberId));
MemberCareer memberCareer = memberCareerRetriever.findMemberLastCareerByMemberId(detailMemberId);
Boolean isMine = Objects.equals(memberId, detailMemberId);
return coffeeChatResponseMapper.toCoffeeChatDetailResponse(coffeeChat, member, memberCareer, isMine);
Expand All @@ -89,6 +89,12 @@ public Boolean getCoffeeChatActivate (Long memberId) {
}
}

@Transactional(readOnly = true)
public Boolean isCoffeeChatExist (Long memberId) {
Member member = memberRetriever.findMemberById(memberId);
return coffeeChatRetriever.existsCoffeeChat(member);
}

@Transactional
public void updateCoffeeChatOpen(Long memberId, CoffeeChatOpenRequest request) {
Member member = memberRetriever.findMemberById(memberId);
Expand Down

0 comments on commit d25bb8d

Please sign in to comment.