Skip to content

Commit

Permalink
Merge pull request #91 from Mojacknong/fix_90/미션인증-api-수정
Browse files Browse the repository at this point in the history
Fix 90/미션인증 api 수정
  • Loading branch information
Ryeolee authored Aug 18, 2024
2 parents 912a590 + 759b8f8 commit b5e8cd0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

public record CreateMissionPostRequestDto(
// 사진, 내용, 스텝번호
Long userFarmClubId,
String content,
Long stepNum
Long farmClubId,
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ 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));
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Builder(access = AccessLevel.PRIVATE)
public record MissionPostHistoryVo(
Long stepNum,
int stepNum,
String image,
String content,
String date
Expand All @@ -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)
Expand Down

0 comments on commit b5e8cd0

Please sign in to comment.