-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: 어드민 게시글 CRUD API 작성 #940
Conversation
…feature/admin-article-api
…feature/admin-article-api
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.
몇가지 코멘트 남겼습니다 확인해주세요~!
- 추가로 리뷰하면서 ArticleService로직좀 살펴봤는데 리팩토링이 필요해보여요
`content` MEDIUMTEXT CHARACTER SET 'utf8mb4' NULL DEFAULT NULL COMMENT '내용', | ||
`hit` INT UNSIGNED NOT NULL DEFAULT '0' COMMENT '조회수', | ||
`is_notice` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '공지사항인지 여부', | ||
`is_deleted` TINYINT(1) NOT NULL DEFAULT '0' COMMENT '삭제 여부', |
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.
C
새로 생성하는 테이블들에 is_deleted
가 꼭 필요한 걸까요?
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.
특정 작성자의 모든 게시글 조회와 같이 articles.is_deleted를 JOIN해서 함께 필터링해야 하는 경우를 감안해서 is_deleted를 koin_articles와 koreatech_articles도 가지도록 역정규화했습니다.
DROP TABLE `koin`.`old_articles`; | ||
DROP TABLE `koin`.`old_koreatech_articles`; |
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.
C
기존 테이블의 삭제는 조금 보류해뒀으면 좋을 것 같아요.
배포중 롤백해야하는 상황이 생긴다면 git revert를 한 후 재배포를 할텐데 DB는 롤백이 안되기때문에 DB와 Entity의 정합성이 안맞을 것 같습니다
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.
그래서 덤프뜨고 진행하면 되는지 질문드렸었는데 그래도 조심스럽게 대응해야 하는 건 맞는 것 같아요.
RENAME과 DROP만 나중으로 미루면 되는 내용이니 리뷰 반영해두겠습니다.
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.
적용 완료했습니다.(RENAME 롤백, DROP 롤백)
article_attachments 테이블은 기존 테이블을 그대로 사용하기 때문에 하위호환성을 지키기가 애매했습니다.
- 기존에 걸려있던 article_id FK 해제
- article_id 값 일괄 변경
따라서 배포 시 해당 테이블만 미리 dump해두고 진행하면 될 것 같습니다. 나머지 테이블은 전부 기존 테이블 그대로 유지했기에 코드만 롤백(revert)하면 됩니다.
article_attachments.article_id는 원상복구 힘드니 배포 전 덤프떠둘 것
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.
수고하셨습니다!
배치만 보다가 보니까 적응이 안되네요 ㅋㅋㅋ
배치에도 테이블에 new_ 붙여야겠네요
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.
송선권씨 옆에 두고 설명 들었습니다
DB 어렵네요...
몇가지만 확인해주세용
Optional<Article> foundArticle = articleRepository.findById(noticeId); | ||
if (foundArticle.isEmpty()) { | ||
return; | ||
} |
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.
getById()
를 안쓴 이유가 있나요?
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.
제거 요청은 대상 존재 유무에 상관없이 204 응답을 반환하는 것이 적절하다고 생각해서 대상이 존재하지 않는 경우 예외가 발생하는 getById()
대신 findById()
를 사용하고 직접 핸들링하는 방향으로 작성했습니다.
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class AdminNoticeController implements AdminNoticeApi { |
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.
@RequestMapping("/admin")
으로 뺴도 될 것 같아요!
import jakarta.validation.Valid; | ||
|
||
@Tag(name = "(Admin) Notice: 코인 공지", description = "") | ||
public interface AdminNoticeApi { |
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.
여기도요!
🚀 작업 내용
Article
이koreatech_article
이 아닌articles
테이블을 참조하도록 변경했습니다.기존 테이블 구조
articles: 레거시 게시글 테이블. 옛날 코인 자체 게시글과 한기대 크롤링 게시글이 들어있음. 몇 달 전부터 미사용 중
koreatech_articles: 한기대 크롤링 게시글 테이블.
변경된 테이블 구조
articles: 게시글 테이블. 제목이나 내용 등 게시글 종류에 무관하게 필요한 내용이 포함됨
koreatech_articles: 한기대 크롤링 게시글만이 갖는 추가 필드를 다룸
koin_articles: 코인 자체 게시글만이 갖는 추가 필드를 다룸
💬 리뷰 중점사항
게시글 관련 DB 테이블을 싹 갈아엎어서 flyway가 많이 길어졌습니다. 로컬에서 꼭 한번씩 테스트해주시면 감사하겠습니다!
+) 이번 작업은 신규 캠퍼스팀원 @DHkimgit 및 백엔드 에이스 @ImTotem 과 함께 진행했습니다.