Skip to content

Commit 8187ed7

Browse files
committed
refactor(community): imgUrl 삭제
1 parent 8a9f3ea commit 8187ed7

File tree

8 files changed

+16
-42
lines changed

8 files changed

+16
-42
lines changed

src/main/java/com/somemore/domains/community/controller/CommunityBoardCommandApiController.java

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import com.somemore.domains.community.usecase.board.UpdateCommunityBoardUseCase;
88
import com.somemore.global.auth.annotation.RoleId;
99
import com.somemore.global.common.response.ApiResponse;
10-
import com.somemore.global.imageupload.dto.ImageUploadRequestDto;
11-
import com.somemore.global.imageupload.usecase.ImageUploadUseCase;
1210
import io.swagger.v3.oas.annotations.Operation;
1311
import io.swagger.v3.oas.annotations.tags.Tag;
1412
import jakarta.validation.Valid;
@@ -19,14 +17,11 @@
1917
import org.springframework.web.bind.annotation.PostMapping;
2018
import org.springframework.web.bind.annotation.PutMapping;
2119
import org.springframework.web.bind.annotation.RequestMapping;
22-
import org.springframework.web.bind.annotation.RequestPart;
20+
import org.springframework.web.bind.annotation.RequestBody;
2321
import org.springframework.web.bind.annotation.RestController;
24-
import org.springframework.web.multipart.MultipartFile;
2522

2623
import java.util.UUID;
2724

28-
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
29-
3025
@Tag(name = "Community Board Command API", description = "커뮤니티 게시글 생성 수정 삭제 API")
3126
@RequiredArgsConstructor
3227
@RequestMapping("/api/community-board")
@@ -36,37 +31,30 @@ public class CommunityBoardCommandApiController {
3631
private final CreateCommunityBoardUseCase createCommunityBoardUseCase;
3732
private final UpdateCommunityBoardUseCase updateCommunityBoardUseCase;
3833
private final DeleteCommunityBoardUseCase deleteCommunityBoardUseCase;
39-
private final ImageUploadUseCase imageUploadUseCase;
4034

4135
@Secured("ROLE_VOLUNTEER")
4236
@Operation(summary = "커뮤니티 게시글 등록", description = "커뮤니티 게시글을 등록합니다.")
43-
@PostMapping(consumes = MULTIPART_FORM_DATA_VALUE)
37+
@PostMapping
4438
public ApiResponse<Long> createCommunityBoard(
4539
@RoleId UUID volunteerId,
46-
@Valid @RequestPart("data") CommunityBoardCreateRequestDto requestDto,
47-
@RequestPart(value = "img_file", required = false) MultipartFile image
40+
@Valid @RequestBody CommunityBoardCreateRequestDto requestDto
4841
) {
49-
String imgUrl = imageUploadUseCase.uploadImage(new ImageUploadRequestDto(image));
50-
5142
return ApiResponse.ok(
5243
201,
53-
createCommunityBoardUseCase.createCommunityBoard(requestDto, volunteerId, imgUrl),
44+
createCommunityBoardUseCase.createCommunityBoard(requestDto, volunteerId),
5445
"커뮤니티 게시글 등록 성공"
5546
);
5647
}
5748

5849
@Secured("ROLE_VOLUNTEER")
5950
@Operation(summary = "커뮤니티 게시글 수정", description = "커뮤니티 게시글을 수정합니다.")
60-
@PutMapping(value = "/{id}", consumes = MULTIPART_FORM_DATA_VALUE)
51+
@PutMapping(value = "/{id}")
6152
public ApiResponse<String> updateCommunityBoard(
6253
@RoleId UUID volunteerId,
6354
@PathVariable Long id,
64-
@Valid @RequestPart("data") CommunityBoardUpdateRequestDto requestDto,
65-
@RequestPart(value = "img_file", required = false) MultipartFile image
55+
@Valid @RequestBody CommunityBoardUpdateRequestDto requestDto
6656
) {
67-
String imgUrl = imageUploadUseCase.uploadImage(new ImageUploadRequestDto(image));
68-
updateCommunityBoardUseCase.updateCommunityBoard(requestDto, id, volunteerId, imgUrl);
69-
57+
updateCommunityBoardUseCase.updateCommunityBoard(requestDto, id, volunteerId);
7058
return ApiResponse.ok("커뮤니티 게시글 수정 성공");
7159
}
7260

@@ -78,7 +66,6 @@ public ApiResponse<String> deleteCommunityBoard(
7866
@PathVariable Long id
7967
) {
8068
deleteCommunityBoardUseCase.deleteCommunityBoard(volunteerId, id);
81-
8269
return ApiResponse.ok("커뮤니티 게시글 삭제 성공");
8370
}
8471
}

