Skip to content

Commit

Permalink
Merge pull request #93 from U-is-Ni-in-Korea/feature/#92-updateProfile
Browse files Browse the repository at this point in the history
[feat] Update Profile API 수정
  • Loading branch information
jiyeoon00 authored Jul 18, 2023
2 parents afc8078 + c623ddd commit ae28268
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/universe/uni/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
import org.springframework.http.MediaType;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.universe.uni.dto.UserDto;
import com.universe.uni.dto.request.UpdateUserNicknameRequestDto;
import com.universe.uni.dto.request.UpdateUserProfileRequestDto;
import com.universe.uni.dto.response.ProfileResponseDto;
import com.universe.uni.dto.response.UserWishCouponResponseDto;
import com.universe.uni.service.CoupleServiceContract;
Expand All @@ -40,17 +39,18 @@ public UserDto updateUserNickname(
return userService.updateUserNickname(userId, requestDto.nickname());
}

@PatchMapping(value = "/info", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PatchMapping(
value = "/info",
consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
public UserDto updateUserProfile(
@AuthenticationPrincipal long userId,
@RequestPart MultipartFile image,
@RequestParam String nickname,
@RequestParam String startDate
@ModelAttribute final UpdateUserProfileRequestDto updateUserProfileRequestDto
) {
final Long userCoupleId = userService.findUserCoupleId(userId);
coupleService.updateCoupleStartDate(userCoupleId, startDate);
return userService.updateUserNicknameAndImage(userId, "", nickname);
coupleService.updateCoupleStartDate(userCoupleId, updateUserProfileRequestDto.startDate());
return userService.updateUserNicknameAndImage(userId, "", updateUserProfileRequestDto.nickname());
}

@GetMapping("/{userId}/wish")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.universe.uni.dto.request;

import org.springframework.web.multipart.MultipartFile;

public record UpdateUserProfileRequestDto(MultipartFile image, String nickname, String startDate) {
}

0 comments on commit ae28268

Please sign in to comment.