-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from haedoang/feature/liked
[feature/profile] 프로필 조회/수정
- Loading branch information
Showing
14 changed files
with
248 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/koliving/api/my/application/dto/UserProfileUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.koliving.api.my.application.dto; | ||
|
||
import com.koliving.api.file.domain.ImageFile; | ||
import com.koliving.api.user.Gender; | ||
import com.koliving.api.user.User; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import org.springframework.lang.Nullable; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.time.LocalDate; | ||
|
||
@Schema(description = "작성자 정보") | ||
public record UserProfileUpdateRequest( | ||
|
||
@NotNull | ||
@Schema(description = "이미지 URL 고유 Key") | ||
Long profileId, | ||
|
||
@NotNull | ||
@Schema(description = "성별") | ||
Gender gender, | ||
|
||
@NotNull | ||
@Schema(description = "이름") | ||
String firstName, | ||
|
||
@NotNull | ||
@Schema(description = "성") | ||
String lastName, | ||
|
||
@NotNull | ||
@Schema(description = "생년월일") | ||
LocalDate birthDate, | ||
|
||
@Nullable | ||
@Schema(description = "설명") | ||
String description | ||
) { | ||
public User toUser(ImageFile imageFile) { | ||
return User.of(imageFile, gender, firstName, lastName, birthDate, description); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.koliving.api.my.ui; | ||
|
||
import com.koliving.api.base.ErrorResponse; | ||
import com.koliving.api.my.application.dto.UserProfileUpdateRequest; | ||
import com.koliving.api.user.User; | ||
import com.koliving.api.user.application.UserService; | ||
import com.koliving.api.user.application.dto.UserResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
||
@Tag(name = "MY API", description = "MY API") | ||
@RestController | ||
@RequestMapping("api/v1/my") | ||
@RequiredArgsConstructor | ||
public class MyController { | ||
private final UserService userService; | ||
|
||
@Operation( | ||
summary = "프로필 수정", | ||
description = "프로필을 수정합니다.", | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "204", | ||
description = "프로필 수정 성공" | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "프로필 수정 실패", | ||
content = @Content(schema = @Schema(implementation = ErrorResponse.class)) | ||
), | ||
}) | ||
@PutMapping("/profile") | ||
public ResponseEntity<Void> updateProfile(@RequestBody UserProfileUpdateRequest request, @AuthenticationPrincipal User user) { | ||
userService.updateProfile(request, user.getId()); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
|
||
@Operation( | ||
summary = "프로필 조회", | ||
description = "프로필 정보를 조회합니다", | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "프로필 조회 성공", | ||
content = @Content(schema = @Schema(implementation = UserResponse.class)) | ||
), | ||
@ApiResponse( | ||
responseCode = "400", | ||
description = "프로필 조회 실패", | ||
content = @Content(schema = @Schema(implementation = ErrorResponse.class)) | ||
), | ||
}) | ||
@GetMapping | ||
public ResponseEntity<UserResponse> myProfile(@AuthenticationPrincipal User user) { | ||
UserResponse response = userService.findById(user.getId()); | ||
|
||
return ResponseEntity.ok() | ||
.body(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/koliving/api/room/application/dto/WriterResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.koliving.api.room.application.dto; | ||
|
||
import com.koliving.api.user.Gender; | ||
import com.koliving.api.user.User; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Objects; | ||
|
||
@Schema(description = "작성자 정보") | ||
public record WriterResponse( | ||
@Schema(description = "작성자 이름") | ||
String firstName, | ||
@Schema(description = "작성자 성") | ||
String lastName, | ||
|
||
@Schema(description = "작성자 성별") | ||
Gender gender, | ||
@Schema(description = "작성자 생년월일") | ||
LocalDate birthDate, | ||
|
||
@Schema(description = "작성자 소개") | ||
String description, | ||
|
||
@Schema(description = "작성자 프로필 URL") | ||
String imageUrl | ||
) { | ||
|
||
public static WriterResponse of(User entity) { | ||
String imageUrl = Objects.isNull(entity.getImageFile()) ? null : entity.getImageFile().getPath(); | ||
return new WriterResponse(entity.getFirstName(), entity.getLastName(), entity.getGender(), entity.getBirthDate(), entity.getDescription(), imageUrl); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/java/com/koliving/api/room/infra/RoomRepositoryQueryDsl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package com.koliving.api.room.infra; | ||
|
||
import com.koliving.api.room.application.dto.RoomResponse; | ||
import com.koliving.api.room.application.dto.RoomSearchCondition; | ||
import com.koliving.api.room.domain.Room; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
public interface RoomRepositoryQueryDsl { | ||
Page<Room> search(Pageable pageable, RoomSearchCondition condition); | ||
Page<RoomResponse> search(Pageable pageable, RoomSearchCondition condition); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.