Skip to content

Commit

Permalink
[fix] DTO,VO 관련 네이밍, 패키징 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchoGreenT committed Apr 28, 2024
1 parent 53b818d commit 47e442e
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 77 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,16 +18,16 @@ public record GetFarmClubResponseDto (
List<String> help
){
public static GetFarmClubResponseDto of(FarmClub farmClub, int currentMemberCount, List<String> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

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,
String farmClubName,
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -17,16 +19,17 @@ public record GetMyFarmClubResponseDto(
) {

public static GetMyFarmClubResponseDto of(GetMyFarmClubVo farmClubInfo, List<Step> 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<Step> createSteps(List<StepVo> stepVoList, List<GetMissionPostListWithStepCountsAndImages> missionList) {
public static List<Step> createSteps(List<StepVo> stepVoList, List<GetMissionPostListWithStepCountsAndImagesVo> missionList) {
List<Step> steps = new ArrayList<>();
for (int i = 0; i < stepVoList.size(); i++) {
Step step = new Step(
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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<GetMissionPostListWithStepCountsAndImages> getMissionPostStepNumAndImage(Long farmClubId);
List<GetMissionPostListWithStepCountsAndImagesVo> getMissionPostStepNumAndImage(Long farmClubId);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,7 +20,7 @@ public class MissionPostRepositoryImpl implements MissionPostRepositoryCustom {
private EntityManager em;

@Override
public List<GetMissionPostListWithStepCountsAndImages> getMissionPostStepNumAndImage(Long farmClubId) {
public List<GetMissionPostListWithStepCountsAndImagesVo> getMissionPostStepNumAndImage(Long farmClubId) {
JPAQueryFactory queryFactory = new JPAQueryFactory(em);

return queryFactory
Expand All @@ -30,7 +30,7 @@ public List<GetMissionPostListWithStepCountsAndImages> getMissionPostStepNumAndI
.where(farmClub.id.eq(farmClubId))
.transform(
GroupBy.groupBy(missionPost.stepNum)
.list(new QGetMissionPostListWithStepCountsAndImages(
.list(new QGetMissionPostListWithStepCountsAndImagesVo(
missionPost.stepNum.count(),
GroupBy.list(missionPost.image)
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +75,7 @@ public GetMyFarmClubResponseDto getMyFarmClub(Long userId, Long farmClubId) {
String veggieInfoId = farmClubInfo.veggieInfoId();
List<StepVo> stepList = veggieInfoHelper.getStepList(veggieInfoId);
String randomTip = getRandomTip(stepList);
List<GetMissionPostListWithStepCountsAndImages> missionList =
List<GetMissionPostListWithStepCountsAndImagesVo> missionList =
missionPostRepository.getMissionPostStepNumAndImage(farmClubId);

return GetMyFarmClubResponseDto.of(farmClubInfo, GetMyFarmClubResponseDto.createSteps(stepList, missionList), randomTip);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> images
) {
@QueryProjection
public GetMissionPostListWithStepCountsAndImages {
public GetMissionPostListWithStepCountsAndImagesVo {
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<InfoForRegister> getVeggieInfoListForRegister();
List<InfoForRegisterVo> getVeggieInfoListForRegister();
CreateFarmClubVo getVeggieInfoForCreateFarmClub(String veggieInfoId);
List<StepVo> getVeggieInfoStepList(String veggieInfoId);
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,7 +19,7 @@ public class VeggieInfoRepositoryImpl implements CustomVeggieInfoRepository{
private final MongoTemplate mongoTemplate;

@Override
public List<InfoForRegister> getVeggieInfoListForRegister() {
public List<InfoForRegisterVo> getVeggieInfoListForRegister() {
// Query to get all name, difficulty, veggieImage, period from veggieInfo collection
// and return as List<InfoForRegister>
Query query = new Query();
Expand All @@ -30,7 +30,7 @@ public List<InfoForRegister> getVeggieInfoListForRegister() {
.include("veggieImage")
.include("period");

return mongoTemplate.find(query, InfoForRegister.class, "veggie_info");
return mongoTemplate.find(query, InfoForRegisterVo.class, "veggie_info");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +15,7 @@ public class VeggieInfoService {

private final VeggieInfoRepository veggieInfoRepository;

public List<InfoForRegister> getVeggieInfoListForRegister() {
public List<InfoForRegisterVo> getVeggieInfoListForRegister() {
// Get all veggie info list for register
return veggieInfoRepository.getVeggieInfoListForRegister();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.modernfarmer.farmusspring.domain.veggieinfo.dto.res;
package com.modernfarmer.farmusspring.domain.veggieinfo.vo;

public record CreateFarmClubVo(
String _id,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
){
}

0 comments on commit 47e442e

Please sign in to comment.