Skip to content

Commit

Permalink
[Fix] 생성친구 request DTO 수정, 기념일 필드 생성 #36
Browse files Browse the repository at this point in the history
  • Loading branch information
eunki96 committed Jun 7, 2023
1 parent dc09dea commit 34f65c1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
8 changes: 8 additions & 0 deletions favor/src/main/java/com/favor/favor/friend/Friend.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.favor.favor.friend;


import com.favor.favor.common.enums.Favor;
import lombok.*;

import com.favor.favor.common.TimeStamped;
Expand Down Expand Up @@ -48,6 +49,13 @@ public void setFriendMemo(String friendMemo) {
@Builder.Default
@ElementCollection
private List<Integer> favorList = new ArrayList<>();
public void setFavorList(List<Favor> favorList){
ArrayList<Integer> favorTypeList = new ArrayList<>();
for(Favor favor : favorList){
favorTypeList.add(favor.getType());
}
this.favorList = favorTypeList;
}
private Boolean isUser;

private Long friendUserNo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void updateFriend(Friend friend, FriendUpdateRequestDto friendUpdateReque

friend.setFriendName(friendUpdateRequestDto.getFriendName());
friend.setFriendMemo(friendUpdateRequestDto.getFriendMemo());
friend.setFavorList(friendUpdateRequestDto.getFavorList());
save(friend);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
public class FriendRequestDto {
@ApiModelProperty(position = 1, required = true, value = "친구이름", example = "이름")
private String friendName;

@ApiModelProperty(position = 2, required = false, value = "친구메모", example = "메모")
private String friendMemo;

@Transactional
public Friend toEntity(User user){
return Friend.builder()
.isUser(false)
.friendName(friendName)
.friendMemo(friendMemo)
.friendMemo("")
.user(user)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.favor.favor.friend.noAccount;

import com.favor.favor.friend.Friend;
import com.favor.favor.common.enums.Favor;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.transaction.Transactional;
import java.util.List;

@Getter
@NoArgsConstructor
Expand All @@ -18,11 +18,6 @@ public class FriendUpdateRequestDto {
@ApiModelProperty(position = 2, required = false, dataType = "String", value = "친구메모", example = "메모")
private String friendMemo;

@Transactional
public Friend toEntity(){
return Friend.builder()
.friendName(friendName)
.friendMemo(friendMemo)
.build();
}
@ApiModelProperty(position = 3, required = false, dataType = "", value = "취향목록", example = "[\n\"심플한\",\n\"귀여운\"\n]")
private List<Favor> favorList;
}
1 change: 0 additions & 1 deletion favor/src/main/java/com/favor/favor/user/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static com.favor.favor.exception.ExceptionCode.*;

Expand Down

0 comments on commit 34f65c1

Please sign in to comment.