Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
dkflfkd53 committed Sep 26, 2024
1 parent 0f0c8d6 commit 0676a80
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
package com.repo.whopper.application.notice.impl;

import com.repo.whopper.application.notice.usecase.EditNoticeUseCase;
import com.repo.whopper.application.notice.usecase.ChangeNoticeUseCase;
import com.repo.whopper.common.exception.notice.NoticeNotFoundException;
import com.repo.whopper.domain.notice.NoticeModel;
import com.repo.whopper.domain.notice.NoticeRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class EditNoticeService implements EditNoticeUseCase {
public class ChangeNoticeService implements ChangeNoticeUseCase {
private final NoticeRepository noticeRepository;

@Override
@Transactional
public void checkNotice(String noticeId) {
NoticeModel notice = noticeRepository.findById(noticeId)
.orElseThrow(() -> NoticeNotFoundException.EXCEPTION);

var newNotice = notice.checkNotice();
noticeRepository.save(newNotice);
}

@Override
@Transactional
public void editNotice(String noticeId, String title, String content) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.repo.whopper.application.notice.impl;

import com.repo.whopper.application.notice.usecase.FetchNoticeUseCase;
import com.repo.whopper.common.exception.notice.NoticeNotFoundException;
import com.repo.whopper.common.http.dto.DataResponseInfo;
import com.repo.whopper.domain.notice.NoticeModel;
import com.repo.whopper.domain.notice.NoticeRepository;
import com.repo.whopper.interfaces.notice.dto.response.NoticeDetailResponse;
import com.repo.whopper.interfaces.notice.dto.response.NoticeResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -16,18 +13,6 @@
public class FetchNoticeService implements FetchNoticeUseCase {
private final NoticeRepository noticeRepository;

@Override
@Transactional(readOnly = true)
public NoticeDetailResponse fetchNoticeDetailResponse(String noticeId){
NoticeModel notice = noticeRepository.findById(noticeId)
.orElseThrow(() -> NoticeNotFoundException.EXCEPTION);

var newNotice = notice.checkNotice();
noticeRepository.save(newNotice);

return new NoticeDetailResponse(notice);
}

@Override
@Transactional(readOnly = true)
public DataResponseInfo<NoticeResponse> fetchNotice() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.repo.whopper.application.notice.usecase;

public interface EditNoticeUseCase {
public interface ChangeNoticeUseCase {
void checkNotice(String noticeId);
void editNotice(String noticeId, String title, String content);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.repo.whopper.application.notice.usecase;

import com.repo.whopper.common.http.dto.DataResponseInfo;
import com.repo.whopper.interfaces.notice.dto.response.NoticeDetailResponse;
import com.repo.whopper.interfaces.notice.dto.response.NoticeResponse;

public interface FetchNoticeUseCase {
NoticeDetailResponse fetchNoticeDetailResponse(String noticeId);
DataResponseInfo<NoticeResponse> fetchNotice();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "Edit_notice", description = "공지 수정 API")
public interface EditNoticeApiDocumentation {
public interface ChangeNoticeApiDocumentation {
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "OK, 성공!"
)
})
@Operation(
summary = "공지 확인 API",
description = "클라이언트에서 받은 id로 공지를 검색하고, 검색한 확인 상태로 변경합니다."
)
void checkNotice(String noticeId);
@ApiResponses({
@ApiResponse(
responseCode = "200",
Expand All @@ -16,7 +27,7 @@ public interface EditNoticeApiDocumentation {
})
@Operation(
summary = "공지 수정 API",
description = "클라이언트에서 받은 id로 공지를 검색하고, 검색한 공지의 제목과 내용을 수정합니다."
description = "클라이언트에서 받은 id로 공지를 검색하고, 검색한 공지의 제목과 내용을 변경합니다."
)
void editNotice(String noticeId, NoticeRequest request);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.repo.whopper.common.swagger.notice;

import com.repo.whopper.common.error.ErrorResponse;
import com.repo.whopper.common.http.dto.DataResponseInfo;
import com.repo.whopper.interfaces.notice.dto.response.NoticeDetailResponse;
import com.repo.whopper.interfaces.notice.dto.response.NoticeResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -14,33 +12,6 @@

@Tag(name = "Fetch_notice", description = "공지 조회 API")
public interface FetchNoticeApiDocumentation {
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "OK, 성공!",
content = @Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(
implementation = NoticeDetailResponse.class
)
)
),
@ApiResponse(
responseCode = "404",
description = "요청하신 공지를 찾지 못했습니다.",
content = @Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(
implementation = ErrorResponse.class
)
)
)
})
@Operation(
summary = "공지 상세 조회 API",
description = "클라이언트에서 받은 id로 공지를 검색합니다."
)
NoticeDetailResponse fetchNoticeDetailResponse(String noticeId);
@ApiResponses({
@ApiResponse(
responseCode = "200",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
package com.repo.whopper.interfaces.notice;

import com.repo.whopper.application.notice.usecase.EditNoticeUseCase;
import com.repo.whopper.application.notice.usecase.ChangeNoticeUseCase;
import com.repo.whopper.common.annotation.OnlyTeacher;
import com.repo.whopper.common.swagger.notice.EditNoticeApiDocumentation;
import com.repo.whopper.common.swagger.notice.ChangeNoticeApiDocumentation;
import com.repo.whopper.interfaces.notice.dto.request.NoticeRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/notice")
public class EditNoticeController implements EditNoticeApiDocumentation {
private final EditNoticeUseCase editNoticeUseCase;
public class ChangeNoticeController implements ChangeNoticeApiDocumentation {
private final ChangeNoticeUseCase changeNoticeUseCase;

@PostMapping("/{noticeId}")
public void checkNotice(@PathVariable String noticeId) {
changeNoticeUseCase.checkNotice(noticeId);
}

@OnlyTeacher
@PatchMapping("/{noticeId}")
public void editNotice(@PathVariable String noticeId, @RequestBody NoticeRequest request) {
editNoticeUseCase.editNotice(noticeId, request.title(), request.content());
changeNoticeUseCase.editNotice(noticeId, request.title(), request.content());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import com.repo.whopper.application.notice.usecase.FetchNoticeUseCase;
import com.repo.whopper.common.http.dto.DataResponseInfo;
import com.repo.whopper.common.swagger.notice.FetchNoticeApiDocumentation;
import com.repo.whopper.interfaces.notice.dto.response.NoticeDetailResponse;
import com.repo.whopper.interfaces.notice.dto.response.NoticeResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -17,11 +15,6 @@
public class FetchNoticeController implements FetchNoticeApiDocumentation {
private final FetchNoticeUseCase fetchNoticeUseCase;

@GetMapping("/{noticeId}")
public NoticeDetailResponse fetchNoticeDetailResponse(@PathVariable String noticeId) {
return fetchNoticeUseCase.fetchNoticeDetailResponse(noticeId);
}

@GetMapping
public DataResponseInfo<NoticeResponse> fetchNotice() {
return fetchNoticeUseCase.fetchNotice();
Expand Down

This file was deleted.

0 comments on commit 0676a80

Please sign in to comment.