src/main/java/com/somemore/domains/community/domain/CommunityBoard.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,19 @@ public class CommunityBoard extends BaseEntity {
3838
@Column(name = "content", length = 1000, nullable = false)
3939
private String content;
4040

41-
@Column(name = "img_url", nullable = false)
42-
private String imgUrl;
43-
4441
@Builder
45-
public CommunityBoard(UUID writerId, String title, String content, String imgUrl) {
42+
public CommunityBoard(UUID writerId, String title, String content) {
4643
this.writerId = writerId;
4744
this.title = title;
4845
this.content = content;
49-
this.imgUrl = imgUrl;
5046
}
5147

5248
public boolean isWriter(UUID writerId) {
5349
return this.writerId.equals(writerId);
5450
}
5551

56-
public void updateWith(CommunityBoardUpdateRequestDto dto, String imgUrl) {
52+
public void updateWith(CommunityBoardUpdateRequestDto dto) {
5753
this.title = dto.title();
5854
this.content = dto.content();
59-
this.imgUrl = imgUrl;
6055
}
6156
}

src/main/java/com/somemore/domains/community/dto/request/CommunityBoardCreateRequestDto.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ public record CommunityBoardCreateRequestDto(
1919
@NotBlank(message = "게시글 내용은 필수 값입니다.")
2020
String content
2121
) {
22-
public CommunityBoard toEntity(UUID writerId, String imgUrl) {
22+
public CommunityBoard toEntity(UUID writerId) {
2323
return CommunityBoard.builder()
2424
.writerId(writerId)
2525
.title(title)
2626
.content(content)
27-
.imgUrl(imgUrl)
2827
.build();
2928
}
30-
31-
3229
}

src/main/java/com/somemore/domains/community/dto/response/CommunityBoardDetailResponseDto.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ public record CommunityBoardDetailResponseDto(
2121
String title,
2222
@Schema(description = "커뮤니티 게시글 내용", example = "저 포함 5명이 같이 가면 좋을 거 같아요")
2323
String content,
24-
@Schema(description = "이미지 URL", example = "https://image.domain.com/links")
25-
String imageUrl,
2624
@Schema(description = "커뮤니티 게시글 생성 일시", example = "2023-12-02T11:00:00")
2725
LocalDateTime createdAt,
2826
@Schema(description = "커뮤니티 게시글 수정 일시", example = "2023-12-02T11:00:00")
@@ -34,7 +32,6 @@ public static CommunityBoardDetailResponseDto from(CommunityBoard board) {
3432
board.getWriterId(),
3533
board.getTitle(),
3634
board.getContent(),
37-
board.getImgUrl(),
3835
board.getCreatedAt(),
3936
board.getUpdatedAt()
4037
);

src/main/java/com/somemore/domains/community/service/board/CreateCommunityBoardService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public class CreateCommunityBoardService implements CreateCommunityBoardUseCase
1818
private final CommunityBoardRepository communityBoardRepository;
1919

2020
@Override
21-
public Long createCommunityBoard(CommunityBoardCreateRequestDto requestDto, UUID writerId, String imgUrl) {
21+
public Long createCommunityBoard(CommunityBoardCreateRequestDto requestDto, UUID writerId) {
2222

23-
CommunityBoard communityBoard = requestDto.toEntity(writerId, imgUrl == null ? "" : imgUrl);
23+
CommunityBoard communityBoard = requestDto.toEntity(writerId);
2424

2525
communityBoardRepository.save(communityBoard);
2626

src/main/java/com/somemore/domains/community/service/board/UpdateCommunityBoardService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public class UpdateCommunityBoardService implements UpdateCommunityBoardUseCase
2323
private final CommunityBoardRepository communityBoardRepository;
2424

2525
@Override
26-
public void updateCommunityBoard(CommunityBoardUpdateRequestDto requestDto, Long communityBoardId, UUID writerId, String imgUrl) {
26+
public void updateCommunityBoard(CommunityBoardUpdateRequestDto requestDto, Long communityBoardId, UUID writerId) {
2727
CommunityBoard communityBoard = getCommunityBoardById(communityBoardId);
2828
validateWriter(communityBoard, writerId);
29-
communityBoard.updateWith(requestDto, imgUrl);
29+
communityBoard.updateWith(requestDto);
3030

3131
communityBoardRepository.save(communityBoard);
3232
}

src/main/java/com/somemore/domains/community/usecase/board/CreateCommunityBoardUseCase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
public interface CreateCommunityBoardUseCase {
88
Long createCommunityBoard(
99
CommunityBoardCreateRequestDto requestDto,
10-
UUID writerId,
11-
String imgUrl);
10+
UUID writerId);
1211
}

src/main/java/com/somemore/domains/community/usecase/board/UpdateCommunityBoardUseCase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ public interface UpdateCommunityBoardUseCase {
88
void updateCommunityBoard(
99
CommunityBoardUpdateRequestDto requestDto,
1010
Long communityBoardId,
11-
UUID writerId,
12-
String imgUrl);
11+
UUID writerId);
1312
}

0 commit comments

Comments
 (0)