[Improvement] TagCode 도입 — 태그 식별자를 4자리 랜덤 코드로 변경 #269

Closed
opened 2026-03-02 07:11:09 +00:00 by seonkyu.kim · 0 comments
Owner

배경

현재 태그 식별은 DB 글로벌 auto-increment PK(tag_id)를 사용한다. 서비스A 태그가 1,2,3이면 서비스B 태그는 4,5가 되어 서비스별 일관성이 없고, 태그 수가 늘어나면 번호가 무한정 커진다.

변경 내용

  • 4자리 랜덤 영숫자 코드(TagCode) 도입 — [0-9a-zA-Z] 62종 문자, 서비스당 유니크
  • 외부 API에서는 tag_code(string)로 통신, 서버가 tag_code ↔ tag_id 변환
  • DB PK(long)는 내부용으로 유지, Device.Tags 컬럼에는 여전히 tag_id(long) JSON 저장

작업 체크리스트

  • Domain: Tag 엔티티에 TagCode 필드 추가
  • Domain: ITagRepository에 TagCode 관련 메서드 추가
  • Domain: IDeviceRepository tags 파라미터 타입 변경
  • Infrastructure: TagConfiguration — TagCode varchar(4), UNIQUE(ServiceId, TagCode)
  • Infrastructure: TagRepository — 새 메서드 구현
  • Infrastructure: DeviceRepository — tags → tagIds 시그니처 변경
  • Infrastructure: PushWorker — group 케이스 tag_code → tag_id 변환
  • Application: DTOs 변경 (tag_id → tag_code)
  • Application: TagService — TagCode 생성/조회 로직
  • Application: DeviceService — tag_code ↔ tag_id 변환
  • API: TagController — Update/Delete에 serviceId 전달
  • API: ServiceCodeMiddleware — /v1/in/tag scope 정책 변경
  • EF Core Migration — AddTagCode
  • 빌드 성공 확인
## 배경 현재 태그 식별은 DB 글로벌 auto-increment PK(`tag_id`)를 사용한다. 서비스A 태그가 1,2,3이면 서비스B 태그는 4,5가 되어 서비스별 일관성이 없고, 태그 수가 늘어나면 번호가 무한정 커진다. ## 변경 내용 - **4자리 랜덤 영숫자 코드(TagCode)** 도입 — `[0-9a-zA-Z]` 62종 문자, 서비스당 유니크 - 외부 API에서는 `tag_code`(string)로 통신, 서버가 `tag_code ↔ tag_id` 변환 - DB PK(long)는 내부용으로 유지, `Device.Tags` 컬럼에는 여전히 `tag_id`(long) JSON 저장 ## 작업 체크리스트 - [x] Domain: Tag 엔티티에 TagCode 필드 추가 - [x] Domain: ITagRepository에 TagCode 관련 메서드 추가 - [x] Domain: IDeviceRepository tags 파라미터 타입 변경 - [x] Infrastructure: TagConfiguration — TagCode varchar(4), UNIQUE(ServiceId, TagCode) - [x] Infrastructure: TagRepository — 새 메서드 구현 - [x] Infrastructure: DeviceRepository — tags → tagIds 시그니처 변경 - [x] Infrastructure: PushWorker — group 케이스 tag_code → tag_id 변환 - [x] Application: DTOs 변경 (tag_id → tag_code) - [x] Application: TagService — TagCode 생성/조회 로직 - [x] Application: DeviceService — tag_code ↔ tag_id 변환 - [x] API: TagController — Update/Delete에 serviceId 전달 - [x] API: ServiceCodeMiddleware — /v1/in/tag scope 정책 변경 - [x] EF Core Migration — AddTagCode - [x] 빌드 성공 확인
seonkyu.kim added the
Priority
High
Status
In Progress
Type
Improvement
labels 2026-03-02 07:11:16 +00:00
seonkyu.kim self-assigned this 2026-03-02 07:11:17 +00:00
seonkyu.kim added this to the Phase 3: 운영 기능 milestone 2026-03-02 07:11:18 +00:00
seonkyu.kim added
Status
Done
and removed
Status
In Progress
labels 2026-03-02 07:17:17 +00:00
Sign in to join this conversation.
No description provided.