diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/CreateFarmClubResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/CreateFarmClubResponseDto.java index 403ab968..ce9353a3 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/CreateFarmClubResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/CreateFarmClubResponseDto.java @@ -1,9 +1,14 @@ package com.modernfarmer.farmusspring.domain.farmclub.dto.res; +import lombok.Builder; + +@Builder public record CreateFarmClubResponseDto ( Long farmClubId ){ public static CreateFarmClubResponseDto of(Long farmClubId) { - return new CreateFarmClubResponseDto(farmClubId); + return CreateFarmClubResponseDto.builder() + .farmClubId(farmClubId) + .build(); } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetFarmClubResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetFarmClubResponseDto.java index 08ff4d07..b010e7b8 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetFarmClubResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetFarmClubResponseDto.java @@ -1,9 +1,11 @@ package com.modernfarmer.farmusspring.domain.farmclub.dto.res; import com.modernfarmer.farmusspring.domain.farmclub.entity.FarmClub; +import lombok.Builder; import java.util.List; +@Builder public record GetFarmClubResponseDto ( Long farmClubId, String farmClubName, @@ -16,16 +18,16 @@ public record GetFarmClubResponseDto ( List help ){ public static GetFarmClubResponseDto of(FarmClub farmClub, int currentMemberCount, List help) { - return new GetFarmClubResponseDto( - farmClub.getId(), - farmClub.getName(), - farmClub.getDescription(), - farmClub.getVeggieName(), - farmClub.getVeggieImage(), - farmClub.getStartedAt().toString(), - farmClub.getMaxUser(), - currentMemberCount, - help - ); + return GetFarmClubResponseDto.builder() + .farmClubId(farmClub.getId()) + .farmClubName(farmClub.getName()) + .farmClubDescription(farmClub.getDescription()) + .veggieName(farmClub.getVeggieName()) + .veggieImage(farmClub.getVeggieImage()) + .startedAt(String.valueOf(farmClub.getStartedAt())) + .maxMemberCount(farmClub.getMaxUser()) + .currentMemberCount(currentMemberCount) + .help(help) + .build(); } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubListResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubListResponseDto.java index 779717ca..3119697d 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubListResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubListResponseDto.java @@ -2,7 +2,9 @@ import com.modernfarmer.farmusspring.domain.farmclub.entity.FarmClub; import com.querydsl.core.annotations.QueryProjection; +import lombok.Builder; +@Builder public record GetMyFarmClubListResponseDto( Long farmClubId, String farmClubImage, @@ -10,7 +12,12 @@ public record GetMyFarmClubListResponseDto( String veggieName ) { public static GetMyFarmClubListResponseDto of(Long farmClubId, String farmClubImage, String farmClubName, String veggieName) { - return new GetMyFarmClubListResponseDto(farmClubId, farmClubImage, farmClubName, veggieName); + return GetMyFarmClubListResponseDto.builder() + .farmClubId(farmClubId) + .farmClubImage(farmClubImage) + .farmClubName(farmClubName) + .veggieName(veggieName) + .build(); } @QueryProjection diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java index 686492e9..08cc627c 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/GetMyFarmClubResponseDto.java @@ -1,12 +1,14 @@ package com.modernfarmer.farmusspring.domain.farmclub.dto.res; -import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImages; +import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImagesVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMyFarmClubVo; import com.modernfarmer.farmusspring.domain.veggieinfo.vo.StepVo; +import lombok.Builder; import java.util.ArrayList; import java.util.List; +@Builder public record GetMyFarmClubResponseDto( String farmClubName, String farmClubImage, @@ -17,16 +19,17 @@ public record GetMyFarmClubResponseDto( ) { public static GetMyFarmClubResponseDto of(GetMyFarmClubVo farmClubInfo, List steps, String advice) { - return new GetMyFarmClubResponseDto( - farmClubInfo.farmClubName(), - farmClubInfo.farmClubImage(), - farmClubInfo.wholeMemberCount(), - steps, - advice, - farmClubInfo.daySinceStart()); + return GetMyFarmClubResponseDto.builder() + .farmClubName(farmClubInfo.farmClubName()) + .farmClubImage(farmClubInfo.farmClubImage()) + .wholeMemberCount(farmClubInfo.wholeMemberCount()) + .steps(steps) + .advice(advice) + .daysSinceStart(farmClubInfo.daySinceStart()) + .build(); } - public static List createSteps(List stepVoList, List missionList) { + public static List createSteps(List stepVoList, List missionList) { List steps = new ArrayList<>(); for (int i = 0; i < stepVoList.size(); i++) { Step step = new Step( diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/RegisterFarmClubResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/RegisterFarmClubResponseDto.java index c908cca5..fc9f3aa4 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/RegisterFarmClubResponseDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/res/RegisterFarmClubResponseDto.java @@ -1,9 +1,14 @@ package com.modernfarmer.farmusspring.domain.farmclub.dto.res; +import lombok.Builder; + +@Builder public record RegisterFarmClubResponseDto ( Long userFarmClubId ){ public static RegisterFarmClubResponseDto of(Long userFarmClubId) { - return new RegisterFarmClubResponseDto(userFarmClubId); + return RegisterFarmClubResponseDto.builder() + .userFarmClubId(userFarmClubId) + .build(); } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java index 2552ab20..864ecdf8 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryCustom.java @@ -1,11 +1,11 @@ package com.modernfarmer.farmusspring.domain.farmclub.repository; -import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImages; +import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImagesVo; import java.util.List; public interface MissionPostRepositoryCustom { - List getMissionPostStepNumAndImage(Long farmClubId); + List getMissionPostStepNumAndImage(Long farmClubId); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java index 3ed76767..b126d63a 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/repository/MissionPostRepositoryImpl.java @@ -1,8 +1,8 @@ package com.modernfarmer.farmusspring.domain.farmclub.repository; -import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImages; -import com.modernfarmer.farmusspring.domain.farmclub.vo.QGetMissionPostListWithStepCountsAndImages; +import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImagesVo; +import com.modernfarmer.farmusspring.domain.farmclub.vo.QGetMissionPostListWithStepCountsAndImagesVo; import com.querydsl.core.group.GroupBy; import com.querydsl.jpa.impl.JPAQueryFactory; import jakarta.persistence.EntityManager; @@ -20,7 +20,7 @@ public class MissionPostRepositoryImpl implements MissionPostRepositoryCustom { private EntityManager em; @Override - public List getMissionPostStepNumAndImage(Long farmClubId) { + public List getMissionPostStepNumAndImage(Long farmClubId) { JPAQueryFactory queryFactory = new JPAQueryFactory(em); return queryFactory @@ -30,7 +30,7 @@ public List getMissionPostStepNumAndI .where(farmClub.id.eq(farmClubId)) .transform( GroupBy.groupBy(missionPost.stepNum) - .list(new QGetMissionPostListWithStepCountsAndImages( + .list(new QGetMissionPostListWithStepCountsAndImagesVo( missionPost.stepNum.count(), GroupBy.list(missionPost.image) )) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java index 9bcd780f..51ec94e1 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/FarmClubService.java @@ -8,10 +8,10 @@ import com.modernfarmer.farmusspring.domain.farmclub.helper.FarmClubHelper; import com.modernfarmer.farmusspring.domain.farmclub.repository.FarmClubRepository; import com.modernfarmer.farmusspring.domain.farmclub.repository.MissionPostRepository; -import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImages; +import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMissionPostListWithStepCountsAndImagesVo; import com.modernfarmer.farmusspring.domain.farmclub.vo.GetMyFarmClubVo; import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.MyVeggie; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.CreateFarmClubVo; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.CreateFarmClubVo; import com.modernfarmer.farmusspring.domain.veggieinfo.helper.VeggieInfoHelper; import com.modernfarmer.farmusspring.domain.veggieinfo.vo.StepVo; import lombok.RequiredArgsConstructor; @@ -75,7 +75,7 @@ public GetMyFarmClubResponseDto getMyFarmClub(Long userId, Long farmClubId) { String veggieInfoId = farmClubInfo.veggieInfoId(); List stepList = veggieInfoHelper.getStepList(veggieInfoId); String randomTip = getRandomTip(stepList); - List missionList = + List missionList = missionPostRepository.getMissionPostStepNumAndImage(farmClubId); return GetMyFarmClubResponseDto.of(farmClubInfo, GetMyFarmClubResponseDto.createSteps(stepList, missionList), randomTip); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMissionPostListWithStepCountsAndImages.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMissionPostListWithStepCountsAndImagesVo.java similarity index 54% rename from src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMissionPostListWithStepCountsAndImages.java rename to src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMissionPostListWithStepCountsAndImagesVo.java index ae1d2869..ecac9988 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMissionPostListWithStepCountsAndImages.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/vo/GetMissionPostListWithStepCountsAndImagesVo.java @@ -1,15 +1,14 @@ package com.modernfarmer.farmusspring.domain.farmclub.vo; -import com.modernfarmer.farmusspring.domain.farmclub.entity.MissionPost; import com.querydsl.core.annotations.QueryProjection; import java.util.List; -public record GetMissionPostListWithStepCountsAndImages( +public record GetMissionPostListWithStepCountsAndImagesVo( Long count, List images ) { @QueryProjection - public GetMissionPostListWithStepCountsAndImages { + public GetMissionPostListWithStepCountsAndImagesVo { } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/GetVeggieInfoListResponseDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/GetVeggieInfoListResponseDto.java deleted file mode 100644 index 269a4c60..00000000 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/GetVeggieInfoListResponseDto.java +++ /dev/null @@ -1,14 +0,0 @@ -//package com.modernfarmer.farmusspring.domain.veggie.dto.res; -// -// -//import lombok.AllArgsConstructor; -//import lombok.Getter; -//import lombok.NoArgsConstructor; -// -//@AllArgsConstructor(staticName = "of") -//@NoArgsConstructor -//@Getter -//public class GetVeggieInfoListResponseDto { -// -// -//} diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/InfoForRegister.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/InfoForRegister.java deleted file mode 100644 index 9d95ff4a..00000000 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/InfoForRegister.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.modernfarmer.farmusspring.domain.veggieinfo.dto.res; - -import com.modernfarmer.farmusspring.domain.veggieinfo.enums.Difficulty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.bson.types.ObjectId; - - -public record InfoForRegister ( - String _id, - String name, - Difficulty difficulty, - String veggieImage, - String period -){ -} diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java index 7b3a3385..7bc117fb 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/helper/VeggieInfoHelper.java @@ -1,6 +1,6 @@ package com.modernfarmer.farmusspring.domain.veggieinfo.helper; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.CreateFarmClubVo; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.CreateFarmClubVo; import com.modernfarmer.farmusspring.domain.veggieinfo.entity.VeggieInfo; import com.modernfarmer.farmusspring.domain.veggieinfo.exception.custom.VeggieInfoNotFoundException; import com.modernfarmer.farmusspring.domain.veggieinfo.repository.VeggieInfoRepository; diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/CustomVeggieInfoRepository.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/CustomVeggieInfoRepository.java index 20e25c7e..8773f7bd 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/CustomVeggieInfoRepository.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/CustomVeggieInfoRepository.java @@ -1,14 +1,14 @@ package com.modernfarmer.farmusspring.domain.veggieinfo.repository; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.CreateFarmClubVo; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.InfoForRegister; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.CreateFarmClubVo; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.InfoForRegisterVo; import com.modernfarmer.farmusspring.domain.veggieinfo.vo.StepVo; import java.util.List; public interface CustomVeggieInfoRepository { - List getVeggieInfoListForRegister(); + List getVeggieInfoListForRegister(); CreateFarmClubVo getVeggieInfoForCreateFarmClub(String veggieInfoId); List getVeggieInfoStepList(String veggieInfoId); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/VeggieInfoRepositoryImpl.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/VeggieInfoRepositoryImpl.java index fa6271f6..14429465 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/VeggieInfoRepositoryImpl.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/repository/VeggieInfoRepositoryImpl.java @@ -1,8 +1,8 @@ package com.modernfarmer.farmusspring.domain.veggieinfo.repository; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.CreateFarmClubVo; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.InfoForRegister; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.CreateFarmClubVo; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.InfoForRegisterVo; import com.modernfarmer.farmusspring.domain.veggieinfo.vo.StepVo; import lombok.RequiredArgsConstructor; import org.springframework.data.mongodb.core.MongoTemplate; @@ -19,7 +19,7 @@ public class VeggieInfoRepositoryImpl implements CustomVeggieInfoRepository{ private final MongoTemplate mongoTemplate; @Override - public List getVeggieInfoListForRegister() { + public List getVeggieInfoListForRegister() { // Query to get all name, difficulty, veggieImage, period from veggieInfo collection // and return as List Query query = new Query(); @@ -30,7 +30,7 @@ public List getVeggieInfoListForRegister() { .include("veggieImage") .include("period"); - return mongoTemplate.find(query, InfoForRegister.class, "veggie_info"); + return mongoTemplate.find(query, InfoForRegisterVo.class, "veggie_info"); } @Override diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/service/VeggieInfoService.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/service/VeggieInfoService.java index ff5d2e08..786a02cc 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/service/VeggieInfoService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/service/VeggieInfoService.java @@ -1,6 +1,6 @@ package com.modernfarmer.farmusspring.domain.veggieinfo.service; -import com.modernfarmer.farmusspring.domain.veggieinfo.dto.res.InfoForRegister; +import com.modernfarmer.farmusspring.domain.veggieinfo.vo.InfoForRegisterVo; import com.modernfarmer.farmusspring.domain.veggieinfo.entity.VeggieInfo; import com.modernfarmer.farmusspring.domain.veggieinfo.repository.VeggieInfoRepository; import lombok.RequiredArgsConstructor; @@ -15,7 +15,7 @@ public class VeggieInfoService { private final VeggieInfoRepository veggieInfoRepository; - public List getVeggieInfoListForRegister() { + public List getVeggieInfoListForRegister() { // Get all veggie info list for register return veggieInfoRepository.getVeggieInfoListForRegister(); } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/CreateFarmClubVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/vo/CreateFarmClubVo.java similarity index 64% rename from src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/CreateFarmClubVo.java rename to src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/vo/CreateFarmClubVo.java index fda4050a..8904ccc7 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/dto/res/CreateFarmClubVo.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/vo/CreateFarmClubVo.java @@ -1,4 +1,4 @@ -package com.modernfarmer.farmusspring.domain.veggieinfo.dto.res; +package com.modernfarmer.farmusspring.domain.veggieinfo.vo; public record CreateFarmClubVo( String _id, diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/vo/InfoForRegisterVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/vo/InfoForRegisterVo.java new file mode 100644 index 00000000..a133f879 --- /dev/null +++ b/src/main/java/com/modernfarmer/farmusspring/domain/veggieinfo/vo/InfoForRegisterVo.java @@ -0,0 +1,13 @@ +package com.modernfarmer.farmusspring.domain.veggieinfo.vo; + +import com.modernfarmer.farmusspring.domain.veggieinfo.enums.Difficulty; + + +public record InfoForRegisterVo( + String _id, + String name, + Difficulty difficulty, + String veggieImage, + String period +){ +}