Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemberDto가 너무 복잡한 문제를 개선한다. #421

Open
2 tasks
gusah009 opened this issue Sep 20, 2022 · 0 comments
Open
2 tasks

MemberDto가 너무 복잡한 문제를 개선한다. #421

gusah009 opened this issue Sep 20, 2022 · 0 comments
Labels
🤝 FE needs 해당 이슈를 해결하기 위해 프론트엔드 팀과 협업해야 함 ❤️ refactor 코드 리팩토링 (기능상 변경이 없어야 함)

Comments

@gusah009
Copy link
Member

사전 수행 issue

없음.

이슈 내용

현재 MemberDto 코드의 상황입니다.

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@JsonInclude(Include.NON_NULL)
public class MemberDto {

  private Long id;
  private String loginId;
  private String emailAddress;
  private String password;
  private String realName;
  private String nickName;
  private String authCode;
  private Date birthday;
  private String studentId;
  private Date registerDate;
  private String followeeLoginId;
  private Integer point;
  private Integer level;
  private String rank;
  private String type;
  private List<String> jobs;
  private String thumbnailPath;
  private Integer merit;
  private Integer demerit;
  private Float generation;

  public MemberEntity toEntity() {
    return MemberEntity.builder()
        .loginId(loginId)
        .password(password)
        .realName(realName)
        .nickName(nickName)
        .emailAddress(emailAddress)
        .studentId(studentId)
        .build();
  }

  public void initWithEntity(MemberEntity memberEntity) {
    // 민감한 정보 제외
    this.id = memberEntity.getId();
    this.loginId = null;//memberEntity.getLoginId();
    this.password = null;//memberEntity.getPassword();
    this.realName = null;//memberEntity.getRealName();
    this.nickName = memberEntity.getNickName();
    this.birthday = memberEntity.getBirthday();
    this.emailAddress = memberEntity.getEmailAddress();
    this.studentId = null;//memberEntity.getStudentId();
    this.registerDate = memberEntity.getRegisterDate();
    this.point = memberEntity.getPoint();
    this.level = memberEntity.getLevel();
    this.merit = memberEntity.getMerit();
    this.demerit = memberEntity.getDemerit();
    this.generation = memberEntity.getGeneration();

    if (memberEntity.getThumbnail() != null) {
      this.thumbnailPath = EnvironmentProperty.getThumbnailPath(
          memberEntity.getThumbnail().getId());
    }
    if (memberEntity.getMemberRank() != null) {
      this.rank = memberEntity.getMemberRank().getName();
    }
    if (memberEntity.getMemberType() != null) {
      this.type = memberEntity.getMemberType().getName();
    }
    if (memberEntity.getMemberJobs() != null || memberEntity.getMemberJobs().isEmpty() == false) {
      this.jobs = new ArrayList<>();
      memberEntity.getMemberJobs()
          .forEach(job ->
              this.jobs.add(job.getMemberJobEntity().getName()));
    }
  }

  public MemberDto(MemberEntity memberEntity) {
    // 민감한 정보 포함
    this.id = memberEntity.getId();
    this.loginId = memberEntity.getLoginId();
    this.password = null;//memberEntity.getPassword();
    this.realName = memberEntity.getRealName();
    this.nickName = memberEntity.getNickName();
    this.birthday = memberEntity.getBirthday();
    this.emailAddress = memberEntity.getEmailAddress();
    this.studentId = memberEntity.getStudentId();
    this.registerDate = memberEntity.getRegisterDate();
    this.point = memberEntity.getPoint();
    this.level = memberEntity.getLevel();
    this.merit = memberEntity.getMerit();
    this.demerit = memberEntity.getDemerit();
    this.generation = memberEntity.getGeneration();

    if (memberEntity.getThumbnail() != null) {
      this.thumbnailPath = EnvironmentProperty.getThumbnailPath(
          memberEntity.getThumbnail().getId());
    }
    if (memberEntity.getMemberRank() != null) {
      this.rank = memberEntity.getMemberRank().getName();
    }
    if (memberEntity.getMemberType() != null) {
      this.type = memberEntity.getMemberType().getName();
    }
    if (memberEntity.getMemberJobs() != null || memberEntity.getMemberJobs().isEmpty() == false) {
      this.jobs = new ArrayList<>();
      memberEntity.getMemberJobs()
          .forEach(job ->
              this.jobs.add(job.getMemberJobEntity().getName()));
    }
  }
}

불필요한 정보까지 클라이언트로 넘겨주고 있으며, Dto 코드 자체도 방대해서 알아보기 힘듭니다.
또, admin/MemberDtouser/MemberDto, common/CommonMemberDto 등 비슷한 Dto가 많습니다.

많은 코드에서 사용하는 MemberDto인 만큼 확실한 체계를 갖추고, 깔끔한 코드를 보여줘야 합니다.

따라서, 권한수준에 따라서 회원 정보를 얼마나 보여줄 지 상의하고 그에 맞게 MemberDto를 수정해야 할 것 같습니다.

  • 권한수준에 따라서 회원 정보를 얼마나 보여줄 지 상의하고, 그에 맞게 MemberDto를 수정한다.
    • ❗️ 해당 작업 수행 과정에서 응답 데이터 형식이나 url이 변경된다면 반드시 프론트엔드에 알리고 함께 수정할 것!!
@gusah009 gusah009 added ❤️ refactor 코드 리팩토링 (기능상 변경이 없어야 함) 🤝 FE needs 해당 이슈를 해결하기 위해 프론트엔드 팀과 협업해야 함 labels Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤝 FE needs 해당 이슈를 해결하기 위해 프론트엔드 팀과 협업해야 함 ❤️ refactor 코드 리팩토링 (기능상 변경이 없어야 함)
Projects
None yet
Development

No branches or pull requests

1 participant