Skip to content

Commit

Permalink
[fix] 채소 정보의 help 클래스 추가, 기존 문자열 배열에서 json 타입으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchoGreenT committed May 26, 2024
1 parent 078e6d0 commit b78424b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 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 @@ -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 b78424b

Please sign in to comment.