|
| 1 | +package com.somemore.center.controller; |
| 2 | + |
| 3 | +import com.somemore.auth.annotation.CurrentUser; |
| 4 | +import com.somemore.center.dto.request.CenterProfileUpdateRequestDto; |
| 5 | +import com.somemore.center.usecase.command.UpdateCenterProfileUseCase; |
| 6 | +import com.somemore.global.common.response.ApiResponse; |
| 7 | +import com.somemore.imageupload.dto.ImageUploadRequestDto; |
| 8 | +import com.somemore.imageupload.usecase.ImageUploadUseCase; |
| 9 | +import io.swagger.v3.oas.annotations.Operation; |
| 10 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | +import jakarta.validation.Valid; |
| 12 | +import lombok.RequiredArgsConstructor; |
| 13 | +import org.springframework.security.access.annotation.Secured; |
| 14 | +import org.springframework.web.bind.annotation.*; |
| 15 | +import org.springframework.web.multipart.MultipartFile; |
| 16 | + |
| 17 | +import java.util.UUID; |
| 18 | + |
| 19 | +import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; |
| 20 | + |
| 21 | +@Tag(name = "Center Command API", description = "센터 프로필 수정 API") |
| 22 | +@RequiredArgsConstructor |
| 23 | +@RequestMapping("/api/center/profile") |
| 24 | +@RestController |
| 25 | +public class CenterProfileCommandApiController { |
| 26 | + |
| 27 | + private final UpdateCenterProfileUseCase updateCenterProfileUseCase; |
| 28 | + private final ImageUploadUseCase imageUploadUseCase; |
| 29 | + |
| 30 | + @Secured("ROLE_CENTER") |
| 31 | + @Operation(summary = "센터 프로필 수정", description = "센터 프로필을 수정합니다.") |
| 32 | + @PutMapping(value = "/{centerId}", consumes = MULTIPART_FORM_DATA_VALUE) |
| 33 | + public ApiResponse<String> updateCenterProfile( |
| 34 | + @CurrentUser UUID centerId, |
| 35 | + @Valid @RequestPart("data") CenterProfileUpdateRequestDto requestDto, |
| 36 | + @RequestPart(value = "img_file", required = false) MultipartFile image |
| 37 | + ) { |
| 38 | + String imgUrl = imageUploadUseCase.uploadImage(new ImageUploadRequestDto(image)); |
| 39 | + updateCenterProfileUseCase.updateCenterProfile(centerId, requestDto, imgUrl); |
| 40 | + |
| 41 | + return ApiResponse.ok("센터 프로필 수정 성공"); |
| 42 | + } |
| 43 | +} |
0 commit comments