Skip to content

Commit

Permalink
feat: 멤버 아이디 존재 여부 조회 API 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hocaron committed Dec 4, 2023
1 parent 9bd5de5 commit a0dc70e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
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;
Expand All @@ -23,16 +34,6 @@
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
Expand Down Expand Up @@ -217,6 +218,10 @@ public Long getTotalCountByPlatformAndGeneration(
return memberRepository.countActiveByPlatformAndGeneration(platform, generation);
}

public boolean existsIdentification(String identification) {
return memberRepository.existsByIdentification(identification);
}

private void checkAllActiveStatus(List<Member> members) {
for(Member member : members){
if (member.getStatus() != MemberStatus.ACTIVE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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.ExistsResponse;
import kr.mashup.branding.ui.member.response.MemberGenerationsResponse;
import kr.mashup.branding.ui.member.response.MemberInfoResponse;
import kr.mashup.branding.ui.member.response.TokenResponse;
Expand Down Expand Up @@ -131,6 +132,12 @@ public ValidResponse checkDuplicatedIdentification(String identification) {
return ValidResponse.of(!isExist);
}

@Transactional(readOnly = true)
public ExistsResponse existsIdentification(String identification) {
boolean isExist = memberService.existsIdentification(identification);
return ExistsResponse.of(isExist);
}

@Transactional
public Boolean updatePushNotificationAgreed(Long memberId, PushNotificationRequest request) {
Member member = memberService.getActiveOrThrowById(memberId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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.ExistsResponse;
import kr.mashup.branding.ui.member.response.MemberInfoResponse;
import kr.mashup.branding.ui.member.response.TokenResponse;
import kr.mashup.branding.ui.member.response.ValidResponse;
Expand Down Expand Up @@ -120,13 +121,24 @@ public ApiResponse<Boolean> updatePushNotificationAgreed(
return ApiResponse.success(updatePushNotificationAgreedResponse);
}

@ApiOperation("ID 존재 여부 조회")
@GetMapping("{id}/exists")
public ApiResponse<ExistsResponse> existsIdentification(
@PathVariable String id
) {
final ExistsResponse response
= memberFacadeService.existsIdentification(id);

return ApiResponse.success(response);
}

@ApiOperation("비밀번호 변경")
@PutMapping("/{identification}/password")
@PutMapping("/{id}/password")
public ApiResponse<EmptyResponse> changePassword(
@PathVariable String identification,
@PathVariable String id,
@RequestBody MemberPasswordChangeRequest request
){
memberFacadeService.changePassword(identification, request);
memberFacadeService.changePassword(id, request);

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

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(staticName = "of")
public class ExistsResponse {
private boolean exists;
}

0 comments on commit a0dc70e

Please sign in to comment.