From 2307bcd33e520685c7ed93feaddf96ae1182dfb4 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Sun, 18 Aug 2024 23:12:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EC=9D=98=20stepNum=20int=ED=98=95=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=AF=B8=EC=85=98?= =?UTF-8?q?=20=EC=9D=B8=EC=A6=9D=20=EC=8B=9C=20stepNum=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=EA=B0=92=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../farmclub/dto/req/CreateMissionPostRequestDto.java | 7 +++---- .../farmusspring/domain/farmclub/entity/MissionPost.java | 4 ++-- .../domain/farmclub/service/MissionPostService.java | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java index 3447f961..1c3f493a 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java @@ -6,11 +6,10 @@ public record CreateMissionPostRequestDto( // 사진, 내용, 스텝번호 Long userFarmClubId, - String content, - Long stepNum + String content ) { - public MissionPost toEntity(UserFarmClub userFarmClub, String imageUrl) { - return MissionPost.createMissionPost(this.content, this.stepNum, imageUrl, userFarmClub); + public MissionPost toEntity(UserFarmClub userFarmClub, String imageUrl, int stepNum) { + return MissionPost.createMissionPost(this.content, stepNum, imageUrl, userFarmClub); } } diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPost.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPost.java index fa0da170..07061178 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPost.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/entity/MissionPost.java @@ -24,7 +24,7 @@ public class MissionPost extends BaseEntity { private String content; @Column(nullable = false) - private Long stepNum; + private int stepNum; @Column(nullable = false) private String image; @@ -41,7 +41,7 @@ public class MissionPost extends BaseEntity { @JoinColumn(name = "user_farm_club_id") private UserFarmClub userFarmClub; - public static MissionPost createMissionPost(String content, Long stepNum, String image, UserFarmClub userFarmClub){ + public static MissionPost createMissionPost(String content, int stepNum, String image, UserFarmClub userFarmClub){ MissionPost newMissionPost = MissionPost.builder() .content(content) .stepNum(stepNum) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java index e3ab53fe..49e96db8 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java @@ -39,7 +39,7 @@ public class MissionPostService { public CreateMissionPostResponseDto createMissionPost(CreateMissionPostRequestDto request, MultipartFile image) { UserFarmClub userFarmClub = userFarmClubHelper.getUserFarmClubEntity(request.userFarmClubId()); String imageUrl = s3Service.uploadImage(image, "mission-post"); - MissionPost missionPost = saveMissionPost(request.toEntity(userFarmClub, imageUrl)); + MissionPost missionPost = saveMissionPost(request.toEntity(userFarmClub, imageUrl, userFarmClub.getCurrentStep())); userFarmClub.addMissionPost(missionPost); userFarmClub.updateStep(veggieInfoHelper.getStepName(userFarmClub.getFarmClub().getVeggieInfoId(), userFarmClub.getCurrentStep() + 1)); return CreateMissionPostResponseDto.of(missionPost.getId()); From 759b8f8a73e61d9562bab7184b5d25c31305b755 Mon Sep 17 00:00:00 2001 From: MinchoGreenT Date: Sun, 18 Aug 2024 23:39:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=20=EB=AF=B8=EC=85=98=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D=20=EC=8B=9C=20=ED=8C=9C=ED=81=B4=EB=9F=BD=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=EB=94=94=EB=A5=BC=20=EB=B0=9B=EC=95=84=EC=84=9C=20?= =?UTF-8?q?=EC=9C=A0=EC=A0=80=ED=8C=9C=ED=81=B4=EB=9F=BD=EC=9D=84=20?= =?UTF-8?q?=EB=B6=88=EB=9F=AC=EC=98=A4=EB=8A=94=20=ED=98=95=EC=8B=9D?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/farmclub/controller/FarmClubController.java | 3 ++- .../domain/farmclub/dto/req/CreateMissionPostRequestDto.java | 2 +- .../domain/farmclub/service/MissionPostService.java | 4 ++-- .../farmusspring/domain/history/vo/MissionPostHistoryVo.java | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java index e673b2cc..958bedf9 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/controller/FarmClubController.java @@ -80,10 +80,11 @@ public BaseResponseDto getMyFarmClub( @PostMapping("/mission") public BaseResponseDto createMissionPost( + @AuthenticationPrincipal CustomUser user, @RequestPart CreateMissionPostRequestDto requestDto, @RequestPart(value = "image") MultipartFile image ) { - return BaseResponseDto.of(SuccessCode.CREATED, missionPostService.createMissionPost(requestDto, image)); + return BaseResponseDto.of(SuccessCode.CREATED, missionPostService.createMissionPost(user.getUserId(), requestDto, image)); } @PostMapping("/mission/comment") diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java index 1c3f493a..8ab9bdc6 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/dto/req/CreateMissionPostRequestDto.java @@ -5,7 +5,7 @@ public record CreateMissionPostRequestDto( // 사진, 내용, 스텝번호 - Long userFarmClubId, + Long farmClubId, String content ) { diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java index 49e96db8..effdb8ae 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/farmclub/service/MissionPostService.java @@ -36,8 +36,8 @@ public class MissionPostService { private final S3Service s3Service; @Transactional - public CreateMissionPostResponseDto createMissionPost(CreateMissionPostRequestDto request, MultipartFile image) { - UserFarmClub userFarmClub = userFarmClubHelper.getUserFarmClubEntity(request.userFarmClubId()); + public CreateMissionPostResponseDto createMissionPost(Long userId, CreateMissionPostRequestDto request, MultipartFile image) { + UserFarmClub userFarmClub = userFarmClubHelper.findByUserIdAndFarmClubId(userId, request.farmClubId()); String imageUrl = s3Service.uploadImage(image, "mission-post"); MissionPost missionPost = saveMissionPost(request.toEntity(userFarmClub, imageUrl, userFarmClub.getCurrentStep())); userFarmClub.addMissionPost(missionPost); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/history/vo/MissionPostHistoryVo.java b/src/main/java/com/modernfarmer/farmusspring/domain/history/vo/MissionPostHistoryVo.java index d1eb0a3f..27544325 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/history/vo/MissionPostHistoryVo.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/history/vo/MissionPostHistoryVo.java @@ -7,7 +7,7 @@ @Builder(access = AccessLevel.PRIVATE) public record MissionPostHistoryVo( - Long stepNum, + int stepNum, String image, String content, String date @@ -17,7 +17,7 @@ public record MissionPostHistoryVo( public MissionPostHistoryVo { } - public static MissionPostHistoryVo of(Long stepNum, String image, String content, String date) { + public static MissionPostHistoryVo of(int stepNum, String image, String content, String date) { return MissionPostHistoryVo.builder() .stepNum(stepNum) .image(image)