Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Mojacknong/Farmus-Spring int…
Browse files Browse the repository at this point in the history
…o bug_22/User도메인-수정
  • Loading branch information
Ryeolee committed May 26, 2024
2 parents ed22beb + b78424b commit 66c49f3
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.modernfarmer.farmusspring.domain.farmclub.dto.res;

import com.modernfarmer.farmusspring.domain.farmclub.entity.FarmClub;
import com.modernfarmer.farmusspring.domain.veggieinfo.entity.VeggieInfo;
import lombok.Builder;

import java.util.List;
Expand All @@ -15,9 +16,9 @@ public record GetFarmClubResponseDto (
String startedAt,
int maxMemberCount,
int currentMemberCount,
List<String> help
VeggieInfo.Help help
){
public static GetFarmClubResponseDto of(FarmClub farmClub, int currentMemberCount, List<String> help) {
public static GetFarmClubResponseDto of(FarmClub farmClub, int currentMemberCount, VeggieInfo.Help help) {
return GetFarmClubResponseDto.builder()
.farmClubId(farmClub.getId())
.farmClubName(farmClub.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMyFarmClubVo;
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.MyVeggie;
import com.modernfarmer.farmusspring.domain.myveggiegarden.helper.MyVeggieHelper;
import com.modernfarmer.farmusspring.domain.veggieinfo.entity.VeggieInfo;
import com.modernfarmer.farmusspring.domain.veggieinfo.vo.CreateFarmClubVo;
import com.modernfarmer.farmusspring.domain.veggieinfo.helper.VeggieInfoHelper;
import com.modernfarmer.farmusspring.domain.veggieinfo.vo.StepVo;
Expand Down Expand Up @@ -49,7 +50,7 @@ public CreateFarmClubResponseDto createFarmClub(CreateFarmClubRequestDto request

public GetFarmClubResponseDto getFarmClub(Long id) {
FarmClub farmClub = farmClubHelper.getFarmClubEntity(id);
List<String> help = veggieInfoHelper.getVeggieInfoHelp(farmClub.getVeggieInfoId());
VeggieInfo.Help help = veggieInfoHelper.getVeggieInfoHelp(farmClub.getVeggieInfoId());
return GetFarmClubResponseDto.of(farmClub, farmClub.getUserFarmClubs().size(), help);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public class MyVeggieGardenController {
@PostMapping(value = "")
public BaseResponseDto<Void> settingMyVeggie(
@AuthenticationPrincipal CustomUser user,
@Validated @RequestBody SettingMyVeggieRequest settingMyVeggi
@Validated @RequestBody SettingMyVeggieRequest settingMyVeggie
){
return myVeggieGardenService.settingMyVeggie(
user.getUserId(),
settingMyVeggi
settingMyVeggie
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class SettingMyVeggieRequest {
private String nickname;

@NotNull(message = "null 값을 가지면 안됩니다.")
private Date birh;
private Date birth;

@NotNull(message = "null 값을 가지면 안됩니다.")
private Long veggiInfoId;
private String veggieInfoId;

@NotNull(message = "null 값을 가지면 안됩니다.")
private String veggieName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SelectMyVeggieListDto {

public static List<SelectMyVeggieListResponse> processData(List<MyVeggie> myVeggieList){
return myVeggieList.stream()
.map(myVeggie -> SelectMyVeggieListResponse.of(myVeggie.getVeggieInfoId(),myVeggie.getNickname()))
.map(myVeggie -> SelectMyVeggieListResponse.of(myVeggie.getId(),myVeggie.getNickname()))
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class MyVeggie extends BaseEntity {
private Date birth;

@Column(name = "veggie_info_id")
private Long veggieInfoId;
private String veggieInfoId;

@Column(name = "veggie_name")
private String veggieName;
Expand All @@ -58,7 +58,7 @@ public class MyVeggie extends BaseEntity {
@JoinColumn(name = "user_farm_club_id")
private UserFarmClub userFarmClub;

public static MyVeggie createMyVegetable(String nickname, Date birth, Long veggieInfoId,
public static MyVeggie createMyVegetable(String nickname, Date birth, String veggieInfoId,
String veggieName,
String veggieImage,
User user){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public MyVeggie getMyVeggie(Long userId){
.orElseThrow(() -> new IllegalArgumentException("채소가 존재하지 않습니다."));
}

private void addMyyVeggie(Long userId, SettingMyVeggieRequest settingMyVeggiRequest){
private void addMyyVeggie(Long userId, SettingMyVeggieRequest settingMyVeggieRequest){

MyVeggie newMyVeggie = MyVeggie.createMyVegetable(
settingMyVeggiRequest.getNickname(),
settingMyVeggiRequest.getBirh(),
settingMyVeggiRequest.getVeggiInfoId(),
settingMyVeggiRequest.getVeggieName(),
settingMyVeggiRequest.getVeggieImage(),
settingMyVeggieRequest.getNickname(),
settingMyVeggieRequest.getBirth(),
settingMyVeggieRequest.getVeggieInfoId(),
settingMyVeggieRequest.getVeggieName(),
settingMyVeggieRequest.getVeggieImage(),
User.builder().id(userId).build()
);
myVeggieRepository.save(newMyVeggie);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class VeggieInfo extends BaseDocument {

private String period;

private List<String> help;
private Help help;

@AllArgsConstructor
@NoArgsConstructor
Expand All @@ -48,6 +48,16 @@ public static class Step {
private List<String> tips;
}

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Builder
public static class Help {
private String material;
private List<String> selectHow;
private List<String> features;
}

public static VeggieInfo createVeggieInfo(String name, String difficulty, List<Step> steps, String veggieImage) {
return VeggieInfo.builder()
.name(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class VeggieInfoHelper {

private final VeggieInfoRepository veggieInfoRepository;

public List<String> getVeggieInfoHelp(String veggieInfoId) {
public VeggieInfo.Help getVeggieInfoHelp(String veggieInfoId) {
VeggieInfo veggieInfo = veggieInfoRepository.findById(new ObjectId(veggieInfoId))
.orElseThrow(() -> new VeggieInfoNotFoundException("존재하지 않는 채소 정보 아이디입니다."));

Expand Down

0 comments on commit 66c49f3

Please sign in to comment.