-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/#83 멤버관리 api 추가
- Loading branch information
Showing
23 changed files
with
426 additions
and
15 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/main/java/play/pluv/config/ArgumentResolverConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package play.pluv.config; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import play.pluv.login.application.MemberIdArgumentResolver; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class ArgumentResolverConfig implements WebMvcConfigurer { | ||
|
||
private final MemberIdArgumentResolver memberIdArgumentResolver; | ||
|
||
@Override | ||
public void addArgumentResolvers(final List<HandlerMethodArgumentResolver> resolvers) { | ||
resolvers.add(memberIdArgumentResolver); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/play/pluv/member/application/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package play.pluv.member.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import play.pluv.member.domain.NickName; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class MemberService { | ||
|
||
private final MemberUpdater memberUpdater; | ||
|
||
@Transactional | ||
public void updateNickname(final Long memberId, final String nickName) { | ||
memberUpdater.updateNickName(memberId, new NickName(nickName)); | ||
} | ||
|
||
@Transactional | ||
public void unregister(final Long memberId) { | ||
memberUpdater.unregister(memberId); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/play/pluv/member/application/MemberUpdater.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package play.pluv.member.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import play.pluv.member.domain.NickName; | ||
import play.pluv.member.domain.repository.MemberRepository; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class MemberUpdater { | ||
|
||
private final MemberRepository memberRepository; | ||
|
||
public void updateNickName(final Long memberId, final NickName nickName) { | ||
memberRepository.readById(memberId) | ||
.updateNickName(nickName); | ||
} | ||
|
||
public void unregister(final Long memberId) { | ||
memberRepository.deleteById(memberId); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/play/pluv/member/application/dto/UpdateNickNameRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package play.pluv.member.application.dto; | ||
|
||
public record UpdateNickNameRequest(String nickName) { | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/play/pluv/member/controller/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package play.pluv.member.controller; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import play.pluv.base.BaseResponse; | ||
import play.pluv.login.application.dto.JwtMemberId; | ||
import play.pluv.member.application.MemberService; | ||
import play.pluv.member.application.dto.UpdateNickNameRequest; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
public class MemberController { | ||
|
||
private final MemberService memberService; | ||
|
||
@PostMapping("/member/nickname") | ||
public ResponseEntity<BaseResponse<String>> updateNickName( | ||
@Valid @RequestBody final UpdateNickNameRequest updateNickNameRequest, | ||
final JwtMemberId jwtMemberId | ||
) { | ||
memberService.updateNickname(jwtMemberId.memberId(), updateNickNameRequest.nickName()); | ||
return ResponseEntity.ok(BaseResponse.ok("")); | ||
} | ||
|
||
@PostMapping("/member/unregister") | ||
public ResponseEntity<BaseResponse<String>> unregister(final JwtMemberId jwtMemberId) { | ||
memberService.unregister(jwtMemberId.memberId()); | ||
return ResponseEntity.ok(BaseResponse.ok("")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/play/pluv/member/domain/repository/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package play.pluv.member.domain.repository; | ||
|
||
import static play.pluv.member.exception.MemberExceptionType.MEMBER_NOT_FOUND; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import play.pluv.member.domain.Member; | ||
import play.pluv.member.exception.MemberException; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
|
||
default Member readById(final Long id) { | ||
return findById(id).orElseThrow(() -> new MemberException(MEMBER_NOT_FOUND)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.