Skip to content

Commit

Permalink
feat: admin 권한으로 유저 수정 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wocks1123 committed May 28, 2024
1 parent e96fa7d commit 3f58371
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.swygbro.trip.backend.domain.review.dto.UpdateReviewRequest;
import com.swygbro.trip.backend.domain.user.application.UserService;
import com.swygbro.trip.backend.domain.user.domain.User;
import com.swygbro.trip.backend.domain.user.dto.UpdateUserRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
Expand All @@ -32,6 +33,12 @@ public class AdminCommandController {
private final ReservationService reservationService;
private final ReviewService reviewService;

@PutMapping(value = "/users/{userId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void updateUserByAdmin(@PathVariable Long userId,
@RequestPart @Valid UpdateUserRequest dto,
@RequestPart(required = false) MultipartFile imageFile) {
userService.updateUser(userId, dto, imageFile);
}

@PostMapping(value = "/guideProducts", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void createGuideProduct(String nickname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public Optional<UserInfoCard> getUserInfoCard(Long userId) {
.select(qReview.count(), qReview.rating.avg())
.from(qReview)
.where(qReview.reviewer.eq(user))
.groupBy(qUser)
.groupBy(qReview.reviewer)
.fetchFirst();
long myReviewCount = 0;
float myReviewRatingAvg = 0.0f;
Expand All @@ -262,6 +262,13 @@ public Optional<UserInfoCard> getUserInfoCard(Long userId) {
.email(user.getEmail())
.nickname(user.getNickname())
.profileImageUrl(user.getProfileImageUrl())
.nationality(user.getNationality())
.profile(user.getProfile())
.phone(user.getPhone())
.location(user.getLocation())
.birthdate(user.getBirthdate())
.signUpType(user.getSignUpType())
.languages(user.getUserLanguages().stream().map(UserLanguage::getLanguage).toList())
.guideProductCount(guideProductCount)
.guideProductReservationCount(guideProductReservationCount)
.guideProductReviewRatingAvg(guideProductReviewRatingAvg)
Expand Down

0 comments on commit 3f58371

Please sign in to comment.