Skip to content

Commit

Permalink
[fix] 유저 프로필, 일기 추가 @RequestParam -> @RequestPart
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryeolee committed Jul 4, 2024
1 parent fe27f06 commit f8871a8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.modernfarmer.farmusspring.domain.myveggiegarden.controller;

import com.modernfarmer.farmusspring.domain.auth.entity.CustomUser;
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.CommentDelete;
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.CommentUpdate;
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.CommentWrite;
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.Like;
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.*;
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response.*;
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.Diary;
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.DiaryComment;
Expand Down Expand Up @@ -35,18 +32,15 @@ public class MyVeggieDiaryController {

@PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
public BaseResponseDto<Void> settingMyVeggieDiary(
@RequestPart(value = "file", required = false) MultipartFile multipartFile,
@RequestParam("content") String content,
@RequestParam("isOpen") boolean isOpen,
@RequestParam("state") String state,
@RequestParam("myVeggieId") Long myVeggieId
) throws IOException {
@RequestPart(value = "image", required = false) MultipartFile multipartFile,
@RequestPart MyVeggieDiaryInsert myVeggieDiaryInsert
) throws IOException {
return myVeggieDiaryService.settingMyVeggieDiary(
multipartFile,
content,
isOpen,
state,
myVeggieId
myVeggieDiaryInsert.getContent(),
myVeggieDiaryInsert.isOpen(),
myVeggieDiaryInsert.getState(),
myVeggieDiaryInsert.getMyVeggieId()
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request;

import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;


@Getter
@AllArgsConstructor
@NoArgsConstructor
public class MyVeggieDiaryInsert {
@NotNull(message = "null 값을 가지면 안됩니다.")
String content;

boolean isOpen;
@NotNull(message = "null 값을 가지면 안됩니다.")
String state;
@NotNull(message = "null 값을 가지면 안됩니다.")
Long myVeggieId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public BaseResponseDto<Void> deleteProfleImage(@AuthenticationPrincipal CustomUs
@PostMapping(value = "/profile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public BaseResponseDto<Void> settingProfile(
@AuthenticationPrincipal CustomUser user,
@RequestParam("nickname") String nickname,
@RequestPart(value = "file", required = false) MultipartFile file
@RequestPart String nickname,
@RequestPart(value = "image", required = false) MultipartFile file
) throws IOException {
return userService.settingProfile(user.getUserId(), file, nickname);
}
Expand Down

0 comments on commit f8871a8

Please sign in to comment.