From 4d3bbd6bb373d7b4363ab6394d145aa597b50e1e Mon Sep 17 00:00:00 2001 From: eunjungL Date: Sun, 30 Jul 2023 01:40:08 +0900 Subject: [PATCH 01/14] =?UTF-8?q?Fix:=20git=20=EC=B6=A9=EB=8F=8C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/request/MemberStatusUpdateRequest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 mashup-admin/src/main/java/kr/mashup/branding/ui/member/request/MemberStatusUpdateRequest.java diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/request/MemberStatusUpdateRequest.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/request/MemberStatusUpdateRequest.java new file mode 100644 index 00000000..56a9c35e --- /dev/null +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/request/MemberStatusUpdateRequest.java @@ -0,0 +1,14 @@ +package kr.mashup.branding.ui.member.request; + +import kr.mashup.branding.domain.member.MemberStatus; +import kr.mashup.branding.domain.member.Platform; +import lombok.Getter; + +import java.util.List; + +@Getter +public class MemberStatusUpdateRequest { + List memberIds; + MemberStatus memberStatus; + Platform platform; +} From 5fb74f0295d643cdb65727cee886ecabe2ad6aad Mon Sep 17 00:00:00 2001 From: eunjungL Date: Sun, 30 Jul 2023 01:40:47 +0900 Subject: [PATCH 02/14] =?UTF-8?q?Fix:=20git=20=EC=B6=A9=EB=8F=8C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../facade/member/MemberFacadeService.java | 44 +++- .../branding/ui/member/MemberController.java | 23 +- .../member/response/MemberDetailResponse.java | 6 +- .../ui/member/response/MemberResponse.java | 2 + .../mashup/branding/domain/member/Member.java | 4 + .../branding/domain/member/MemberStatus.java | 9 +- .../member/MemberGenerationRepository.java | 2 +- .../member/MemberRepositoryCustom.java | 2 +- .../member/MemberRepositoryCustomImpl.java | 4 +- .../service/member/MemberService.java | 71 ++++-- .../domain/application/ApplicationTest.java | 123 ---------- .../domain/attendance/GenerationTest.java | 50 ---- .../domain/attendance/MemberTest.java | 105 -------- .../kr/mashup/branding/util/DateUtilTest.java | 232 ------------------ 14 files changed, 125 insertions(+), 552 deletions(-) delete mode 100644 mashup-domain/src/test/java/kr/mashup/branding/domain/application/ApplicationTest.java delete mode 100644 mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/GenerationTest.java delete mode 100644 mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/MemberTest.java delete mode 100644 mashup-domain/src/test/java/kr/mashup/branding/util/DateUtilTest.java diff --git a/mashup-admin/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java b/mashup-admin/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java index b02c2e70..452c7ba3 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java @@ -8,6 +8,9 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import kr.mashup.branding.domain.member.MemberGeneration; +import kr.mashup.branding.domain.member.MemberStatus; +import kr.mashup.branding.ui.member.request.MemberStatusUpdateRequest; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -37,11 +40,12 @@ public class MemberFacadeService { private final ScoreHistoryService scoreHistoryService; @Transactional(readOnly = true) - public Page getAllActive(Integer generationNumber, Platform platform, String searchName, Pageable pageable) { + public Page getAllNotRun(Integer generationNumber, Platform platform, String searchName, Pageable pageable) { final Generation generation = generationService.getByNumberOrThrow(generationNumber); - final Page queryResults = memberService.getActiveAllByGeneration(generation, platform, searchName, pageable); + final Page queryResults + = memberService.getActiveAllByGeneration(generation, platform, searchName, pageable); final List response = new ArrayList<>(); @@ -53,7 +57,8 @@ public Page getAllActive(Integer generationNumber, Platform plat member.getName(), member.getIdentification(), result.getPlatform().name(), - result.getScore()); + result.getScore(), + member.getStatus()); response.add(memberResponse); } @@ -68,13 +73,18 @@ public MemberDetailResponse getAttendance(Integer generationNumber, Long memberI // 활동점수 히스토리 // 제목, 세미나정보, 등록일시, 점수, 총활동점수, final Generation generation = generationService.getByNumberOrThrow(generationNumber); - final Member member = memberService.getActiveOrThrowById(memberId); + + final Member member = memberService.findMemberById(memberId); + final String memberName = member.getName(); + final String identification = member.getIdentification(); + final Platform platform = memberService.getPlatform(member, generation); - AtomicReference accumulatedScore = new AtomicReference<>(0.0); - List scoreHistories = scoreHistoryService + final AtomicReference accumulatedScore = new AtomicReference<>(0.0); + + final List scoreHistories = scoreHistoryService .getByMemberAndGeneration(member, generation) .stream() .sorted(Comparator.comparingLong(it -> it.getDate().toInstant(ZoneOffset.UTC).getEpochSecond())) @@ -85,21 +95,35 @@ public MemberDetailResponse getAttendance(Integer generationNumber, Long memberI return ScoreHistoryResponse.from(it, accumulatedScore.get()); }) .collect(Collectors.toList()); + Collections.reverse(scoreHistories); - return MemberDetailResponse.of(memberName, identification, generationNumber, platform.name(), scoreHistories); + return MemberDetailResponse.of(memberName, identification, generationNumber, platform.name(), scoreHistories, member.getStatus()); } @Transactional public void resetPassword( - String id, - String newPassword + final String identification, + final String newPassword ) { - memberService.resetPassword(id, newPassword); + memberService.resetPassword(identification, newPassword); } @Transactional public void withdraw(Long memberId) { memberService.deleteMember(memberId); } + + @Transactional + public void updateMemberStatus(Integer generationNumber, MemberStatusUpdateRequest memberStatusUpdateRequest) { + + final Generation generation = generationService.getByNumberOrThrow(generationNumber); + + final MemberStatus memberStatus = memberStatusUpdateRequest.getMemberStatus(); + + final List memberIds = memberStatusUpdateRequest.getMemberIds(); + + List members = memberIds.stream().map(memberService::findMemberById).collect(Collectors.toList()); + memberService.updateStatus(memberStatus, generation, memberStatusUpdateRequest.getPlatform(), members); + } } diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/MemberController.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/MemberController.java index 554d6d08..94e4a805 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/MemberController.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/MemberController.java @@ -2,17 +2,11 @@ import java.util.List; +import kr.mashup.branding.ui.member.request.MemberStatusUpdateRequest; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import io.swagger.annotations.ApiOperation; import kr.mashup.branding.EmptyResponse; @@ -39,7 +33,7 @@ public ApiResponse> getAllByGeneration( @RequestParam(value = "platform", required = false) Platform platform, @RequestParam(value = "searchName", required = false) String searchName ) { - Page response = memberFacadeService.getAllActive(generationNumber, platform, searchName, pageable); + Page response = memberFacadeService.getAllNotRun(generationNumber, platform, searchName, pageable); return ApiResponse.success(response); } @@ -75,4 +69,15 @@ public ApiResponse withdraw( return ApiResponse.success(); } + + @ApiOperation("멤버 상태 변경") + @PostMapping("/status/{generationNumber}") + public ApiResponse updateMemberStatus( + @PathVariable Integer generationNumber, + @RequestBody MemberStatusUpdateRequest memberStatusUpdateRequest + ) { + memberFacadeService.updateMemberStatus(generationNumber, memberStatusUpdateRequest); + + return ApiResponse.success(); + } } diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberDetailResponse.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberDetailResponse.java index 1c767284..7e77a22e 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberDetailResponse.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberDetailResponse.java @@ -1,5 +1,6 @@ package kr.mashup.branding.ui.member.response; +import kr.mashup.branding.domain.member.MemberStatus; import kr.mashup.branding.ui.scorehistory.response.ScoreHistoryResponse; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -17,8 +18,9 @@ public class MemberDetailResponse { private String platform; private List scoreHistoryResponses; private Double totalScore; + private MemberStatus memberStatus; - public static MemberDetailResponse of(String name, String identification, Integer generationNumber, String platform, List scoreHistoryResponses) { - return new MemberDetailResponse(name, identification, generationNumber, platform, scoreHistoryResponses, scoreHistoryResponses.stream().filter(it->!it.getIsCanceled()).mapToDouble(ScoreHistoryResponse::getScore).sum()); + public static MemberDetailResponse of(String name, String identification, Integer generationNumber, String platform, List scoreHistoryResponses, MemberStatus memberStatus) { + return new MemberDetailResponse(name, identification, generationNumber, platform, scoreHistoryResponses, scoreHistoryResponses.stream().filter(it->!it.getIsCanceled()).mapToDouble(ScoreHistoryResponse::getScore).sum(), memberStatus); } } diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberResponse.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberResponse.java index c82c0b43..e6785cc7 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberResponse.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/member/response/MemberResponse.java @@ -1,5 +1,6 @@ package kr.mashup.branding.ui.member.response; +import kr.mashup.branding.domain.member.MemberStatus; import lombok.Getter; import lombok.Value; @@ -11,4 +12,5 @@ public class MemberResponse { private String identification; private String platform; private Double score; + private MemberStatus memberStatus; } diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/Member.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/Member.java index 57b5c564..caf3ac89 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/Member.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/Member.java @@ -155,4 +155,8 @@ public void updatePushNotificationAgreed(Boolean newsPushNotificationAgreed, Boo public void setPassword(String newPassword, PasswordEncoder passwordEncoder) { this.password = passwordEncoder.encode(newPassword); } + + public void setStatus(MemberStatus status) { + this.status = status; + } } diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberStatus.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberStatus.java index b7b3bf2a..02915d3c 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberStatus.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberStatus.java @@ -1,5 +1,12 @@ package kr.mashup.branding.domain.member; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor public enum MemberStatus { - ACTIVE, PENDING, + ACTIVE("활동 중"), + INACTIVE("활동 종료"), + RUN("중도 탈퇴"); + + private final String description; } diff --git a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberGenerationRepository.java b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberGenerationRepository.java index 99dcc2b0..47dd9f5f 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberGenerationRepository.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberGenerationRepository.java @@ -15,7 +15,7 @@ public interface MemberGenerationRepository extends JpaRepository findByMemberAndGeneration(Member member, Generation generation); List findByMember(Member member); List findByGeneration(Generation generation); - + Boolean existsByMemberAndGeneration(Member member, Generation generation); } /** * MemberGeneration 연관관계 diff --git a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustom.java b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustom.java index c892e70d..d1e95dd5 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustom.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustom.java @@ -13,7 +13,7 @@ public interface MemberRepositoryCustom { - Page findAllActiveByGeneration(Generation generation, Platform platform, String searchName, Pageable pageable); + Page findAllNotRunByGeneration(Generation generation, Platform platform, String searchName, Pageable pageable); Long countActiveByPlatformAndGeneration(Platform platform, Generation generation); diff --git a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustomImpl.java b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustomImpl.java index 358b788d..2e9c1e53 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustomImpl.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberRepositoryCustomImpl.java @@ -36,7 +36,7 @@ public class MemberRepositoryCustomImpl implements MemberRepositoryCustom { private final NumberPath sumAlias = Expressions.numberPath(Double.class, "score"); @Override - public Page findAllActiveByGeneration(Generation generation, Platform platform, String searchName, Pageable pageable) { + public Page findAllNotRunByGeneration(Generation generation, Platform platform, String searchName, Pageable pageable) { //기본 정렬은 이름 기준 final Sort sort = pageable.getSortOr(Sort.by(Sort.Direction.ASC, "name")); @@ -47,7 +47,7 @@ public Page findAllActiveByGeneration(Generation generat // 점수가 없는 멤버도 있을 수 있으니 left join, 취소 여부는 on 절에서 판단해서 where 절에서 삭제되지 않게끔 함 .leftJoin(scoreHistory).on(scoreHistory.member.eq(member).and(scoreHistory.generation.eq(generation)).and(scoreHistory.isCanceled.eq(false))) .join(memberGeneration).on(memberGeneration.member.eq(member).and(memberGeneration.generation.eq(generation))) - .where(nameContains(searchName), member.status.eq(MemberStatus.ACTIVE), platformEq(platform)) + .where(nameContains(searchName), member.status.ne(MemberStatus.RUN), platformEq(platform)) .groupBy(member, memberGeneration) .orderBy(getOrderSpecifier(sort)) .offset(pageable.getOffset()) diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java index b2d53dca..702be6d8 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java @@ -77,6 +77,14 @@ public Member save(final MemberCreateDto memberCreateDto) { return member; } + public MemberGeneration saveMemberGeneration(Member member, Generation generation, Platform platform) { + return memberGenerationRepository.save(MemberGeneration.of(member, generation, platform)); + } + + public void deleteMemberGeneration(MemberGeneration memberGeneration) { + memberGenerationRepository.delete(memberGeneration); + } + //2-1. 회원 조회 - active 상태만 public Member getActiveOrThrowById(Long memberId) { @@ -86,11 +94,8 @@ public Member getActiveOrThrowById(Long memberId) { return member; } - public Member getActiveOrThrowByIdentification(String identification) { - final Member member - = memberRepository.findByIdentification(identification).orElseThrow(MemberNotFoundException::new); - checkActiveStatus(member); - return member; + public Member findMemberById(Long memberId) { + return memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); } public boolean isDuplicatedIdentification(String identification) { @@ -117,7 +122,7 @@ public Page getActiveAllByGeneration( Pageable pageable ) { - return memberRepository.findAllActiveByGeneration(generation, platform, searchName, pageable); + return memberRepository.findAllNotRunByGeneration(generation, platform, searchName, pageable); } public List getAllByPlatformAndGeneration( @@ -142,12 +147,6 @@ public Page getAllByPlatformAndGeneration( ); } - //2-2 회원 조회 - pending 상태만 - public Page getPendingMembers(Pageable pageable) { - return memberRepository.findAllByStatus(MemberStatus.PENDING, pageable); - } - - //기수 조회 public List getMemberGenerations(Member member) { return memberGenerationRepository.findByMember(member); @@ -174,11 +173,12 @@ public Member changePassword( } public void resetPassword( - String id, - String newPassword + final String identification, + final String newPassword ){ - final Member member = memberRepository.findByIdentification(id) - .orElseThrow(MemberNotFoundException::new); + final Member member = memberRepository.findByIdentification(identification) + .orElseThrow(MemberNotFoundException::new); + member.setPassword(newPassword,passwordEncoder); } @@ -186,6 +186,7 @@ public Member activate(Long memberId) { final Member member = memberRepository.findById(memberId) .orElseThrow(MemberNotFoundException::new); + member.activate(); return member; @@ -257,6 +258,10 @@ public MemberGeneration findByMemberIdAndGenerationNumber(Long memberId, Integer .orElseThrow(GenerationIntegrityFailException::new); } + public Boolean existMemberGenerationByMemberAndGeneration(Member member, Generation generation) { + return memberGenerationRepository.existsByMemberAndGeneration(member, generation); + } + public List getAllDanggnPushNotiTargetableMembers() { return memberRepository.findAllByCurrentGenerationAt(LocalDate.now()).stream() .filter(Member::getDanggnPushNotificationAgreed) @@ -275,4 +280,38 @@ public Boolean isActiveGeneration(MemberGeneration memberGeneration) { public List findByGeneration(Generation generation) { return memberGenerationRepository.findByGeneration(generation); } + + public void updateStatus(MemberStatus memberStatus, Generation generation, Platform platform, List members) { + switch (memberStatus) { + case ACTIVE: + for (final Member member : members) { + if (!existMemberGenerationByMemberAndGeneration(member, generation)) { // memberGeneration 없으면 생성 + saveMemberGeneration(member, generation, platform); + } + + member.setStatus(memberStatus); + } + break; + case INACTIVE: + for (final Member member : members) { + if (existMemberGenerationByMemberAndGeneration(member, generation)) { // memberGeneration 있을면 삭제 + + final MemberGeneration memberGeneration + = findByMemberIdAndGenerationNumber(member.getId(), generation.getNumber()); + + deleteMemberGeneration(memberGeneration); + } + + member.setStatus(memberStatus); + } + break; + case RUN: + for (final Member member : members) { + member.setStatus(memberStatus); + } + break; + default: + throw new IllegalArgumentException(); + } + } } diff --git a/mashup-domain/src/test/java/kr/mashup/branding/domain/application/ApplicationTest.java b/mashup-domain/src/test/java/kr/mashup/branding/domain/application/ApplicationTest.java deleted file mode 100644 index acd4fdf3..00000000 --- a/mashup-domain/src/test/java/kr/mashup/branding/domain/application/ApplicationTest.java +++ /dev/null @@ -1,123 +0,0 @@ -package kr.mashup.branding.domain.application; - -import java.lang.reflect.Constructor; -import java.time.LocalDate; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; - -import kr.mashup.branding.domain.team.Team; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.function.Executable; -import org.springframework.test.util.ReflectionTestUtils; - -import kr.mashup.branding.domain.applicant.Applicant; -import kr.mashup.branding.domain.application.form.ApplicationForm; -import kr.mashup.branding.domain.application.form.Question; -import kr.mashup.branding.domain.application.form.QuestionRequestVo; -import kr.mashup.branding.domain.application.form.QuestionType; -import kr.mashup.branding.domain.team.CreateTeamVo; - -class ApplicationTest { -// @DisplayName("개인정보처리방침 동의여부가 false 이면 제출시 예외발생") -// @Test -// void submit_throwException_whenPrivacyPolicyIsNotAgreed() throws Exception { -// // given -// Boolean privacyPolicyAgreed = false; -// ApplicationForm applicationForm = createApplicationForm(); -// Application sut = Application.of(createApplicant(), applicationForm); -// ReflectionTestUtils.setField(sut, "privacyPolicyAgreed", false); -// ReflectionTestUtils.setField(sut.getAnswers().get(0), "answerId", 1L); -// ReflectionTestUtils.setField(sut.getAnswers().get(1), "answerId", 2L); -// ReflectionTestUtils.setField(sut.getAnswers().get(2), "answerId", 3L); -// AtomicLong atomicLong = new AtomicLong(); -// ApplicationSubmitRequestVo applicationSubmitRequestVo = ApplicationSubmitRequestVo.of( -// "applicantName", -// "010-1234-1234", -// LocalDate.now(), -// "매쉬업", -// "제주도", -// applicationForm.getQuestions() -// .stream() -// .map(it -> AnswerRequestVo.of(atomicLong.incrementAndGet(), it.getQuestionId(), "answerContent")) -// .collect(Collectors.toList()), -// privacyPolicyAgreed -// ); -// // when -// Executable executable = () -> sut.submit(applicationSubmitRequestVo); -// // then -// Assertions.assertThrows(PrivacyPolicyNotAgreedException.class, executable); -// } -// -// @DisplayName("개인정보처리방침 동의여부가 null 이면 제출시 예외발생") -// @Test -// void submit_throwException_whenPrivacyPolicyIsNull() throws Exception { -// // given -// Boolean privacyPolicyAgreed = null; -// ApplicationForm applicationForm = createApplicationForm(); -// Application sut = Application.of(createApplicant(), applicationForm); -// ReflectionTestUtils.setField(sut, "privacyPolicyAgreed", false); -// ReflectionTestUtils.setField(sut.getAnswers().get(0), "answerId", 1L); -// ReflectionTestUtils.setField(sut.getAnswers().get(1), "answerId", 2L); -// ReflectionTestUtils.setField(sut.getAnswers().get(2), "answerId", 3L); -// AtomicLong atomicLong = new AtomicLong(); -// ApplicationSubmitRequestVo applicationSubmitRequestVo = ApplicationSubmitRequestVo.of( -// "applicantName", -// "010-1234-1234", -// LocalDate.now(), -// "매쉬업", -// "제주도", -// applicationForm.getQuestions() -// .stream() -// .map(it -> AnswerRequestVo.of(atomicLong.incrementAndGet(), it.getQuestionId(), "answerContent")) -// .collect(Collectors.toList()), -// privacyPolicyAgreed -// ); -// // when -// Executable executable = () -> sut.submit(applicationSubmitRequestVo); -// // then -// Assertions.assertThrows(PrivacyPolicyNotAgreedException.class, executable); -// } -// -// private ApplicationForm createApplicationForm() { -// Team teamVo = Team.of(CreateTeamVo.of("teamName")); -// ApplicationForm applicationForm = ApplicationForm.of(teamVo, "applicationFormName"); -// List questions = Arrays.asList( -// Question.of(applicationForm, QuestionRequestVo.of( -// "이름을 입력해 주세요", -// null, -// "ex) 홍길동", -// true, -// QuestionType.SINGLE_LINE_TEXT -// )), -// Question.of(applicationForm, QuestionRequestVo.of( -// "나이를 입력해 주세요", -// null, -// "ex) 25세", -// true, -// QuestionType.SINGLE_LINE_TEXT -// )), -// Question.of(applicationForm, QuestionRequestVo.of( -// "매쉬업에서 이루고자 하는 목표가 있다면 말씀해주세요", -// 500, -// "ex) 앱스토어 1등하는 앱 배포하기", -// false, -// QuestionType.SINGLE_LINE_TEXT -// )) -// ); -// applicationForm.addQuestions(questions); -// ReflectionTestUtils.setField(questions.get(0), "questionId", 1L); -// ReflectionTestUtils.setField(questions.get(1), "questionId", 2L); -// ReflectionTestUtils.setField(questions.get(2), "questionId", 3L); -// return applicationForm; -// } -// -// private Applicant createApplicant() throws Exception { -// Constructor declaredConstructor = Applicant.class.getDeclaredConstructor(); -// declaredConstructor.setAccessible(true); -// return declaredConstructor.newInstance(); -// } -} \ No newline at end of file diff --git a/mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/GenerationTest.java b/mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/GenerationTest.java deleted file mode 100644 index e7ecd850..00000000 --- a/mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/GenerationTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package kr.mashup.branding.domain.attendance; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import java.time.LocalDate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - -@Disabled -class GenerationTest { - -// @Test -// @DisplayName("기수 생성 테스트 - 성공") -// public void createGenerationTest() throws Exception{ -// Generation generation = Generation.of(1, LocalDate.now(), LocalDate.now().plusMonths(6)); -// assertThat(generation.getNumber()).isEqualTo(1); -// } -// -// @Test -// @DisplayName("기수 생성 테스트 - 실패 - 숫자가 0이하인 경우") -// public void createGenerationTestFail1() throws Exception{ -// assertThatIllegalArgumentException().isThrownBy(()->Generation.of(0, LocalDate.now(), LocalDate.now().plusMonths(6))); -// } -// -// @Test -// @DisplayName("기수 생성 테스트 - 실패 - 끝나는 날짜 후 시작하는 경우") -// public void createGenerationTestFail2() throws Exception{ -// assertThatIllegalArgumentException().isThrownBy(()->Generation.of(1, LocalDate.now().plusMonths(6), LocalDate.now())); -// } -// -// @Test -// @DisplayName("기수 생성 테스트 - 실패 - 시작날짜 변경 시 끝나는 날짜 이후인 경우") -// public void createGenerationTestFail3() throws Exception{ -// Generation generation = Generation.of(1, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException().isThrownBy(()->generation.changeStartDate(LocalDate.now().plusMonths(12))); -// } -// -// @Test -// @DisplayName("기수 생성 테스트 - 실패 - 끝나는 날짜 변경 시 시작 날짜 이전인 경우") -// public void createGenerationTestFail4() throws Exception{ -// Generation generation = Generation.of(1, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException().isThrownBy(()->generation.changeEndedDate(LocalDate.now().minusDays(10))); -// } - -} diff --git a/mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/MemberTest.java b/mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/MemberTest.java deleted file mode 100644 index 7b510bc1..00000000 --- a/mashup-domain/src/test/java/kr/mashup/branding/domain/attendance/MemberTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package kr.mashup.branding.domain.attendance; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; - -import java.time.LocalDate; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - -@Disabled -class MemberTest { - -// static final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); -// -// @Test -// @DisplayName("멤버 생성 테스트 - 성공") -// public void createMemberTest1() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// Member member = Member.of("테스트", -// "testtest", -// "test", -// passwordEncoder, -// Team.SPRING, -// generation, -// true); -// -// assertThat(member.getName()).isEqualTo("테스트"); -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 이름이 3글자인 미만인 경우") -// public void createMemberTestFail1() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("테스", "testtest","test", -// passwordEncoder, Team.SPRING, generation, true)); -// -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 이름이 4글자 초과하는 경우") -// public void createMemberTestFail2() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("테스트테스", "testtest", "test", -// passwordEncoder, Team.SPRING, generation, true)); -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 이름이 완성된 한글이 아닌 경우") -// public void createMemberTestFail3() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("ㅌㅅㅌ", "testtest", "test", -// passwordEncoder, Team.SPRING, generation, true)); -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 아이디에 숫자가 들어가는 경우") -// public void createMemberTestFail4() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("테스트", "testtest1", "test", -// passwordEncoder, Team.SPRING, generation, true)); -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 아이디가 5글자 미만인 경우") -// public void createMemberTestFail5() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("테스트", "test", "test", -// passwordEncoder, Team.SPRING, generation, true)); -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 아이디가 15글자 초과인 경우") -// public void createMemberTestFail6() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("테스트", "testtesttesttest", "test", -// passwordEncoder, Team.SPRING, generation, true)); -// } -// -// @Test -// @DisplayName("멤버 생성 테스트 - 실패 - 개인정보 이용 동의하지 않는 경우") -// public void createMemberTestFail7() throws Exception { -// Generation generation = Generation.of(11, LocalDate.now(), LocalDate.now().plusMonths(6)); -// -// assertThatIllegalArgumentException() -// .isThrownBy(() -> Member.of("테스트", "testtesttesttest", "test", -// passwordEncoder, Team.SPRING, generation, false)); -// } - -} diff --git a/mashup-domain/src/test/java/kr/mashup/branding/util/DateUtilTest.java b/mashup-domain/src/test/java/kr/mashup/branding/util/DateUtilTest.java deleted file mode 100644 index b01a3532..00000000 --- a/mashup-domain/src/test/java/kr/mashup/branding/util/DateUtilTest.java +++ /dev/null @@ -1,232 +0,0 @@ -package kr.mashup.branding.util; - - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.Month; - -import static org.assertj.core.api.Assertions.assertThat; - -@Disabled -public class DateUtilTest { - - -// /** -// * isStartBeforeOrEqualEnd Test -// */ -// -// @Test -// @DisplayName("isStartBeforeOrEqualEnd Test - 성공, 끝나는 시간이 시작시간과 같은 경우") -// public void isStartBeforeOrEqualEndTest1(){ -// LocalDateTime startDateTime = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime endDateTime = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// -// boolean isValid = DateUtil.isStartBeforeOrEqualEnd(startDateTime, endDateTime); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isStartBeforeOrEqualEnd Test - 성공, 끝나는 시간이 시작시간과 다른 경우") -// public void isStartBeforeOrEqualEndTest2() { -// LocalDateTime startDateTime = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime endDateTime = LocalDateTime.of(2022, Month.JANUARY, 14, 0, 0); -// -// boolean isValid = DateUtil.isStartBeforeOrEqualEnd(startDateTime, endDateTime); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isStartBeforeOrEqualEnd(LocalDate) Test - 성공, 끝나는 시간이 시작시간과 같은 경우") -// public void isStartBeforeOrEqualEndTest3() { -// LocalDate startDateTime = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate endDateTime = LocalDate.of(2022, Month.JANUARY, 13); -// -// boolean isValid = DateUtil.isStartBeforeOrEqualEnd(startDateTime, endDateTime); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isStartBeforeOrEqualEnd(LocalDate) Test - 성공, 끝나는 시간이 시작시간과 다른 경우") -// public void isStartBeforeOrEqualEndTest4() { -// LocalDate startDateTime = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate endDateTime = LocalDate.of(2022, Month.JANUARY, 14); -// -// boolean isValid = DateUtil.isStartBeforeOrEqualEnd(startDateTime, endDateTime); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isStartBeforeOrEqualEnd Test - 실패, 끝나는 시간이 시작 시간 전인 경우") -// public void isStartBeforeOrEqualEndTestFail1() { -// LocalDateTime startDateTime = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime endDateTime = LocalDateTime.of(2022, Month.JANUARY, 12, 0, 0); -// -// boolean isValid = DateUtil.isStartBeforeOrEqualEnd(startDateTime, endDateTime); -// assertThat(isValid).isFalse(); -// } -// -// @Test -// @DisplayName("isStartBeforeOrEqualEnd(LocalDate) Test - 실패, 끝나는 시간이 시작 시간 전인 경우") -// public void isStartBeforeOrEqualEndTestFail2() { -// LocalDate startDateTime = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate endDateTime = LocalDate.of(2022, Month.JANUARY, 12); -// -// boolean isValid = DateUtil.isStartBeforeOrEqualEnd(startDateTime, endDateTime); -// assertThat(isValid).isFalse(); -// } -// -// /** -// * isContainDateRange Test -// */ -// -// @Test -// @DisplayName("isContainDateRange Test - 성공, 안쪽으로 겹치는 경우") -// public void isContainDateRangeTest1() { -// LocalDateTime baseStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime baseEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// LocalDateTime targetStart = LocalDateTime.of(2022, Month.JANUARY, 14, 0, 0); -// LocalDateTime targetEnd = LocalDateTime.of(2022, Month.JANUARY, 15, 0, 0); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isContainDateRange Test - 성공, 시작 시간이 일치하는 경우") -// public void isContainDateRangeTest2() { -// LocalDateTime baseStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime baseEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// LocalDateTime targetStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime targetEnd = LocalDateTime.of(2022, Month.JANUARY, 15, 0, 0); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isContainDateRange Test - 성공, 끝나는 시간이 일치하는 경우") -// public void isContainDateRangeTest3() { -// LocalDateTime baseStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime baseEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// LocalDateTime targetStart = LocalDateTime.of(2022, Month.JANUARY, 14, 0, 0); -// LocalDateTime targetEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isContainDateRange Test - 실패, 시작시간이 벗어나는 경우") -// public void isContainDateRangeTestFail1() { -// LocalDateTime baseStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime baseEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// LocalDateTime targetStart = LocalDateTime.of(2022, Month.JANUARY, 12, 0, 0); -// LocalDateTime targetEnd = LocalDateTime.of(2022, Month.JANUARY, 15, 0, 0); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isFalse(); -// } -// -// @Test -// @DisplayName("isContainDateRange Test - 실패, 끝나는 시간이 벗어나는 경우") -// public void isContainDateRangeTestFail2() { -// LocalDateTime baseStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime baseEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// LocalDateTime targetStart = LocalDateTime.of(2022, Month.JANUARY, 14, 0, 0); -// LocalDateTime targetEnd = LocalDateTime.of(2022, Month.JANUARY, 17, 0, 0); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isFalse(); -// } -// -// @Test -// @DisplayName("isContainDateRange Test - 실패, 둘 다 벗어나는 경우") -// public void isContainDateRangeTestFail4() { -// LocalDateTime baseStart = LocalDateTime.of(2022, Month.JANUARY, 13, 0, 0); -// LocalDateTime baseEnd = LocalDateTime.of(2022, Month.JANUARY, 16, 0, 0); -// LocalDateTime targetStart = LocalDateTime.of(2022, Month.JANUARY, 11, 0, 0); -// LocalDateTime targetEnd = LocalDateTime.of(2022, Month.JANUARY, 17, 0, 0); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isFalse(); -// } -// -// @Test -// @DisplayName("isContainDateRange(LocalDate) Test - 성공, 안쪽으로 겹치는 경우") -// public void isContainDateRangeTest5() { -// LocalDate baseStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate baseEnd = LocalDate.of(2022, Month.JANUARY, 16); -// LocalDate targetStart = LocalDate.of(2022, Month.JANUARY, 14); -// LocalDate targetEnd = LocalDate.of(2022, Month.JANUARY, 15); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isContainDateRange(LocalDate) Test - 성공, 시작 시간이 일치하는 경우") -// public void isContainDateRangeTest6() { -// LocalDate baseStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate baseEnd = LocalDate.of(2022, Month.JANUARY, 16); -// LocalDate targetStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate targetEnd = LocalDate.of(2022, Month.JANUARY, 15); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isContainDateRange(LocalDate) Test - 성공, 끝나는 시간이 일치하는 경우") -// public void isContainDateRangeTest7() { -// LocalDate baseStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate baseEnd = LocalDate.of(2022, Month.JANUARY, 16); -// LocalDate targetStart = LocalDate.of(2022, Month.JANUARY, 14); -// LocalDate targetEnd = LocalDate.of(2022, Month.JANUARY, 16); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isTrue(); -// } -// -// @Test -// @DisplayName("isContainDateRange(LocalDate) Test - 실패, 시작시간이 벗어나는 경우") -// public void isContainDateRangeTestFail5() { -// LocalDate baseStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate baseEnd = LocalDate.of(2022, Month.JANUARY, 16); -// LocalDate targetStart = LocalDate.of(2022, Month.JANUARY, 12); -// LocalDate targetEnd = LocalDate.of(2022, Month.JANUARY, 15); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isFalse(); -// } -// -// @Test -// @DisplayName("isContainDateRange(LocalDate) Test - 실패, 끝나는 시간이 벗어나는 경우") -// public void isContainDateRangeTestFail6() { -// LocalDate baseStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate baseEnd = LocalDate.of(2022, Month.JANUARY, 16); -// LocalDate targetStart = LocalDate.of(2022, Month.JANUARY, 14); -// LocalDate targetEnd = LocalDate.of(2022, Month.JANUARY, 17); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isFalse(); -// } -// -// @Test -// @DisplayName("isContainDateRange(LocalDate) Test - 실패, 둘 다 벗어나는 경우") -// public void isContainDateRangeTestFail7() { -// LocalDate baseStart = LocalDate.of(2022, Month.JANUARY, 13); -// LocalDate baseEnd = LocalDate.of(2022, Month.JANUARY, 16); -// LocalDate targetStart = LocalDate.of(2022, Month.JANUARY, 11); -// LocalDate targetEnd = LocalDate.of(2022, Month.JANUARY, 17); -// -// boolean isValid = DateUtil.isContainDateRange(baseStart, baseEnd, targetStart, targetEnd); -// assertThat(isValid).isFalse(); -// } - - - -} From 81fb31cdb8c8edb0e6ca441698a5929c273a434e Mon Sep 17 00:00:00 2001 From: kh0712 Date: Sun, 30 Jul 2023 02:39:47 +0900 Subject: [PATCH 03/14] feature: fix admin api (#379) Co-authored-by: KyungHwanKim --- .../adminmember/AdminMemberFacadeService.java | 21 ++++++++++++------- .../ui/adminmember/AdminMemberController.java | 17 +++++++-------- .../ui/adminmember/vo/AdminDeleteRequest.java | 10 +++++++++ .../{ => vo}/AdminPasswordChangeRequest.java | 2 +- .../{ => vo}/AdminPasswordResetRequest.java | 5 ++++- .../adminmember/AdminMemberRepository.java | 7 +++---- .../adminmember/AdminMemberService.java | 17 +++++++++++++++ 7 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminDeleteRequest.java rename mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/{ => vo}/AdminPasswordChangeRequest.java (76%) rename mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/{ => vo}/AdminPasswordResetRequest.java (51%) diff --git a/mashup-admin/src/main/java/kr/mashup/branding/facade/adminmember/AdminMemberFacadeService.java b/mashup-admin/src/main/java/kr/mashup/branding/facade/adminmember/AdminMemberFacadeService.java index 6ebde625..fb7d383e 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/facade/adminmember/AdminMemberFacadeService.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/facade/adminmember/AdminMemberFacadeService.java @@ -3,7 +3,9 @@ import kr.mashup.branding.domain.adminmember.entity.AdminMember; import kr.mashup.branding.domain.adminmember.vo.AdminMemberSignUpCommand; import kr.mashup.branding.domain.adminmember.vo.AdminMemberVo; -import kr.mashup.branding.ui.adminmember.AdminPasswordChangeRequest; +import kr.mashup.branding.ui.adminmember.vo.AdminDeleteRequest; +import kr.mashup.branding.ui.adminmember.vo.AdminPasswordChangeRequest; +import kr.mashup.branding.ui.adminmember.vo.AdminPasswordResetRequest; import org.springframework.stereotype.Service; import kr.mashup.branding.config.jwt.JwtService; @@ -41,13 +43,12 @@ public AdminMemberVo getAdminMember(Long adminMemberId) { @Transactional public void resetPassword( final Long adminMemberId, - final Long targetAdminId, - final String resetPassword) { + final AdminPasswordResetRequest request) { final AdminMember executor = adminMemberService.getByAdminMemberId(adminMemberId); - final AdminMember targetAdmin = adminMemberService.getByAdminMemberId(targetAdminId); + final List targetAdmins = adminMemberService.getByAdminMemberIds(request.getAdminIds()); - adminMemberService.resetPassword(targetAdmin, executor, resetPassword); + adminMemberService.resetPassword(executor, targetAdmins, request.getResetPassword()); } @Transactional public void changePassword(Long adminMemberId, AdminPasswordChangeRequest request) { @@ -58,10 +59,14 @@ public void changePassword(Long adminMemberId, AdminPasswordChangeRequest reques } @Transactional - public void deleteAdminMember(final Long adminMemberId,final Long targetAdminId) { + public void deleteAdminMember( + final Long adminMemberId, + final AdminDeleteRequest request + ) { final AdminMember me = adminMemberService.getByAdminMemberId(adminMemberId); - final AdminMember targetAdmin = adminMemberService.getByAdminMemberId(targetAdminId); - adminMemberService.deleteAdminMember(me, targetAdmin); + final List targetAdmins = adminMemberService.getByAdminMemberIds(request.getAdminIds()); + + targetAdmins.forEach(it -> adminMemberService.deleteAdminMember(me, it)); } @Transactional(readOnly = true) diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminMemberController.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminMemberController.java index 6bbcc0f2..b194d25d 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminMemberController.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminMemberController.java @@ -5,9 +5,7 @@ import kr.mashup.branding.domain.adminmember.vo.AdminLoginCommand; import kr.mashup.branding.domain.adminmember.vo.AdminMemberSignUpCommand; import kr.mashup.branding.domain.adminmember.vo.AdminMemberVo; -import kr.mashup.branding.ui.adminmember.vo.AdminMemberResponse; -import kr.mashup.branding.ui.adminmember.vo.LoginRequest; -import kr.mashup.branding.ui.adminmember.vo.LoginResponse; +import kr.mashup.branding.ui.adminmember.vo.*; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -47,23 +45,22 @@ public ApiResponse getMe( return ApiResponse.success(AdminMemberResponse.from(adminMemberVo)); } - @PostMapping("/{adminId}/password/reset") + @PostMapping("/password/reset") public ApiResponse resetPassword( @ApiIgnore @ModelAttribute("adminMemberId") Long adminMemberId, - @PathVariable("adminId") Long targetAdminId, @RequestBody AdminPasswordResetRequest request ){ - adminMemberFacadeService.resetPassword(adminMemberId, targetAdminId, request.getResetPassword()); + adminMemberFacadeService.resetPassword(adminMemberId, request); return ApiResponse.success(); } - @DeleteMapping("/{adminId}") - public ApiResponse deleteAdminMember( + @DeleteMapping + public ApiResponse deleteAdminMembers( @ApiIgnore @ModelAttribute("adminMemberId") Long adminMemberId, - @PathVariable("adminId") Long targetAdminId + @RequestBody AdminDeleteRequest request ){ - adminMemberFacadeService.deleteAdminMember(adminMemberId, targetAdminId); + adminMemberFacadeService.deleteAdminMember(adminMemberId, request); return ApiResponse.success(); } diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminDeleteRequest.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminDeleteRequest.java new file mode 100644 index 00000000..3e9655ac --- /dev/null +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminDeleteRequest.java @@ -0,0 +1,10 @@ +package kr.mashup.branding.ui.adminmember.vo; + +import lombok.Getter; + +import java.util.List; + +@Getter +public class AdminDeleteRequest { + List adminIds; +} diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminPasswordChangeRequest.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminPasswordChangeRequest.java similarity index 76% rename from mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminPasswordChangeRequest.java rename to mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminPasswordChangeRequest.java index 9b387b49..faae013a 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminPasswordChangeRequest.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminPasswordChangeRequest.java @@ -1,4 +1,4 @@ -package kr.mashup.branding.ui.adminmember; +package kr.mashup.branding.ui.adminmember.vo; import lombok.Getter; diff --git a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminPasswordResetRequest.java b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminPasswordResetRequest.java similarity index 51% rename from mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminPasswordResetRequest.java rename to mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminPasswordResetRequest.java index 53f7032e..748b8c7f 100644 --- a/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/AdminPasswordResetRequest.java +++ b/mashup-admin/src/main/java/kr/mashup/branding/ui/adminmember/vo/AdminPasswordResetRequest.java @@ -1,10 +1,13 @@ -package kr.mashup.branding.ui.adminmember; +package kr.mashup.branding.ui.adminmember.vo; import lombok.Getter; +import java.util.List; + @Getter public class AdminPasswordResetRequest { + private List adminIds; private String resetPassword; } diff --git a/mashup-domain/src/main/java/kr/mashup/branding/repository/adminmember/AdminMemberRepository.java b/mashup-domain/src/main/java/kr/mashup/branding/repository/adminmember/AdminMemberRepository.java index 314e7dae..878e5990 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/repository/adminmember/AdminMemberRepository.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/repository/adminmember/AdminMemberRepository.java @@ -1,5 +1,6 @@ package kr.mashup.branding.repository.adminmember; +import java.util.List; import java.util.Optional; import kr.mashup.branding.domain.adminmember.entity.AdminMember; @@ -9,8 +10,6 @@ public interface AdminMemberRepository extends JpaRepository Optional findByUsername(String username); boolean existsByUsername(String username); + + List findAdminMembersByAdminMemberIdIn(List adminMemberIds); } -/** - * AdminMember 연관관계 - * 없음 - */ diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java index 202b41b2..8fb4148d 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java @@ -65,6 +65,13 @@ public AdminMember getByAdminMemberId(final Long adminMemberId) { return adminMember; } + public List getByAdminMemberIds(final List adminMemberIds) { + + final List adminMembers = adminMemberRepository + .findAdminMembersByAdminMemberIdIn(adminMemberIds); + + return adminMembers; + } private void checkNotDuplicatedUsername(AdminMemberSignUpCommand command) { if (adminMemberRepository.existsByUsername(command.getUsername())) { @@ -89,6 +96,16 @@ public void resetPassword( targetAdmin.setPassword(passwordEncoder,resetPassword); } + public void resetPassword( + final AdminMember executor, + final List targetAdmins, + final String resetPassword) { + + checkLeaderOrSubLeader(executor); + targetAdmins + .forEach(it->it.setPassword(passwordEncoder,resetPassword)); + } + public void changePassword( final AdminMember me, final String currentPassword, From acc60b42688a6655af029245a350752c6c4bab54 Mon Sep 17 00:00:00 2001 From: hocaron Date: Sun, 30 Jul 2023 02:49:40 +0900 Subject: [PATCH 04/14] =?UTF-8?q?feat:=20=EB=8B=B9=EA=B7=BC=20=ED=8C=9D?= =?UTF-8?q?=EC=97=85=20=EB=A6=AC=EC=9B=8C=EB=93=9C=20=EB=A7=88=EC=A7=80?= =?UTF-8?q?=EB=A7=89=20=EB=B3=B8=20=EB=82=A0=EC=A7=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/mashup/branding/service/popup/MemberPopupService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java index 41ecf814..648abd57 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/popup/MemberPopupService.java @@ -33,6 +33,6 @@ public Boolean isEnabledMemberPopup(Member member, PopupType popupType) { } public void save(Member member, PopupType popupType) { - memberPopupRepository.save(MemberPopup.of(true, LocalDateTime.now(), member, popupType)); + memberPopupRepository.save(MemberPopup.of(true, LocalDateTime.now().minusDays(1), member, popupType)); } } From 754e7bbd100a0009b5ac939a770a3efd2c19dec6 Mon Sep 17 00:00:00 2001 From: eunjungL Date: Sun, 30 Jul 2023 02:58:41 +0900 Subject: [PATCH 05/14] =?UTF-8?q?Fix:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EC=9C=A0=EC=A0=80=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdminMemberUsernameDuplicatedException.java | 9 ++++++--- .../branding/service/adminmember/AdminMemberService.java | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/adminmember/exception/AdminMemberUsernameDuplicatedException.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/adminmember/exception/AdminMemberUsernameDuplicatedException.java index 67ca9682..ae7790e2 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/domain/adminmember/exception/AdminMemberUsernameDuplicatedException.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/adminmember/exception/AdminMemberUsernameDuplicatedException.java @@ -1,7 +1,10 @@ package kr.mashup.branding.domain.adminmember.exception; -public class AdminMemberUsernameDuplicatedException extends RuntimeException { - public AdminMemberUsernameDuplicatedException(String message) { - super(message); +import kr.mashup.branding.domain.ResultCode; +import kr.mashup.branding.domain.exception.BadRequestException; + +public class AdminMemberUsernameDuplicatedException extends BadRequestException { + public AdminMemberUsernameDuplicatedException() { + super(ResultCode.ADMIN_MEMBER_USERNAME_DUPLICATED); } } diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java index 8fb4148d..90174735 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/adminmember/AdminMemberService.java @@ -75,8 +75,7 @@ public List getByAdminMemberIds(final List adminMemberIds) { private void checkNotDuplicatedUsername(AdminMemberSignUpCommand command) { if (adminMemberRepository.existsByUsername(command.getUsername())) { - throw new AdminMemberUsernameDuplicatedException( - "이미 사용중인 username 입니다. username: " + command.getUsername()); + throw new AdminMemberUsernameDuplicatedException(); } } From 1163f0d22c99e88dcbea4f71070c5aa9804ac1ce Mon Sep 17 00:00:00 2001 From: alertjjm Date: Wed, 2 Aug 2023 21:42:32 +0900 Subject: [PATCH 06/14] add is running --- .../ui/danggn/response/DanggnRankingRoundsResponse.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundsResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundsResponse.java index 0cfc3a3d..b76d92ba 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundsResponse.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundsResponse.java @@ -1,6 +1,7 @@ package kr.mashup.branding.ui.danggn.response; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; import kr.mashup.branding.domain.danggn.DanggnRankingRound; @@ -25,12 +26,18 @@ public static class DanggnRankingRoundSimpleResponse { LocalDate endDate; + Boolean isRunning; + public static DanggnRankingRoundSimpleResponse from(DanggnRankingRound danggnRankingRound) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startedAt = danggnRankingRound.getStartedAt().toLocalDate().atStartOfDay(); + LocalDateTime endedAt = danggnRankingRound.getEndedAt().toLocalDate().plusDays(1L).atStartOfDay(); return new DanggnRankingRoundSimpleResponse( danggnRankingRound.getId(), danggnRankingRound.getNumber(), danggnRankingRound.getStartedAt().toLocalDate(), - danggnRankingRound.getEndedAt().toLocalDate() + danggnRankingRound.getEndedAt().toLocalDate(), + now.isAfter(startedAt) && now.isBefore(endedAt) ); } } From 6711ea361f61e7cb77a8fcac384e16110be30370 Mon Sep 17 00:00:00 2001 From: alertjjm Date: Wed, 2 Aug 2023 21:53:30 +0900 Subject: [PATCH 07/14] add isrunning --- .../ui/danggn/response/DanggnRankingRoundResponse.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundResponse.java index 21c45425..1230d177 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundResponse.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/danggn/response/DanggnRankingRoundResponse.java @@ -24,13 +24,19 @@ public class DanggnRankingRoundResponse { DanggnRankingRewardResponse danggnRankingReward; + Boolean isRunning; + public static DanggnRankingRoundResponse of(DanggnRankingRound danggnRankingRound, DanggnRankingRewardResponse danggnRankingReward) { + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startedAt = danggnRankingRound.getStartedAt().toLocalDate().atStartOfDay(); + LocalDateTime endedAt = danggnRankingRound.getEndedAt().toLocalDate().plusDays(1L).atStartOfDay(); return new DanggnRankingRoundResponse( danggnRankingRound.getNumber(), danggnRankingRound.getStartedAt(), danggnRankingRound.getEndedAt(), - DateUtil.countDayFromNow(danggnRankingRound.getEndedAt(), LocalDateTime.now()), - danggnRankingReward + DateUtil.countDayFromNow(danggnRankingRound.getEndedAt(), now), + danggnRankingReward, + now.isAfter(startedAt) && now.isBefore(endedAt) ); } From b22b5800258625dbcf2485d234d778b56bdf1f69 Mon Sep 17 00:00:00 2001 From: hocaron Date: Thu, 24 Aug 2023 15:35:04 +0900 Subject: [PATCH 08/14] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=A1=B0=ED=9A=8C=20=EB=B0=8F=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../branding/domain/member/MemberProfile.java | 69 +++++++++++++++++++ .../domain/scorehistory/ScoreHistory.java | 3 - .../member/MemberProfileRepository.java | 11 +++ .../service/member/MemberProfileService.java | 51 ++++++++++++++ .../service/member/MemberService.java | 38 +++++++--- .../facade/member/MemberFacadeService.java | 38 +++++++--- .../member/MemberProfileFacadeService.java | 41 +++++++++++ .../branding/ui/member/MemberController.java | 10 +-- .../ui/member/MemberProfileController.java | 43 ++++++++++++ .../member/request/MemberProfileRequest.java | 29 ++++++++ .../response/MemberProfileResponse.java | 50 ++++++++++++++ 11 files changed, 353 insertions(+), 30 deletions(-) create mode 100644 mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberProfile.java create mode 100644 mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberProfileRepository.java create mode 100644 mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberProfileService.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberProfileRequest.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberProfile.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberProfile.java new file mode 100644 index 00000000..52852d49 --- /dev/null +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberProfile.java @@ -0,0 +1,69 @@ +package kr.mashup.branding.domain.member; + +import kr.mashup.branding.domain.BaseEntity; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.persistence.Entity; +import java.time.LocalDate; + +@Entity +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class MemberProfile extends BaseEntity { + + private LocalDate birthDate; // 생년월일 + + private String job; // 직군 + + private String company; // 회사 + + private String introduction; // 자기소개 + + private String residence; // 거주기 + + private String socialNetworkServiceLink; // 인스타그램 링크 + + private String githubLink; // 깃헙 링크 + + private String portfolioLink; // 비핸스 링크 + + private String blogLink; // 티스토리 링크 + + private String linkedInLink; // 링크드인 링크 + + private Long memberId; + + public static MemberProfile from(Long memberId) { + return new MemberProfile(memberId); + } + + private MemberProfile(Long memberId) { + this.memberId = memberId; + } + + public void update( + LocalDate birthDate, + String job, + String company, + String introduction, + String residence, + String socialNetworkServiceLink, + String githubLink, + String portfolioLink, + String blogLink, + String linkedInLink + ) { + this.birthDate = birthDate; + this.job = job; + this.company = company; + this.introduction = introduction; + this.residence = residence; + this.socialNetworkServiceLink = socialNetworkServiceLink; + this.githubLink = githubLink; + this.portfolioLink = portfolioLink; + this.blogLink = blogLink; + this.linkedInLink = linkedInLink; + } +} diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/scorehistory/ScoreHistory.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/scorehistory/ScoreHistory.java index 62d44d38..358e860e 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/domain/scorehistory/ScoreHistory.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/scorehistory/ScoreHistory.java @@ -14,7 +14,6 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import java.time.LocalDate; import java.time.LocalDateTime; @Entity @@ -82,8 +81,6 @@ public void cancel(String memo){ this.memo = memo; } - - private ScoreHistory(String type, String name, Double score, LocalDateTime date, String scheduleName, Generation generation, Member member, boolean isCanceled, String memo) { this.type = type; diff --git a/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberProfileRepository.java b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberProfileRepository.java new file mode 100644 index 00000000..2c6e615a --- /dev/null +++ b/mashup-domain/src/main/java/kr/mashup/branding/repository/member/MemberProfileRepository.java @@ -0,0 +1,11 @@ +package kr.mashup.branding.repository.member; + +import kr.mashup.branding.domain.member.MemberProfile; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Optional; + +public interface MemberProfileRepository extends JpaRepository { + + Optional findByMemberId(Long memberId); +} diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberProfileService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberProfileService.java new file mode 100644 index 00000000..382ddd9e --- /dev/null +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberProfileService.java @@ -0,0 +1,51 @@ +package kr.mashup.branding.service.member; + +import kr.mashup.branding.domain.member.MemberProfile; +import kr.mashup.branding.repository.member.MemberProfileRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; + +@Service +@Slf4j +@RequiredArgsConstructor +public class MemberProfileService { + + private final MemberProfileRepository memberProfileRepository; + + public void updateOrSave( + Long memberId, + LocalDate birthDate, + String job, + String company, + String introduction, + String residence, + String socialNetworkServiceLink, + String githubLink, + String portfolioLink, + String blogLink, + String linkedInLink + ) { + var profile = memberProfileRepository.findByMemberId(memberId) + .orElseGet(() -> memberProfileRepository.save(MemberProfile.from(memberId))); + profile.update( + birthDate, + job, + company, + introduction, + residence, + socialNetworkServiceLink, + githubLink, + portfolioLink, + blogLink, + linkedInLink + ); + } + + public MemberProfile findOrSave(Long memberId) { + return memberProfileRepository.findByMemberId(memberId) + .orElseGet(() -> memberProfileRepository.save(MemberProfile.from(memberId))); + } +} diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java index 702be6d8..cd0dd90b 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/member/MemberService.java @@ -1,16 +1,5 @@ package kr.mashup.branding.service.member; -import java.time.LocalDate; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - import kr.mashup.branding.domain.ResultCode; import kr.mashup.branding.domain.exception.BadRequestException; import kr.mashup.branding.domain.exception.GenerationIntegrityFailException; @@ -34,6 +23,16 @@ import kr.mashup.branding.util.DateUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; @Service @Slf4j @@ -314,4 +313,21 @@ public void updateStatus(MemberStatus memberStatus, Generation generation, Platf throw new IllegalArgumentException(); } } + + public List findMemberGenerationByMemberId(Member member) { + return memberGenerationRepository.findByMember(member); + } + + public void updateMemberGeneration( + Long memberGenerationId, + String projectTeamName, + String role + ) { + var memberGeneration = memberGenerationRepository.findById(memberGenerationId) + .orElseThrow(GenerationIntegrityFailException::new); + memberGeneration.update( + projectTeamName, + role + ); + } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java b/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java index a59556af..304c6473 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java +++ b/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberFacadeService.java @@ -14,20 +14,15 @@ import kr.mashup.branding.service.invite.InviteService; import kr.mashup.branding.service.member.MemberService; import kr.mashup.branding.service.scorehistory.ScoreHistoryService; -import kr.mashup.branding.ui.member.request.LoginRequest; -import kr.mashup.branding.ui.member.request.PushNotificationRequest; -import kr.mashup.branding.ui.member.request.SignUpRequest; -import kr.mashup.branding.ui.member.request.ValidInviteRequest; -import kr.mashup.branding.ui.member.response.AccessResponse; -import kr.mashup.branding.ui.member.response.MemberInfoResponse; -import kr.mashup.branding.ui.member.response.TokenResponse; -import kr.mashup.branding.ui.member.response.ValidResponse; +import kr.mashup.branding.ui.member.request.*; +import kr.mashup.branding.ui.member.response.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.Comparator; +import java.util.List; @Service @@ -136,6 +131,25 @@ public Boolean updatePushNotificationAgreed(Long memberId, PushNotificationReque return true; } + @Transactional(readOnly = true) + public MemberGenerationsResponse findMemberGenerationByMemberId(Long memberId) { + Member member = memberService.getActiveOrThrowById(memberId); + return MemberGenerationsResponse.of(memberService.findMemberGenerationByMemberId(member)); + } + + @Transactional + public Boolean updateMemberGenerationById( + Long memberId, + Long memberGenerationId, + MemberGenerationRequest request + ) { + Member member = memberService.getActiveOrThrowById(memberId); + checkMemberGenerationIsIn(memberGenerationId, member.getMemberGenerations()); + + memberService.updateMemberGeneration(memberGenerationId, request.getProjectTeamName(), request.getRole()); + return true; + } + private MemberGeneration getLatestMemberGeneration(Member member) { return member.getMemberGenerations().stream().min(Comparator.comparing( memberGeneration -> memberGeneration.getGeneration().getNumber() @@ -146,4 +160,12 @@ private String getToken(Member member) { final MemberGeneration latestMemberGeneration = getLatestMemberGeneration(member); return jwtService.encode(member.getId(), latestMemberGeneration.getId()); } + + private void checkMemberGenerationIsIn(Long memberGenerationId, List memberGenerations) { + var result = memberGenerations.stream() + .anyMatch(memberGeneration -> memberGeneration.getId().equals(memberGenerationId)); + if (!result) { + throw new GenerationIntegrityFailException(); + } + } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java b/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java new file mode 100644 index 00000000..bc02f9b9 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java @@ -0,0 +1,41 @@ +package kr.mashup.branding.facade.member; + +import kr.mashup.branding.service.member.MemberProfileService; +import kr.mashup.branding.ui.member.request.MemberProfileRequest; +import kr.mashup.branding.ui.member.response.MemberProfileResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +public class MemberProfileFacadeService { + + private final MemberProfileService memberProfileService; + + @Transactional + public Boolean updateMyProfile(Long memberId, MemberProfileRequest request) { + memberProfileService.updateOrSave( + memberId, + request.getBirthDate(), + request.getJob(), + request.getCompany(), + request.getIntroduction(), + request.getResidence(), + request.getSocialNetworkServiceLink(), + request.getGithubLink(), + request.getPortfolioLink(), + request.getBlogLink(), + request.getLinkedInLink() + ); + + return true; + } + + @Transactional + public MemberProfileResponse getMyProfile(Long memberId) { + var profile = memberProfileService.findOrSave(memberId); + + return MemberProfileResponse.from(profile); + } +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberController.java index 15680cff..0728a0f7 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberController.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberController.java @@ -1,17 +1,12 @@ package kr.mashup.branding.ui.member; import io.swagger.annotations.ApiOperation; -import kr.mashup.branding.domain.member.Member; import kr.mashup.branding.facade.member.MemberFacadeService; import kr.mashup.branding.security.MemberAuth; -import kr.mashup.branding.service.member.MemberService; import kr.mashup.branding.ui.ApiResponse; -import kr.mashup.branding.ui.member.request.LoginRequest; -import kr.mashup.branding.ui.member.request.SignUpRequest; -import kr.mashup.branding.ui.member.request.ValidInviteRequest; -import kr.mashup.branding.ui.member.response.*; import kr.mashup.branding.ui.EmptyResponse; -import kr.mashup.branding.ui.member.request.PushNotificationRequest; +import kr.mashup.branding.ui.member.request.*; +import kr.mashup.branding.ui.member.response.*; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; @@ -108,5 +103,4 @@ public ApiResponse updatePushNotificationAgreed( return ApiResponse.success(updatePushNotificationAgreedResponse); } - } diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java new file mode 100644 index 00000000..3d30cf39 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java @@ -0,0 +1,43 @@ +package kr.mashup.branding.ui.member; + +import io.swagger.annotations.ApiOperation; +import kr.mashup.branding.facade.member.MemberProfileFacadeService; +import kr.mashup.branding.security.MemberAuth; +import kr.mashup.branding.ui.ApiResponse; +import kr.mashup.branding.ui.member.request.MemberProfileRequest; +import kr.mashup.branding.ui.member.response.MemberProfileResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.validation.Valid; + +@RestController +@RequestMapping("api/v1/member-profiles") +@RequiredArgsConstructor +public class MemberProfileController { + + private final MemberProfileFacadeService memberProfileFacadeService; + @ApiOperation("멤버 프로필 조회") + @GetMapping("/my") + public ApiResponse getMyProfile( + @ApiIgnore MemberAuth memberAuth + ) { + final MemberProfileResponse response + = memberProfileFacadeService.getMyProfile(memberAuth.getMemberId()); + + return ApiResponse.success(response); + } + + @ApiOperation("멤버 프로필 업데이트") + @PatchMapping("/my") + public ApiResponse updateMyProfile( + @ApiIgnore MemberAuth memberAuth, + @Valid @RequestBody MemberProfileRequest request + ) { + final Boolean response + = memberProfileFacadeService.updateMyProfile(memberAuth.getMemberId(), request); + + return ApiResponse.success(response); + } +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberProfileRequest.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberProfileRequest.java new file mode 100644 index 00000000..92749341 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberProfileRequest.java @@ -0,0 +1,29 @@ +package kr.mashup.branding.ui.member.request; + +import lombok.Getter; + +import java.time.LocalDate; + +@Getter +public class MemberProfileRequest { + + private LocalDate birthDate; // 생년월일 + + private String job; // 직군 + + private String company; // 회사 + + private String introduction; // 자기소개 + + private String residence; // 거주기 + + private String socialNetworkServiceLink; // 인스타그램 링크 + + private String githubLink; // 깃헙 링크 + + private String portfolioLink; // 비핸스 링크 + + private String blogLink; // 티스토리 링크 + + private String linkedInLink; // 링크드인 링크 +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java new file mode 100644 index 00000000..57db0351 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java @@ -0,0 +1,50 @@ +package kr.mashup.branding.ui.member.response; + +import kr.mashup.branding.domain.member.MemberProfile; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDate; + +@Getter +@AllArgsConstructor +public class MemberProfileResponse { + + private Long memberId; + + private LocalDate birthDate; // 생년월일 + + private String job; // 직군 + + private String company; // 회사 + + private String introduction; // 자기소개 + + private String residence; // 거주기 + + private String socialNetworkServiceLink; // 인스타그램 링크 + + private String githubLink; // 깃헙 링크 + + private String portfolioLink; // 비핸스 링크 + + private String blogLink; // 티스토리 링크 + + private String linkedInLink; // 링크드인 링크 + + public static MemberProfileResponse from(MemberProfile memberProfile) { + return new MemberProfileResponse( + memberProfile.getMemberId(), + memberProfile.getBirthDate(), + memberProfile.getJob(), + memberProfile.getCompany(), + memberProfile.getIntroduction(), + memberProfile.getResidence(), + memberProfile.getSocialNetworkServiceLink(), + memberProfile.getGithubLink(), + memberProfile.getPortfolioLink(), + memberProfile.getBlogLink(), + memberProfile.getLinkedInLink() + ); + } +} From 5070b3b38cd2b688b34ad6ffb648080de63b0f08 Mon Sep 17 00:00:00 2001 From: hocaron Date: Thu, 24 Aug 2023 15:35:23 +0900 Subject: [PATCH 09/14] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EA=B8=B0?= =?UTF-8?q?=EC=88=98=20=EC=A1=B0=ED=9A=8C=20=EB=B0=8F=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EC=B6=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/MemberGeneration.java | 12 +++++ .../ui/member/MemberGenerationController.java | 44 +++++++++++++++++++ .../request/MemberGenerationRequest.java | 11 +++++ .../response/MemberGenerationResponse.java | 30 +++++++++++++ .../response/MemberGenerationsResponse.java | 22 ++++++++++ 5 files changed, 119 insertions(+) create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberGenerationRequest.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java create mode 100644 mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationsResponse.java diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberGeneration.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberGeneration.java index bce9a596..83d7758c 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberGeneration.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/member/MemberGeneration.java @@ -25,6 +25,10 @@ public class MemberGeneration extends BaseEntity { @Enumerated(EnumType.STRING) private Platform platform; + private String projectTeamName; + + private String role; + public static MemberGeneration of(Member member, Generation generation, Platform platform){ return new MemberGeneration(member, generation, platform); } @@ -37,4 +41,12 @@ private MemberGeneration(Member member, Generation generation, Platform platform this.generation = generation; this.platform = platform; } + + public void update( + String projectTeamName, + String role + ) { + this.projectTeamName = projectTeamName; + this.role = role; + } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java new file mode 100644 index 00000000..0ee46058 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java @@ -0,0 +1,44 @@ +package kr.mashup.branding.ui.member; + +import io.swagger.annotations.ApiOperation; +import kr.mashup.branding.facade.member.MemberFacadeService; +import kr.mashup.branding.security.MemberAuth; +import kr.mashup.branding.ui.ApiResponse; +import kr.mashup.branding.ui.member.request.MemberGenerationRequest; +import kr.mashup.branding.ui.member.response.MemberGenerationsResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.validation.Valid; + +@RestController +@RequestMapping("api/v1/member-generations") +@RequiredArgsConstructor +public class MemberGenerationController { + + private final MemberFacadeService memberFacadeService; + @ApiOperation("멤버 기수 정보 조회") + @GetMapping("/my") + public ApiResponse findMy( + @ApiIgnore MemberAuth memberAuth + ) { + final MemberGenerationsResponse response + = memberFacadeService.findMemberGenerationByMemberId(memberAuth.getMemberId()); + + return ApiResponse.success(response); + } + + @ApiOperation("멤버 기수 정보 업데이트") + @PatchMapping("{id}") + public ApiResponse updateMy( + @ApiIgnore MemberAuth memberAuth, + @PathVariable Long id, + @Valid @RequestBody MemberGenerationRequest request + ) { + final Boolean response + = memberFacadeService.updateMemberGenerationById(memberAuth.getMemberId(), id, request); + + return ApiResponse.success(response); + } +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberGenerationRequest.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberGenerationRequest.java new file mode 100644 index 00000000..3d0588e1 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/request/MemberGenerationRequest.java @@ -0,0 +1,11 @@ +package kr.mashup.branding.ui.member.request; + +import lombok.Getter; + +@Getter +public class MemberGenerationRequest { + + private String projectTeamName; // 프로젝트 팀명 + + private String role; // 역할 +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java new file mode 100644 index 00000000..b212a741 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java @@ -0,0 +1,30 @@ +package kr.mashup.branding.ui.member.response; + +import kr.mashup.branding.domain.member.MemberGeneration; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class MemberGenerationResponse { + + private Long id; // 기수 + + private Integer number; // 기수 + + private String platform; // 플랫폼 + + private String projectTeamName; // 프로젝트 팀 + + private String role; // 역할 + + public static MemberGenerationResponse of(MemberGeneration memberGeneration) { + return new MemberGenerationResponse( + memberGeneration.getId(), + memberGeneration.getGeneration().getNumber(), + memberGeneration.getPlatform().getName(), + memberGeneration.getProjectTeamName(), + memberGeneration.getRole() + ); + } +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationsResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationsResponse.java new file mode 100644 index 00000000..9cb23302 --- /dev/null +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationsResponse.java @@ -0,0 +1,22 @@ +package kr.mashup.branding.ui.member.response; + +import kr.mashup.branding.domain.member.MemberGeneration; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@AllArgsConstructor +public class MemberGenerationsResponse { + + private List memberGenerations; + + public static MemberGenerationsResponse of(List memberGenerations) { + List responses = memberGenerations.stream() + .map(MemberGenerationResponse::of) + .collect(Collectors.toList()); + return new MemberGenerationsResponse(responses); + } +} From 18762c389c33ac0617897ee43be40cf2dc4e935d Mon Sep 17 00:00:00 2001 From: hocaron Date: Fri, 25 Aug 2023 00:30:09 +0900 Subject: [PATCH 10/14] =?UTF-8?q?feat:=20=EA=B8=B0=EC=88=98=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20API=20path?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mashup/branding/ui/member/MemberGenerationController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java index 0ee46058..b61ffac9 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java @@ -30,7 +30,7 @@ public ApiResponse findMy( } @ApiOperation("멤버 기수 정보 업데이트") - @PatchMapping("{id}") + @PatchMapping("/my/{id}") public ApiResponse updateMy( @ApiIgnore MemberAuth memberAuth, @PathVariable Long id, From b09fb1e7ea52d3105bc9f76a9f29d04f1e612514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=98=B8=EC=84=A0=EC=9A=B0?= Date: Fri, 6 Oct 2023 10:54:24 +0900 Subject: [PATCH 11/14] =?UTF-8?q?feat:=20=EA=B8=B0=EC=88=98=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20API=20=EC=97=90=20=EC=83=81=ED=83=9C=EA=B0=92=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mashup/branding/domain/generation/Generation.java | 10 ++++++++++ .../branding/domain/generation/GenerationStatus.java | 7 +++++++ .../ui/member/response/MemberGenerationResponse.java | 6 +++++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 mashup-domain/src/main/java/kr/mashup/branding/domain/generation/GenerationStatus.java diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/Generation.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/Generation.java index c81f1e66..ed062b58 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/Generation.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/Generation.java @@ -72,6 +72,16 @@ public void changeEndedDate(LocalDate newEndedDate){ this.endedAt = newEndedDate; } + public GenerationStatus getStatus(){ + + // 현재 일자 기준으로 기수 종료일자가 미래이거나 같은 경우 + if (DateUtil.isStartBeforeOrEqualEnd(LocalDate.now(), endedAt)) { + return GenerationStatus.ON_GOING; + } + + return GenerationStatus.DONE; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/GenerationStatus.java b/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/GenerationStatus.java new file mode 100644 index 00000000..c5e41ca2 --- /dev/null +++ b/mashup-domain/src/main/java/kr/mashup/branding/domain/generation/GenerationStatus.java @@ -0,0 +1,7 @@ +package kr.mashup.branding.domain.generation; + +public enum GenerationStatus { + ON_GOING, // 진행중 + DONE // 완료 + ; +} diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java index b212a741..0c61853c 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberGenerationResponse.java @@ -1,5 +1,6 @@ package kr.mashup.branding.ui.member.response; +import kr.mashup.branding.domain.generation.GenerationStatus; import kr.mashup.branding.domain.member.MemberGeneration; import lombok.AllArgsConstructor; import lombok.Getter; @@ -18,13 +19,16 @@ public class MemberGenerationResponse { private String role; // 역할 + private GenerationStatus status; // 기수 상태 + public static MemberGenerationResponse of(MemberGeneration memberGeneration) { return new MemberGenerationResponse( memberGeneration.getId(), memberGeneration.getGeneration().getNumber(), memberGeneration.getPlatform().getName(), memberGeneration.getProjectTeamName(), - memberGeneration.getRole() + memberGeneration.getRole(), + memberGeneration.getGeneration().getStatus() ); } } From 59a945aef939c62d357feb0a5b8fc83eebc80047 Mon Sep 17 00:00:00 2001 From: hocaron Date: Thu, 2 Nov 2023 01:11:56 +0900 Subject: [PATCH 12/14] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20id=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attendance/AttendanceFacadeService.java | 29 +++++++++++++------ .../response/PlatformAttendanceResponse.java | 6 ++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/mashup-member/src/main/java/kr/mashup/branding/facade/attendance/AttendanceFacadeService.java b/mashup-member/src/main/java/kr/mashup/branding/facade/attendance/AttendanceFacadeService.java index 8a03bfaf..3e78dac7 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/facade/attendance/AttendanceFacadeService.java +++ b/mashup-member/src/main/java/kr/mashup/branding/facade/attendance/AttendanceFacadeService.java @@ -1,5 +1,19 @@ package kr.mashup.branding.facade.attendance; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import kr.mashup.branding.domain.ResultCode; import kr.mashup.branding.domain.attendance.Attendance; import kr.mashup.branding.domain.attendance.AttendanceCode; @@ -22,17 +36,13 @@ import kr.mashup.branding.service.attendance.AttendanceService; import kr.mashup.branding.service.member.MemberService; import kr.mashup.branding.service.schedule.ScheduleService; -import kr.mashup.branding.ui.attendance.response.*; +import kr.mashup.branding.ui.attendance.response.AttendanceCheckResponse; +import kr.mashup.branding.ui.attendance.response.AttendanceInfo; +import kr.mashup.branding.ui.attendance.response.PersonalAttendanceResponse; +import kr.mashup.branding.ui.attendance.response.PlatformAttendanceResponse; +import kr.mashup.branding.ui.attendance.response.TotalAttendanceResponse; import kr.mashup.branding.util.DateUtil; import lombok.RequiredArgsConstructor; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; -import java.util.*; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor @@ -311,6 +321,7 @@ public PlatformAttendanceResponse getPlatformAttendance( members.stream() .map(member -> PlatformAttendanceResponse.MemberInfo.of( member.getName(), + member.getId(), getAttendanceInfoByMember( member, schedule.getEventList(), diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/attendance/response/PlatformAttendanceResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/attendance/response/PlatformAttendanceResponse.java index 84b0c7c4..0d8d6671 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/attendance/response/PlatformAttendanceResponse.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/attendance/response/PlatformAttendanceResponse.java @@ -1,12 +1,12 @@ package kr.mashup.branding.ui.attendance.response; +import java.util.List; + import io.swagger.annotations.ApiModelProperty; import kr.mashup.branding.domain.member.Platform; import lombok.Getter; import lombok.Value; -import java.util.List; - @Getter @Value(staticConstructor = "of") public class PlatformAttendanceResponse { @@ -20,6 +20,8 @@ public class PlatformAttendanceResponse { public static class MemberInfo { @ApiModelProperty(required = true) String name; + @ApiModelProperty(required = true) + Long memberId; @ApiModelProperty(required = true, notes = "출석 정보가 없을 땐 빈 리스트") List attendanceInfos; } From 106da30e98c52577c53c51d68170d956a79312ad Mon Sep 17 00:00:00 2001 From: hocaron Date: Thu, 2 Nov 2023 01:12:25 +0900 Subject: [PATCH 13/14] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/MemberProfileFacadeService.java | 13 +++++++--- .../ui/member/MemberGenerationController.java | 15 ++++++++--- .../ui/member/MemberProfileController.java | 26 +++++++++++++++---- .../response/MemberProfileResponse.java | 16 +++++++++--- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java b/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java index bc02f9b9..e92b8f58 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java +++ b/mashup-member/src/main/java/kr/mashup/branding/facade/member/MemberProfileFacadeService.java @@ -1,17 +1,21 @@ package kr.mashup.branding.facade.member; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import kr.mashup.branding.domain.member.Member; import kr.mashup.branding.service.member.MemberProfileService; +import kr.mashup.branding.service.member.MemberService; import kr.mashup.branding.ui.member.request.MemberProfileRequest; import kr.mashup.branding.ui.member.response.MemberProfileResponse; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor public class MemberProfileFacadeService { private final MemberProfileService memberProfileService; + private final MemberService memberService; @Transactional public Boolean updateMyProfile(Long memberId, MemberProfileRequest request) { @@ -34,8 +38,11 @@ public Boolean updateMyProfile(Long memberId, MemberProfileRequest request) { @Transactional public MemberProfileResponse getMyProfile(Long memberId) { + Member member = memberService.findMemberById(memberId); + var profile = memberProfileService.findOrSave(memberId); + var generations = memberService.findMemberGenerationByMemberId(member); - return MemberProfileResponse.from(profile); + return MemberProfileResponse.from(profile, generations); } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java index b61ffac9..ec38036e 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberGenerationController.java @@ -1,5 +1,14 @@ package kr.mashup.branding.ui.member; +import javax.validation.Valid; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import io.swagger.annotations.ApiOperation; import kr.mashup.branding.facade.member.MemberFacadeService; import kr.mashup.branding.security.MemberAuth; @@ -7,18 +16,16 @@ import kr.mashup.branding.ui.member.request.MemberGenerationRequest; import kr.mashup.branding.ui.member.response.MemberGenerationsResponse; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; - @RestController @RequestMapping("api/v1/member-generations") @RequiredArgsConstructor public class MemberGenerationController { private final MemberFacadeService memberFacadeService; - @ApiOperation("멤버 기수 정보 조회") + + @ApiOperation("나의 기수 정보 조회") @GetMapping("/my") public ApiResponse findMy( @ApiIgnore MemberAuth memberAuth diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java index 3d30cf39..22c28071 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/MemberProfileController.java @@ -1,5 +1,14 @@ package kr.mashup.branding.ui.member; +import javax.validation.Valid; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import io.swagger.annotations.ApiOperation; import kr.mashup.branding.facade.member.MemberProfileFacadeService; import kr.mashup.branding.security.MemberAuth; @@ -7,18 +16,16 @@ import kr.mashup.branding.ui.member.request.MemberProfileRequest; import kr.mashup.branding.ui.member.response.MemberProfileResponse; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; - @RestController @RequestMapping("api/v1/member-profiles") @RequiredArgsConstructor public class MemberProfileController { private final MemberProfileFacadeService memberProfileFacadeService; - @ApiOperation("멤버 프로필 조회") + + @ApiOperation("나의 프로필 조회") @GetMapping("/my") public ApiResponse getMyProfile( @ApiIgnore MemberAuth memberAuth @@ -29,7 +36,7 @@ public ApiResponse getMyProfile( return ApiResponse.success(response); } - @ApiOperation("멤버 프로필 업데이트") + @ApiOperation("나의 프로필 업데이트") @PatchMapping("/my") public ApiResponse updateMyProfile( @ApiIgnore MemberAuth memberAuth, @@ -40,4 +47,13 @@ public ApiResponse updateMyProfile( return ApiResponse.success(response); } + + @ApiOperation("멤버 프로필 조회") + @GetMapping("/{memberId}") + public ApiResponse getMemberProfile(@PathVariable Long memberId) { + final MemberProfileResponse response + = memberProfileFacadeService.getMyProfile(memberId); + + return ApiResponse.success(response); + } } diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java index 57db0351..51818a87 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/member/response/MemberProfileResponse.java @@ -1,11 +1,14 @@ package kr.mashup.branding.ui.member.response; +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; + +import kr.mashup.branding.domain.member.MemberGeneration; import kr.mashup.branding.domain.member.MemberProfile; import lombok.AllArgsConstructor; import lombok.Getter; -import java.time.LocalDate; - @Getter @AllArgsConstructor public class MemberProfileResponse { @@ -32,7 +35,9 @@ public class MemberProfileResponse { private String linkedInLink; // 링크드인 링크 - public static MemberProfileResponse from(MemberProfile memberProfile) { + private List memberGenerations; + + public static MemberProfileResponse from(MemberProfile memberProfile, List memberGenerations) { return new MemberProfileResponse( memberProfile.getMemberId(), memberProfile.getBirthDate(), @@ -44,7 +49,10 @@ public static MemberProfileResponse from(MemberProfile memberProfile) { memberProfile.getGithubLink(), memberProfile.getPortfolioLink(), memberProfile.getBlogLink(), - memberProfile.getLinkedInLink() + memberProfile.getLinkedInLink(), + memberGenerations.stream() + .map(MemberGenerationResponse::of) + .collect(Collectors.toList()) ); } } From 5345a97b0da5b6973b938bef93b99d4e82a3079b Mon Sep 17 00:00:00 2001 From: hocaron Date: Thu, 2 Nov 2023 01:12:42 +0900 Subject: [PATCH 14/14] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20=EC=A0=90?= =?UTF-8?q?=EC=88=98=20=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScoreHistoryFacadeService.java | 17 ++++++------- .../scorehistory/ScoreHistoryController.java | 24 +++++++++++++++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/mashup-member/src/main/java/kr/mashup/branding/facade/scorehistory/ScoreHistoryFacadeService.java b/mashup-member/src/main/java/kr/mashup/branding/facade/scorehistory/ScoreHistoryFacadeService.java index ca2274f9..a0805e4d 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/facade/scorehistory/ScoreHistoryFacadeService.java +++ b/mashup-member/src/main/java/kr/mashup/branding/facade/scorehistory/ScoreHistoryFacadeService.java @@ -1,19 +1,20 @@ package kr.mashup.branding.facade.scorehistory; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import kr.mashup.branding.domain.member.Member; import kr.mashup.branding.domain.scorehistory.ScoreHistory; import kr.mashup.branding.service.member.MemberService; import kr.mashup.branding.service.scorehistory.ScoreHistoryService; import kr.mashup.branding.ui.scorehistory.response.ScoreHistoryResponse; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; @Service @RequiredArgsConstructor diff --git a/mashup-member/src/main/java/kr/mashup/branding/ui/scorehistory/ScoreHistoryController.java b/mashup-member/src/main/java/kr/mashup/branding/ui/scorehistory/ScoreHistoryController.java index 6803467b..d4e132d8 100644 --- a/mashup-member/src/main/java/kr/mashup/branding/ui/scorehistory/ScoreHistoryController.java +++ b/mashup-member/src/main/java/kr/mashup/branding/ui/scorehistory/ScoreHistoryController.java @@ -1,5 +1,12 @@ package kr.mashup.branding.ui.scorehistory; +import java.util.List; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + import io.swagger.annotations.ApiOperation; import kr.mashup.branding.facade.scorehistory.ScoreHistoryFacadeService; import kr.mashup.branding.security.MemberAuth; @@ -7,13 +14,8 @@ import kr.mashup.branding.ui.scorehistory.response.ScoreHistoriesResponse; import kr.mashup.branding.ui.scorehistory.response.ScoreHistoryResponse; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; -import java.util.List; - @RestController @RequestMapping("/api/v1/score-history") @RequiredArgsConstructor @@ -30,4 +32,16 @@ public ApiResponse getScoreHistory(@ApiIgnore MemberAuth return ApiResponse.success(ScoreHistoriesResponse.of(scoreHistoryResponses)); } + + @ApiOperation("멤버 점수") + @GetMapping("/{memberId}") + public ApiResponse getScore(@PathVariable Long memberId) { + + final ScoreHistoryResponse scoreHistoryResponses + = scoreHistoryFacadeService.getScoreHistory(memberId) + .stream().findFirst() + .orElse(null); + + return ApiResponse.success(scoreHistoryResponses); + } }