-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor: 해시태그에 카테고리 적용 완료 #647
Conversation
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.
현재 제시해주신 DDL에서 hashtag_category
컬럼을 VARCHAR(50)
로 선언하고 있어요. 하지만, HashtagCategory
는 enum으로 정의되어 있기 때문에, 데이터베이스 레벨에서 enum 값을 강제하는 것이 더 적절하다고 생각해요. 이렇게 하면 데이터 무결성을 유지하고, 허용되지 않은 값이 들어가는 것을 방지할 수 있어요.
개선된 DDL 제안
-- Enum 타입 생성
CREATE TYPE hashtag_category_type AS ENUM ('LANGUAGE', 'FIELD', 'SKILL', 'ETC');
-- 컬럼 추가
ALTER TABLE hashtag
ADD COLUMN hashtag_category hashtag_category_type NOT NULL DEFAULT 'ETC';
...n/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java
Show resolved
Hide resolved
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.
public class BoardRequestDto {
@Schema(description = "해시태그 id 리스트", example = "[1, 2]")
private List<Long> hashtagIdList;
}
추가로, 현재 게시글 등록 시 해시태그의 ID를 정수로 전달받도록 설계되어 있어요. 하지만, 이를 해시태그의 이름으로 전달받도록 변경하는 것을 권장드려요.
ID로 해시태그를 전달받을 경우, 테이블 데이터 변경이나 데이터 재등록과 같은 상황에서 ID 값이 변경될 가능성이 있고, 이는 서버 오류로 이어질 수 있어요. 또한, 프론트 팀과의 약속대로 해시태그의 ID 값이 고정되지 않는다면 예상치 못한 결과를 초래할 수 있어요.
해시태그 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.
Copilot reviewed 9 out of 19 changed files in this pull request and generated no comments.
Files not reviewed (10)
- src/main/java/page/clab/api/domain/community/hashtag/application/service/HashtagRegisterService.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/domain/HashtagCategory.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/domain/Hashtag.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/adapter/in/web/HashtagRegisterController.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/application/dto/mapper/HashtagDtoMapper.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/application/dto/response/HashtagResponseDto.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/hashtag/application/port/in/RegisterHashtagUseCase.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/board/application/dto/mapper/BoardDtoMapper.java: Evaluated as low risk
- src/main/java/page/clab/api/domain/community/board/application/service/HotBoardRetrievalService.java: Evaluated as low risk
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.
limehee 님께서 제안하신 DDL 개선점에 대해 현재 enum으로 카테고리가 관리되어 있기에 크게 동의하고, 수정된 코드에서 문제점은 없어보입니다! 고생하셨어요!!
@limehee 님이 제안주신 내용에 따라 아래와 같이 SQL문을 적용하도록 하겠습니다! 수정된 SQL문 CREATE TYPE hashtag_category_type AS ENUM ('LANGUAGE', 'FIELD', 'SKILL', 'ETC'); ALTER TABLE hashtag
ADD COLUMN hashtag_category hashtag_category_type NOT NULL DEFAULT 'ETC';``` INSERT INTO hashtag (name, category, is_deleted, board_usage, created_at, updated_at) VALUES
('C', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('C++', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Java', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Javascript', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Python', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Assembly', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Kotlin', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Typescript', 'LANGUAGE', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Front-end', 'FIELD', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Back-end', 'FIELD', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('AI', 'FIELD', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Game', 'FIELD', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Android', 'FIELD', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('IOS', 'FIELD', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('DB', 'SKILL', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Devops', 'SKILL', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('Infra', 'SKILL', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('framework', 'SKILL', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('algorithm', 'SKILL', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('기타', 'ETC', false, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); |
...n/java/page/clab/api/domain/community/hashtag/application/dto/request/HashtagRequestDto.java
Show resolved
Hide resolved
.../java/page/clab/api/domain/community/board/application/dto/mapper/BoardHashtagDtoMapper.java
Outdated
Show resolved
Hide resolved
PR에 기재된 쿼리문도 수정 부탁드려요. |
Summary
20가지 정도 되던 해시태그를 분류할 수 있도록 카테고리를 생성해서 관리하도록 했습니다.
@Jeong-Ag 님이 UX적인 요소를 고려해서 제안해 주신 내용입니다.
Tasks
SQL
Screenshot