-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add: enum 권한들 추가 * refactor: member 엔티티에 isAuthor, isOperator 필드를 없애고 Authority 필드를 통해 권한 구별하게 변경 * refactor: token 정보로 User 정보 받아오는 것으로 수정 | 기존 URI도 memberId 직접 다루지 않게 수정 * refactor: 작가 관련 메서드 다루는 컨트롤러 통일 및 권한=작가 외에는 접근 금지 설정 * fix: 북토크가 완료되었을 때 작가의 소피스토리도 업데이트 되게끔 변경 * add: 헤더에 있는 access토큰과 refresh토큰을 받아오는 메서드 추가 * modify: 로그아웃시 헤더에서 access토큰만 받아오게 변경
- Loading branch information
Showing
22 changed files
with
212 additions
and
123 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
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
61 changes: 61 additions & 0 deletions
61
src/main/java/org/sophy/sophy/controller/AuthorController.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,61 @@ | ||
package org.sophy.sophy.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.sophy.sophy.common.dto.ApiResponseDto; | ||
import org.sophy.sophy.domain.CompletedBooktalk; | ||
import org.sophy.sophy.domain.dto.booktalk.BooktalkUpdateDto; | ||
import org.sophy.sophy.domain.dto.booktalk.request.BooktalkRequestDto; | ||
import org.sophy.sophy.domain.dto.booktalk.response.BooktalkCreateResponseDto; | ||
import org.sophy.sophy.domain.dto.booktalk.response.BooktalkDeleteResponseDto; | ||
import org.sophy.sophy.domain.dto.mypage.MyPageBooktalkDto; | ||
import org.sophy.sophy.exception.SuccessStatus; | ||
import org.sophy.sophy.infrastructure.MemberRepository; | ||
import org.sophy.sophy.service.BooktalkService; | ||
import org.sophy.sophy.service.MemberService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.security.core.userdetails.User; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import javax.validation.Valid; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/author") | ||
public class AuthorController { | ||
private final MemberRepository memberRepository; | ||
private final MemberService memberService; | ||
private final BooktalkService booktalkService; | ||
|
||
@GetMapping("/my-booktalks") //개설한 북토크 조회 | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<List<MyPageBooktalkDto>> getAuthorBooktalks(@AuthenticationPrincipal User user) { | ||
Long memberId = memberRepository.getMemberByEmail(user.getUsername()).getId(); | ||
return ApiResponseDto.success(SuccessStatus.GET_AUTHOR_BOOKTALKS_SUCCESS, memberService.getAuthorBooktalksByMemberId(memberId)); | ||
} | ||
|
||
@PostMapping("/booktalk") //북토크 생성 | ||
@ResponseStatus(HttpStatus.CREATED) | ||
public ApiResponseDto<BooktalkCreateResponseDto> createBooktalk(@Valid @ModelAttribute BooktalkRequestDto booktalkRequestDto) { | ||
return ApiResponseDto.success(SuccessStatus.CREATE_BOOKTALK_SUCCESS, booktalkService.createBooktalk(booktalkRequestDto)); | ||
} | ||
|
||
@PatchMapping("/booktalk/{booktalkId}") //북토크 수정 | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<BooktalkUpdateDto> updateBooktalk(@PathVariable("booktalkId") Long booktalkId, @Valid @RequestBody BooktalkUpdateDto booktalkUpdateDto) { | ||
return ApiResponseDto.success(SuccessStatus.PATCH_BOOKTALK_SUCCESS, booktalkService.updateBooktalk(booktalkId, booktalkUpdateDto)); | ||
} | ||
|
||
@DeleteMapping("/booktalk/{booktalkId}") //북토크 삭제 | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<BooktalkDeleteResponseDto> deleteBooktalk(@PathVariable("booktalkId") Long booktalkId) { | ||
return ApiResponseDto.success(SuccessStatus.DELETE_BOOKTALK_SUCCESS, booktalkService.deleteBooktalk(booktalkId)); | ||
} | ||
|
||
@PostMapping("/booktalk/{booktalkId}") //북토크 완료 | ||
@ResponseStatus(HttpStatus.OK) | ||
public ApiResponseDto<CompletedBooktalk> completeBooktalk(@PathVariable("booktalkId") Long booktalkId) { | ||
return ApiResponseDto.success(SuccessStatus.DELETE_BOOKTALK_SUCCESS, booktalkService.completeBooktalk(booktalkId)); | ||
} | ||
} |
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
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
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.