Skip to content

Commit

Permalink
♻️ refactor(domain): change name announcement -> notice (#493)
Browse files Browse the repository at this point in the history
* ♻️ refactor(domain): change name announcement -> notice

* ♻️ refactor(api): change name announcement -> notice

* ♻️ refactor(admin): change name announcement -> notice
  • Loading branch information
siyeonSon authored Jul 4, 2024
1 parent 687ae99 commit b1425a0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.depromeet.domains.announcement.repository;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AnnouncementRepository extends JpaRepository<Announcement, Long> {
public interface AnnouncementRepository extends JpaRepository<Notice, Long> {

Page<Announcement> findAll(Pageable pageable);
Page<Notice> findAll(Pageable pageable);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.depromeet.domains.announcement.service;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import com.depromeet.common.dto.PageMetaData;
import com.depromeet.common.dto.PageResponseDto;
import com.depromeet.domains.announcement.dto.request.AnnouncementRequestDto;
Expand Down Expand Up @@ -60,9 +60,9 @@ public AnnouncementResponseDto getAnnouncement(Long announcementId) {

public AnnouncementResponseDto createAnnouncement(AnnouncementRequestDto requestDto) {

Announcement announcement = new Announcement(requestDto.getTitle(), requestDto.getContent());
Notice notice = new Notice(requestDto.getTitle(), requestDto.getContent());

var announcementResult = announcementRepository.save(announcement);
var announcementResult = announcementRepository.save(notice);
return AnnouncementResponseDto.builder()
.id(announcementResult.getId())
.title(announcementResult.getTitle())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.depromeet.domains.notice.dto.response;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import io.swagger.v3.oas.annotations.media.Schema;

import java.time.LocalDateTime;
Expand All @@ -15,11 +15,11 @@ public record NoticeListResponseDto(
@Schema(description = "생성시간", example = "yyyy-MM-dd HH:mm:ss")
LocalDateTime createdAt
) {
public NoticeListResponseDto(Announcement announcement) {
public NoticeListResponseDto(Notice notice) {
this(
announcement.getId(),
announcement.getTitle(),
announcement.getCreatedAt()
notice.getId(),
notice.getTitle(),
notice.getCreatedAt()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.depromeet.domains.notice.dto.response;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;

Expand All @@ -17,12 +17,12 @@ public record NoticeResponseDto(
@Schema(description = "생성시간", example = "yyyy-MM-dd HH:mm:ss")
LocalDateTime createdAt
) {
public NoticeResponseDto(Announcement announcement) {
public NoticeResponseDto(Notice notice) {
this(
announcement.getId(),
announcement.getTitle(),
announcement.getContent(),
announcement.getCreatedAt()
notice.getId(),
notice.getTitle(),
notice.getContent(),
notice.getCreatedAt()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.depromeet.domains.notice.repository;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import org.springframework.data.jpa.repository.JpaRepository;

public interface NoticeRepository extends JpaRepository<Announcement, Long> {
public interface NoticeRepository extends JpaRepository<Notice, Long> {

boolean existsByIdGreaterThan(Long lastNoticeId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package unit.domains.notice.controller;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import com.depromeet.common.dto.MetaInterface;
import com.depromeet.common.dto.PageMetaResponseDto;
import com.depromeet.common.dto.PaginationResponseDto;
Expand Down Expand Up @@ -76,8 +76,8 @@ void getNoticesTestSuccess1() throws Exception {
@Test
void getNoticesTestSuccess2() throws Exception {
var noticeResponseDto = List.of(
new NoticeListResponseDto(new Announcement("Title 1", "Content 1")),
new NoticeListResponseDto(new Announcement("Title 2", "Content 2"))
new NoticeListResponseDto(new Notice("Title 1", "Content 1")),
new NoticeListResponseDto(new Notice("Title 2", "Content 2"))
);
var meta = PageMetaResponseDto.builder()
.page(0)
Expand Down Expand Up @@ -109,7 +109,7 @@ class Success {
@Test
void getNoticeTestSuccess1() throws Exception {
var noticeId = 1L;
var noticeResponseDto = new NoticeResponseDto(new Announcement("Title 1", "Content 1"));
var noticeResponseDto = new NoticeResponseDto(new Notice("Title 1", "Content 1"));
when(noticeService.getNotice(noticeId)).thenReturn(noticeResponseDto);

var response = mvc.perform(get("/notices/{noticeId}", noticeId));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package unit.domains.notice.service;

import com.depromeet.announcement.Announcement;
import com.depromeet.notice.Notice;
import com.depromeet.common.error.exception.internal.NotFoundException;
import com.depromeet.domains.notice.dto.response.NoticeListResponseDto;
import com.depromeet.domains.notice.dto.response.NoticeResponseDto;
Expand Down Expand Up @@ -51,9 +51,9 @@ void getNoticesTestSuccess1() {
@DisplayName("공지사항 2개 조회")
@Test
void getNoticesTestSuccess2() {
List<Announcement> notices = List.of(
new Announcement("Title 1", "Content 1"),
new Announcement("Title 2", "Content 2")
List<Notice> notices = List.of(
new Notice("Title 1", "Content 1"),
new Notice("Title 2", "Content 2")
);
when(noticeRepository.findAll()).thenReturn(notices);

Expand All @@ -78,7 +78,7 @@ class Success {
@DisplayName("id가 일치하는 경우")
@Test
void getNoticeTestSuccess1() {
var notice = new Announcement("Title 1", "Content 1");
var notice = new Notice("Title 1", "Content 1");
when(noticeRepository.findById(1L)).thenReturn(Optional.of(notice));

var result = noticeService.getNotice(1L);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.depromeet.announcement;
package com.depromeet.notice;

import static lombok.AccessLevel.PROTECTED;

Expand All @@ -15,11 +15,11 @@
@Getter
@NoArgsConstructor(access = PROTECTED)
@Entity
public class Announcement extends BaseTimeEntity {
public class Notice extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "announcement_id")
@Column(name = "notice_id")
private Long id;

@Column(nullable = false, length = 200)
Expand All @@ -29,7 +29,7 @@ public class Announcement extends BaseTimeEntity {
private String content;

@Builder
public Announcement(String title, String content) {
public Notice(String title, String content) {
this.title = title;
this.content = content;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE announcement RENAME notice;
ALTER TABLE notice CHANGE announcement_id notice_id BIGINT NOT NULL AUTO_INCREMENT;

0 comments on commit b1425a0

Please sign in to comment.