Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hocaron committed Nov 11, 2023
2 parents c9418f4 + 2747dd7 commit 2c6eb27
Show file tree
Hide file tree
Showing 45 changed files with 785 additions and 636 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<AdminMember> targetAdmins = adminMemberService.getByAdminMemberIds(request.getAdminIds());

adminMemberService.resetPassword(targetAdmin, executor, resetPassword);
adminMemberService.resetPassword(executor, targetAdmins, request.getResetPassword());
}
@Transactional
public void changePassword(Long adminMemberId, AdminPasswordChangeRequest request) {
Expand All @@ -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<AdminMember> targetAdmins = adminMemberService.getByAdminMemberIds(request.getAdminIds());

targetAdmins.forEach(it -> adminMemberService.deleteAdminMember(me, it));
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -37,11 +40,12 @@ public class MemberFacadeService {
private final ScoreHistoryService scoreHistoryService;

@Transactional(readOnly = true)
public Page<MemberResponse> getAllActive(Integer generationNumber, Platform platform, String searchName, Pageable pageable) {
public Page<MemberResponse> getAllNotRun(Integer generationNumber, Platform platform, String searchName, Pageable pageable) {

final Generation generation = generationService.getByNumberOrThrow(generationNumber);

final Page<MemberScoreQueryResult> queryResults = memberService.getActiveAllByGeneration(generation, platform, searchName, pageable);
final Page<MemberScoreQueryResult> queryResults
= memberService.getActiveAllByGeneration(generation, platform, searchName, pageable);

final List<MemberResponse> response = new ArrayList<>();

Expand All @@ -53,7 +57,8 @@ public Page<MemberResponse> getAllActive(Integer generationNumber, Platform plat
member.getName(),
member.getIdentification(),
result.getPlatform().name(),
result.getScore());
result.getScore(),
member.getStatus());

response.add(memberResponse);
}
Expand All @@ -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<Double> accumulatedScore = new AtomicReference<>(0.0);

List<ScoreHistoryResponse> scoreHistories = scoreHistoryService
final AtomicReference<Double> accumulatedScore = new AtomicReference<>(0.0);

final List<ScoreHistoryResponse> scoreHistories = scoreHistoryService
.getByMemberAndGeneration(member, generation)
.stream()
.sorted(Comparator.comparingLong(it -> it.getDate().toInstant(ZoneOffset.UTC).getEpochSecond()))
Expand All @@ -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<Long> memberIds = memberStatusUpdateRequest.getMemberIds();

List<Member> members = memberIds.stream().map(memberService::findMemberById).collect(Collectors.toList());
memberService.updateStatus(memberStatus, generation, memberStatusUpdateRequest.getPlatform(), members);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;

Expand Down Expand Up @@ -47,23 +45,22 @@ public ApiResponse<AdminMemberResponse> getMe(
return ApiResponse.success(AdminMemberResponse.from(adminMemberVo));
}

@PostMapping("/{adminId}/password/reset")
@PostMapping("/password/reset")
public ApiResponse<EmptyResponse> 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<EmptyResponse> deleteAdminMember(
@DeleteMapping
public ApiResponse<EmptyResponse> deleteAdminMembers(
@ApiIgnore @ModelAttribute("adminMemberId") Long adminMemberId,
@PathVariable("adminId") Long targetAdminId
@RequestBody AdminDeleteRequest request
){
adminMemberFacadeService.deleteAdminMember(adminMemberId, targetAdminId);
adminMemberFacadeService.deleteAdminMember(adminMemberId, request);

return ApiResponse.success();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package kr.mashup.branding.ui.adminmember.vo;

import lombok.Getter;

import java.util.List;

@Getter
public class AdminDeleteRequest {
List<Long> adminIds;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.mashup.branding.ui.adminmember;
package kr.mashup.branding.ui.adminmember.vo;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Long> adminIds;
private String resetPassword;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,7 +33,7 @@ public ApiResponse<List<MemberResponse>> getAllByGeneration(
@RequestParam(value = "platform", required = false) Platform platform,
@RequestParam(value = "searchName", required = false) String searchName
) {
Page<MemberResponse> response = memberFacadeService.getAllActive(generationNumber, platform, searchName, pageable);
Page<MemberResponse> response = memberFacadeService.getAllNotRun(generationNumber, platform, searchName, pageable);

return ApiResponse.success(response);
}
Expand Down Expand Up @@ -75,4 +69,15 @@ public ApiResponse<EmptyResponse> withdraw(

return ApiResponse.success();
}

@ApiOperation("멤버 상태 변경")
@PostMapping("/status/{generationNumber}")
public ApiResponse<EmptyResponse> updateMemberStatus(
@PathVariable Integer generationNumber,
@RequestBody MemberStatusUpdateRequest memberStatusUpdateRequest
) {
memberFacadeService.updateMemberStatus(generationNumber, memberStatusUpdateRequest);

return ApiResponse.success();
}
}
Original file line number Diff line number Diff line change
@@ -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<Long> memberIds;
MemberStatus memberStatus;
Platform platform;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,8 +18,9 @@ public class MemberDetailResponse {
private String platform;
private List<ScoreHistoryResponse> scoreHistoryResponses;
private Double totalScore;
private MemberStatus memberStatus;

public static MemberDetailResponse of(String name, String identification, Integer generationNumber, String platform, List<ScoreHistoryResponse> 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<ScoreHistoryResponse> scoreHistoryResponses, MemberStatus memberStatus) {
return new MemberDetailResponse(name, identification, generationNumber, platform, scoreHistoryResponses, scoreHistoryResponses.stream().filter(it->!it.getIsCanceled()).mapToDouble(ScoreHistoryResponse::getScore).sum(), memberStatus);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.mashup.branding.ui.member.response;

import kr.mashup.branding.domain.member.MemberStatus;
import lombok.Getter;
import lombok.Value;

Expand All @@ -11,4 +12,5 @@ public class MemberResponse {
private String identification;
private String platform;
private Double score;
private MemberStatus memberStatus;
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package kr.mashup.branding.domain.generation;

public enum GenerationStatus {
ON_GOING, // 진행중
DONE // 완료
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
}
}
Loading

0 comments on commit 2c6eb27

Please sign in to comment.