Skip to content

Commit

Permalink
Merge pull request #288 from CaZaIt/refactor_master
Browse files Browse the repository at this point in the history
[Chore] #268 - Master DTO 네이밍 변경
  • Loading branch information
inpyu authored Jun 22, 2023
2 parents 369d70a + 753d704 commit 805a83d
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import shop.cazait.domain.master.dto.patch.PatchMasterReq;
import shop.cazait.domain.master.dto.post.PostMasterReq;
import shop.cazait.domain.master.dto.post.PostMasterRes;
import shop.cazait.domain.master.dto.request.MasterCreateInDTO;
import shop.cazait.domain.master.dto.request.MasterUpdateInDTO;
import shop.cazait.domain.master.dto.response.MasterCreateOutDTO;
import shop.cazait.domain.master.error.MasterException;
import shop.cazait.domain.master.service.MasterService;
import shop.cazait.domain.user.exception.UserException;
Expand All @@ -49,15 +49,15 @@ public class MasterController {
@NoAuth
@PostMapping("/sign-up")
@Operation(summary = "마스터 회원가입", description = "마스터 사용자의 정보들을 이용해서 회원가입을 진행한다.")
public SuccessResponse<PostMasterRes> registerMaster(@Validated @RequestBody PostMasterReq dto) throws
public SuccessResponse<MasterCreateOutDTO> registerMaster(@Validated @RequestBody MasterCreateInDTO dto) throws
MasterException,
InvalidAlgorithmParameterException,
NoSuchPaddingException,
IllegalBlockSizeException,
NoSuchAlgorithmException,
BadPaddingException,
InvalidKeyException {
PostMasterRes postCreateMasterRes = masterService.registerMaster(dto);
MasterCreateOutDTO postCreateMasterRes = masterService.registerMaster(dto);
return new SuccessResponse<>(CREATE_MASTER, postCreateMasterRes);
}

Expand All @@ -69,10 +69,10 @@ public SuccessResponse<PostMasterRes> registerMaster(@Validated @RequestBody Pos
)
public SuccessResponse<String> updateMaster(
@PathVariable(name = "masterId") Long masterId,
@RequestBody @Valid PatchMasterReq patchMasterReq,
@RequestBody @Valid MasterUpdateInDTO masterUpdateInDTO,
@RequestHeader(value = "REFRESH-TOKEN") String refreshToken) throws UserException {
jwtService.isValidAccessTokenId(masterId);
masterService.updateMaster(masterId, patchMasterReq);
masterService.updateMaster(masterId, masterUpdateInDTO);
return new SuccessResponse<>(SUCCESS, "마스터 정보 수정 완료");
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package shop.cazait.domain.master.dto.post;
package shop.cazait.domain.master.dto.request;

import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
Expand All @@ -20,7 +20,7 @@
@Schema(description = "마스터 정보 Request : 회원 가입에 필요한 마스터 정보")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class PostMasterReq {
public class MasterCreateInDTO {

@NotBlank(message = "Master 이메일을 입력해주세요.")
@Schema(description = "이메일", example = "[email protected]")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package shop.cazait.domain.master.dto.patch;
package shop.cazait.domain.master.dto.request;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
Expand All @@ -11,7 +11,7 @@
@Schema(description = "마스터 수정 Request : 수정할 마스터 계정 정보")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class PatchMasterReq {
public class MasterUpdateInDTO {

@Schema(description = "Master 이메일")
@NotBlank(message = "수정하고자 하는 마스터 계정의 이메일을 입력해주세요.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package shop.cazait.domain.master.dto.post;
package shop.cazait.domain.master.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
Expand All @@ -9,7 +9,7 @@
@Schema(description = "마스터 정보 Response : 회원 가입한 마스터 계정 정보")
@Getter
@Builder(access = AccessLevel.PRIVATE)
public class PostMasterRes {
public class MasterCreateOutDTO {

@Schema(description = "마스터 계정 ID")
private Long id;
Expand All @@ -20,8 +20,8 @@ public class PostMasterRes {
@Schema(description = "마스터 계정 이름")
private String nickname;

static public PostMasterRes of(Master master) {
return PostMasterRes.builder()
static public MasterCreateOutDTO of(Master master) {
return MasterCreateOutDTO.builder()
.id(master.getId())
.email(master.getEmail())
.nickname(master.getNickname())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package shop.cazait.domain.master.dto.get;
package shop.cazait.domain.master.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
Expand All @@ -9,7 +9,7 @@
@Schema(description = "마스터 조회 Response : 마스터 계정 정보")
@Getter
@Builder(access = AccessLevel.PRIVATE)
public class GetMasterRes {
public class MasterListOutDTO {
@Schema(description = "마스터 계정 ID")
private Long id;

Expand All @@ -19,8 +19,8 @@ public class GetMasterRes {
@Schema(description = "마스터 계정 이름")
private String nickname;

public static GetMasterRes of(Master master) {
return GetMasterRes.builder()
public static MasterListOutDTO of(Master master) {
return MasterListOutDTO.builder()
.id(master.getId())
.email(master.getEmail())
.nickname(master.getNickname())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package shop.cazait.domain.master.dto.patch;
package shop.cazait.domain.master.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;

@Schema(description = "마스터 수정 Response : 수정한 마스터 계정 정보")
@Getter
@Builder
public class PatchMasterRes {
public class MasterUptateOutDTO {

@Schema(description = "마스터 계정 ID")
private Long id;
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/shop/cazait/domain/master/service/MasterService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import lombok.extern.slf4j.Slf4j;
import shop.cazait.domain.auth.dto.PostLoginReq;
import shop.cazait.domain.auth.dto.PostLoginRes;
import shop.cazait.domain.master.dto.get.GetMasterRes;
import shop.cazait.domain.master.dto.patch.PatchMasterReq;
import shop.cazait.domain.master.dto.patch.PatchMasterRes;
import shop.cazait.domain.master.dto.post.PostMasterReq;
import shop.cazait.domain.master.dto.post.PostMasterRes;
import shop.cazait.domain.master.dto.request.MasterCreateInDTO;
import shop.cazait.domain.master.dto.request.MasterUpdateInDTO;
import shop.cazait.domain.master.dto.response.MasterCreateOutDTO;
import shop.cazait.domain.master.dto.response.MasterListOutDTO;
import shop.cazait.domain.master.dto.response.MasterUptateOutDTO;
import shop.cazait.domain.master.entity.Master;
import shop.cazait.domain.master.error.MasterException;
import shop.cazait.domain.master.repository.MasterRepository;
Expand All @@ -46,7 +46,7 @@ public class MasterService {
/**
* 마스터 회원 가입
*/
public PostMasterRes registerMaster(PostMasterReq dto) throws
public MasterCreateOutDTO registerMaster(MasterCreateInDTO dto) throws
MasterException,
InvalidAlgorithmParameterException,
NoSuchPaddingException,
Expand All @@ -68,7 +68,7 @@ public PostMasterRes registerMaster(PostMasterReq dto) throws
Master master = dto.toEntity();
masterRepository.save(master);

return PostMasterRes.of(master);
return MasterCreateOutDTO.of(master);

}

Expand Down Expand Up @@ -116,11 +116,11 @@ public PostLoginRes LoginMaster(PostLoginReq dto) throws

//마스터 회원 전체 조회
@Transactional(readOnly = true)
public List<GetMasterRes> getMasterByStatus(BaseStatus status) throws MasterException {
public List<MasterListOutDTO> getMasterByStatus(BaseStatus status) throws MasterException {
List<Master> masterList = masterRepository.findMasterByStatus(status);
List<GetMasterRes> masterResList = new ArrayList<>();
List<MasterListOutDTO> masterResList = new ArrayList<>();
for (Master master : masterList) {
GetMasterRes masterRes = GetMasterRes.of(master);
MasterListOutDTO masterRes = MasterListOutDTO.of(master);
masterResList.add(masterRes);
}
if (masterResList.isEmpty()) {
Expand All @@ -130,10 +130,10 @@ public List<GetMasterRes> getMasterByStatus(BaseStatus status) throws MasterExce
}

//마스터 회원 정보 업데이트
public PatchMasterRes updateMaster(Long id, PatchMasterReq patchMasterReq) {
public MasterUptateOutDTO updateMaster(Long id, MasterUpdateInDTO masterUpdateInDTO) {
Master findMaster = masterRepository.findMasterById(id).get();
Master updateMaster = masterRepository.save(findMaster);
return PatchMasterRes.builder()
return MasterUptateOutDTO.builder()
.id(updateMaster.getId())
.email(updateMaster.getEmail())
.password(updateMaster.getPassword())
Expand Down

0 comments on commit 805a83d

Please sign in to comment.