Skip to content

Commit

Permalink
Merge pull request #40 from SOPT-SOPHY/refactor/refactoring-codes
Browse files Browse the repository at this point in the history
Refactor/refactoring codes
  • Loading branch information
onpyeong authored Jul 11, 2023
2 parents 2f6777e + 882a36b commit 7b71198
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ public class MemberController {

@GetMapping("/my-page/{memberId}")
@ResponseStatus(HttpStatus.OK)
public ApiResponseDto<MyPageDto> getMyPage(@PathVariable("memberId") long memberId) {
public ApiResponseDto<MyPageDto> getMyPage(@PathVariable("memberId") Long memberId) {
return ApiResponseDto.success(SuccessStatus.GET_MYPAGE_SUCCESS, memberService.getMyPage(memberId));
}

@GetMapping("/my-info/{memberId}")
@ResponseStatus(HttpStatus.OK)
public ApiResponseDto<MyInfoDto> getInfo(@PathVariable("memberId") long memberId) {
public ApiResponseDto<MyInfoDto> getInfo(@PathVariable("memberId") Long memberId) {
return ApiResponseDto.success(SuccessStatus.GET_MYPAGE_SUCCESS, memberService.getMyInfo(memberId));
}

@PostMapping("/my-info/{memberId}")
@ResponseStatus(HttpStatus.OK)
public ApiResponseDto<MemberAdditionalInfoDto> postAdditionalInfo(@PathVariable("memberId") long memberId, @RequestBody MemberAdditionalInfoDto memberAdditionalInfoDto) {
public ApiResponseDto<MemberAdditionalInfoDto> postAdditionalInfo(@PathVariable("memberId") Long memberId, @RequestBody MemberAdditionalInfoDto memberAdditionalInfoDto) {
return ApiResponseDto.success(SuccessStatus.POST_ADDITIONALINFO_SUCCESS, memberService.postAdditionalInfo(memberId, memberAdditionalInfoDto));
}

@PatchMapping("/my-info/{memberId}")
@ResponseStatus(HttpStatus.OK)
public ApiResponseDto<MyInfoDto> patchInfo(@PathVariable("memberId") long memberId, @RequestBody MyInfoDto myInfoDto) {
public ApiResponseDto<MyInfoDto> patchInfo(@PathVariable("memberId") Long memberId, @RequestBody MyInfoDto myInfoDto) {
return ApiResponseDto.success(SuccessStatus.PATCH_MYINFO_SUCCESS, memberService.patchMyInfo(memberId, myInfoDto));
}
}
7 changes: 2 additions & 5 deletions src/main/java/org/sophy/sophy/domain/Author.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package org.sophy.sophy.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

import javax.persistence.*;
import java.util.List;

@Entity
@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@Builder
public class Author {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/sophy/sophy/domain/Booktalk.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Booktalk extends AuditingTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "booktalk_id")
private long id;
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/org/sophy/sophy/domain/Member.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.sophy.sophy.domain;

import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;
import org.sophy.sophy.controller.dto.request.MemberAdditionalInfoDto;
import org.sophy.sophy.domain.dto.MyInfoDto;

Expand All @@ -13,7 +11,7 @@

@Entity
@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Member extends AuditingTimeEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -38,13 +36,13 @@ public class Member extends AuditingTimeEntity{

private City myCity;

private boolean marketingAgree;
private Boolean marketingAgree;

@Column(nullable = false)
private boolean isAuthor;
private Boolean isAuthor;

@Column(nullable = false)
private boolean isOperator;
private Boolean isOperator;

@Enumerated(EnumType.STRING)
private Authority authority;
Expand Down Expand Up @@ -95,6 +93,6 @@ public void patchMyInfo(MyInfoDto myInfoDto) {
this.gender = myInfoDto.getGender();
this.birth = myInfoDto.getBirth();
this.myCity = myInfoDto.getCity();
this.marketingAgree = myInfoDto.isMarketingAgree();
this.marketingAgree = myInfoDto.getMarketingAgree();
}
}
3 changes: 2 additions & 1 deletion src/main/java/org/sophy/sophy/domain/MemberBooktalk.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sophy.sophy.domain;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -8,7 +9,7 @@

@Entity
@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MemberBooktalk extends AuditingTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/sophy/sophy/domain/Place.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sophy.sophy.domain;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -10,11 +11,11 @@

@Entity
@Getter
@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Place extends AuditingTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private Long id;

private City city;

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/sophy/sophy/domain/dto/MyInfoDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.sophy.sophy.domain.City;

import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MyInfoDto {
@Email(message = "이메일 형식에 맞지 않습니다.")
Expand All @@ -23,5 +21,5 @@ public class MyInfoDto {
private String gender;
private String birth;
private City city;
private boolean marketingAgree;
private Boolean marketingAgree;
}
2 changes: 0 additions & 2 deletions src/main/java/org/sophy/sophy/domain/dto/MyPageDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class MyPageDto {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/sophy/sophy/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class MemberService {
public MyPageDto getMyPage(Long memberId) {
Member member = getMemberById(memberId);
//여기에 추가로 member에 있는 userBookTalk 리스트를 시간순으로 정렬해 가장 마감이 임박한 booktalk도 보여줌
if(member.isAuthor()){
if(member.getIsAuthor()){
return MyPageDto.builder()
.name(member.getName())
.bookCount(member.getBookCount())
Expand All @@ -47,7 +47,7 @@ public MyInfoDto getMyInfo(Long memberId) {
.gender(member.getGender())
.birth(member.getBirth())
.city(member.getMyCity())
.marketingAgree(member.isMarketingAgree())
.marketingAgree(member.getMarketingAgree())
.build();
}
@Transactional
Expand Down

0 comments on commit 7b71198

Please sign in to comment.