generated from Software-Meister-High-School-Community/Repository_Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔀 :: (#121) 게시글 수정 API #122
Open
lyutvs
wants to merge
7
commits into
main
Choose a base branch
from
121-update-feed
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
da2c2bf
📑 :: UpdateFeedService
lyutvs 7f0d7ac
📑 :: UpdateFeedRequest
lyutvs d4cf169
⚡️ :: publcFeed
lyutvs 4bd7bf4
⚡️ :: Feed 조회
lyutvs 63d335c
⚡️ :: Url mapping
lyutvs 60cef8b
⚡️ :: Feed조회 구현체
lyutvs 9702a12
♻️ :: 리뷰 수정
lyutvs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
10 changes: 10 additions & 0 deletions
10
src/main/java/com/example/moizaspringserver/domain/feed/presenstation/FeedController.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,21 +1,31 @@ | ||
package com.example.moizaspringserver.domain.feed.presenstation; | ||
|
||
import com.example.moizaspringserver.domain.feed.presenstation.dto.request.UpdateFeedRequest; | ||
import com.example.moizaspringserver.domain.feed.service.DeleteFeedService; | ||
import com.example.moizaspringserver.domain.feed.service.UpdateFeedService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/feeds") | ||
@RestController | ||
public class FeedController { | ||
|
||
private final DeleteFeedService deleteFeedService; | ||
private final UpdateFeedService updateFeedService; | ||
|
||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@DeleteMapping("/{feed-id}") | ||
public void deleteFeed(@PathVariable("feed-id") Integer feedId) { | ||
deleteFeedService.execute(feedId); | ||
} | ||
|
||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@PatchMapping("/{feed-id}") | ||
public void updateFeed(@RequestBody @Valid UpdateFeedRequest request, @PathVariable("feed-id") Integer feedId) { | ||
updateFeedService.execute(request, feedId); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...om/example/moizaspringserver/domain/feed/presenstation/dto/request/UpdateFeedRequest.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,27 @@ | ||
package com.example.moizaspringserver.domain.feed.presenstation.dto.request; | ||
|
||
import com.example.moizaspringserver.domain.feed.type.FeedType; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class UpdateFeedRequest { | ||
|
||
@NotBlank(message = "title은 Null, 공백, 띄어쓰기를 허용하지 않습니다.") | ||
private String title; | ||
|
||
@NotNull(message = "content는 Null일 수 없습니다.") | ||
private String content; | ||
|
||
@NotNull(message = "feed_type은 Null일 수 없습니다.") | ||
private FeedType feedType; | ||
|
||
@NotNull(message = "image_urls은 Null일 수 없습니다.") | ||
private List<String> imageUrls; | ||
|
||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/example/moizaspringserver/domain/feed/service/UpdateFeedService.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,40 @@ | ||
package com.example.moizaspringserver.domain.feed.service; | ||
|
||
import com.example.moizaspringserver.domain.feed.entity.Feed; | ||
import com.example.moizaspringserver.domain.feed.entity.FeedAttachmentFile; | ||
import com.example.moizaspringserver.domain.feed.entity.PublicFeed; | ||
import com.example.moizaspringserver.domain.feed.facade.FeedFacade; | ||
import com.example.moizaspringserver.domain.feed.presenstation.dto.request.UpdateFeedRequest; | ||
import com.example.moizaspringserver.domain.user.entity.User; | ||
import com.example.moizaspringserver.domain.user.facade.UserFacade; | ||
import com.example.moizaspringserver.global.error.security.InvalidRoleException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class UpdateFeedService { | ||
|
||
private final FeedFacade feedFacade; | ||
private final UserFacade userFacade; | ||
|
||
@Transactional | ||
public void execute(UpdateFeedRequest request, Integer feedId) { | ||
|
||
User user = userFacade.queryCurrentUser(); | ||
Feed feed = feedFacade.getFeedById(feedId); | ||
PublicFeed publicFeed = feedFacade.getPublicFeedByFeedId(feed); | ||
FeedAttachmentFile feedAttachmentFile = feedFacade.getFeedAttachmentFileByFeedId(feed); | ||
|
||
if (!user.equals(feed.getUser())) { | ||
throw InvalidRoleException.EXCEPTION; | ||
} | ||
// TODO PR#105 머지시 리팩토링 | ||
|
||
publicFeed.updateFeedTitle(request.getTitle()); | ||
publicFeed.updateFeedContent(request.getContent()); | ||
|
||
// TODO 사진 올리는거 없어서 나중에 추가되면 변경 | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 if문을
publicFeed
를 조회하기 이전에(라인 26과 27 사이) 넣으면 불필요한 조회(publicFeed
,feedAttachmentFile
)를 막을 수 있지 않을까요?