-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor(api): change name announcement -> notice (#490)
* ♻️ refactor(api): change name announcement -> notice * ♻️ refactor(admin): change name announcement -> notice * ♻️ refactor(admin): do not change name announcement -> notice
- Loading branch information
Showing
13 changed files
with
315 additions
and
316 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
...i/src/main/java/com/depromeet/domains/announcement/controller/AnnouncementController.java
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...main/java/com/depromeet/domains/announcement/dto/response/NewAnnouncementResponseDto.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...i/src/main/java/com/depromeet/domains/announcement/repository/AnnouncementRepository.java
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
...rop-api/src/main/java/com/depromeet/domains/announcement/service/AnnouncementService.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...treetdrop-api/src/main/java/com/depromeet/domains/notice/controller/NoticeController.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,49 @@ | ||
package com.depromeet.domains.notice.controller; | ||
|
||
import com.depromeet.common.dto.PaginationResponseDto; | ||
import com.depromeet.common.dto.ResponseDto; | ||
import com.depromeet.domains.notice.dto.response.NoticeResponseDto; | ||
import com.depromeet.domains.notice.dto.response.NewNoticeResponseDto; | ||
import com.depromeet.domains.notice.service.NoticeService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/notices") | ||
@RequiredArgsConstructor | ||
@Tag(name = "🔈Notice", description = "Notice API") | ||
public class NoticeController { | ||
|
||
private final NoticeService noticeService; | ||
|
||
@Operation(summary = "공지사항 전체 조회") | ||
@GetMapping | ||
public ResponseEntity<PaginationResponseDto<?, ?>> getNotices() { | ||
var response = noticeService.getNotices(); | ||
return ResponseDto.ok(response); | ||
} | ||
|
||
@Operation(summary = "공지사항 단건 조회") | ||
@GetMapping("{noticeId}") | ||
public ResponseEntity<NoticeResponseDto> getNotice( | ||
@PathVariable(value = "noticeId") Long noticeId | ||
) { | ||
var response = noticeService.getNotice(noticeId); | ||
return ResponseDto.ok(response); | ||
} | ||
|
||
@Operation(summary = "신규 공지사항 여부 조회") | ||
@GetMapping("/new") | ||
public ResponseEntity<NewNoticeResponseDto> hasNewNotice( | ||
@Schema(description = "마지막으로 조회한 공지사항 아이디", example = "1") | ||
@RequestParam(defaultValue = "-1") Long lastNoticeId | ||
) { | ||
var response = noticeService.hasNewNotice(lastNoticeId); | ||
return ResponseDto.ok(response); | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
...rop-api/src/main/java/com/depromeet/domains/notice/dto/response/NewNoticeResponseDto.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,12 @@ | ||
package com.depromeet.domains.notice.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record NewNoticeResponseDto( | ||
@Schema(description = "새로운 공지사항이 있는지 여부", example = "true") | ||
boolean hasNewNotice | ||
){ | ||
public NewNoticeResponseDto(boolean hasNewNotice) { | ||
this.hasNewNotice = hasNewNotice; | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
...response/AnnouncementListResponseDto.java → ...e/dto/response/NoticeListResponseDto.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
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
...treetdrop-api/src/main/java/com/depromeet/domains/notice/repository/NoticeRepository.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,10 @@ | ||
package com.depromeet.domains.notice.repository; | ||
|
||
import com.depromeet.announcement.Announcement; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface NoticeRepository extends JpaRepository<Announcement, Long> { | ||
|
||
boolean existsByIdGreaterThan(Long lastNoticeId); | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
backend/streetdrop-api/src/main/java/com/depromeet/domains/notice/service/NoticeService.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,51 @@ | ||
package com.depromeet.domains.notice.service; | ||
|
||
import com.depromeet.common.dto.MetaInterface; | ||
import com.depromeet.common.dto.PageMetaResponseDto; | ||
import com.depromeet.common.dto.PaginationResponseDto; | ||
import com.depromeet.common.error.dto.CommonErrorCode; | ||
import com.depromeet.common.error.exception.internal.NotFoundException; | ||
import com.depromeet.domains.notice.dto.response.NoticeListResponseDto; | ||
import com.depromeet.domains.notice.dto.response.NoticeResponseDto; | ||
import com.depromeet.domains.notice.dto.response.NewNoticeResponseDto; | ||
import com.depromeet.domains.notice.repository.NoticeRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class NoticeService { | ||
|
||
private final NoticeRepository noticeRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public PaginationResponseDto<NoticeListResponseDto, MetaInterface> getNotices() { | ||
var notices = noticeRepository.findAll() | ||
.stream() | ||
.map(NoticeListResponseDto::new) | ||
.toList(); | ||
var meta = PageMetaResponseDto.builder() | ||
.page(1) | ||
.size(notices.size()) | ||
.totalPage(1) | ||
.firstPage(true) | ||
.lastPage(true) | ||
.build(); | ||
return new PaginationResponseDto<>(notices, meta); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public NoticeResponseDto getNotice(Long noticeId) { | ||
return noticeRepository.findById(noticeId) | ||
.map(NoticeResponseDto::new) | ||
.orElseThrow(() -> new NotFoundException(CommonErrorCode.NOT_FOUND, noticeId)); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public NewNoticeResponseDto hasNewNotice(Long lastNoticeId) { | ||
var isExist = noticeRepository.existsByIdGreaterThan(lastNoticeId); | ||
return new NewNoticeResponseDto(isExist); | ||
} | ||
|
||
} |
Oops, something went wrong.