improvement: TagCode 도입 — 태그 식별자를 4자리 랜덤 코드로 변경 (#269) #270

Merged
seonkyu.kim merged 1 commits from improvement/#269-tag-code-identifier into develop 2026-03-02 07:15:26 +00:00
Owner

📋 작업 요약

  • 태그 식별자를 DB PK(tag_id) → 4자리 랜덤 영숫자 코드(tag_code)로 변경
  • 외부 API에서 tag_code(string)로 통신, 서버가 tag_code ↔ tag_id 변환
  • ServiceCodeMiddleware에서 /v1/in/tag scope 정책 세분화 (list만 OPTIONAL)

Closes #269

🛠️ 작업 내용 (Changes)

  • SPMS.Domain/Entities/Tag.cs — TagCode 프로퍼티 추가
  • SPMS.Domain/Interfaces/ITagRepository.cs — TagCode 조회 메서드 3개 추가
  • SPMS.Domain/Interfaces/IDeviceRepository.cs — tags 파라미터 List? → List?
  • SPMS.Infrastructure/.../TagConfiguration.cs — TagCode varchar(4), UNIQUE(ServiceId, TagCode)
  • SPMS.Infrastructure/.../TagRepository.cs — 새 메서드 3개 구현
  • SPMS.Infrastructure/.../DeviceRepository.cs — tags → tagIds 시그니처 변경
  • SPMS.Infrastructure/Workers/PushWorker.cs — group 케이스 tag_code → tag_id 변환, ParseTags 개선
  • SPMS.Application/DTOs/Tag/* — tag_id → tag_code 변경 (4개 파일)
  • SPMS.Application/DTOs/Device/* — tags List → List (4개 파일)
  • SPMS.Application/DTOs/Push/* — tags List → List (2개 파일)
  • SPMS.Application/Interfaces/ITagService.cs — Update/Delete 시그니처에 serviceId 추가
  • SPMS.Application/Services/TagService.cs — GenerateUniqueTagCodeAsync, TagCode 기반 CRUD
  • SPMS.Application/Services/DeviceService.cs — ITagRepository DI, tag_code ↔ tag_id 변환
  • SPMS.API/Controllers/TagController.cs — Update/Delete에 GetServiceId() 전달
  • SPMS.API/Middlewares/ServiceCodeMiddleware.cs — /v1/in/tag/list만 OPTIONAL
  • EF Core Migration AddTagCode — 컬럼 추가 + 기존 태그에 랜덤 코드 할당

📢 리뷰어 참고 사항 (To Reviewers)

  • Device.Tags DB 컬럼은 변경 없음 (여전히 tag_id JSON 저장)
  • 마이그레이션 적용 시 기존 태그에 MySQL RAND()로 4자리 코드 자동 할당
  • 서비스당 최대 10개 태그이므로 4자리(62^4 = 14M) 충돌 확률 극히 낮음

체크리스트 (Self Checklist)

  • 빌드(Build)가 성공적으로 수행되었는가?
  • 모든 단위 테스트(Unit Test)를 통과하였는가?
  • 불필요한 로그나 주석을 제거하였는가?
  • 컨벤션(Clean Architecture, Naming)을 준수하였는가?
  • 기밀 정보(비밀번호, 키 등)가 하드코딩 되어있지 않은가?

📸 스크린샷 / 테스트 로그 (Screenshots/Logs)

빌드 성공: 경고 0, 오류 0

## 📋 작업 요약 - 태그 식별자를 DB PK(tag_id) → 4자리 랜덤 영숫자 코드(tag_code)로 변경 - 외부 API에서 tag_code(string)로 통신, 서버가 tag_code ↔ tag_id 변환 - ServiceCodeMiddleware에서 /v1/in/tag scope 정책 세분화 (list만 OPTIONAL) ## 🔗 관련 이슈 (Related Issues) Closes #269 ## 🛠️ 작업 내용 (Changes) - [x] `SPMS.Domain/Entities/Tag.cs` — TagCode 프로퍼티 추가 - [x] `SPMS.Domain/Interfaces/ITagRepository.cs` — TagCode 조회 메서드 3개 추가 - [x] `SPMS.Domain/Interfaces/IDeviceRepository.cs` — tags 파라미터 List<int>? → List<long>? - [x] `SPMS.Infrastructure/.../TagConfiguration.cs` — TagCode varchar(4), UNIQUE(ServiceId, TagCode) - [x] `SPMS.Infrastructure/.../TagRepository.cs` — 새 메서드 3개 구현 - [x] `SPMS.Infrastructure/.../DeviceRepository.cs` — tags → tagIds 시그니처 변경 - [x] `SPMS.Infrastructure/Workers/PushWorker.cs` — group 케이스 tag_code → tag_id 변환, ParseTags 개선 - [x] `SPMS.Application/DTOs/Tag/*` — tag_id → tag_code 변경 (4개 파일) - [x] `SPMS.Application/DTOs/Device/*` — tags List<int> → List<string> (4개 파일) - [x] `SPMS.Application/DTOs/Push/*` — tags List<int> → List<string> (2개 파일) - [x] `SPMS.Application/Interfaces/ITagService.cs` — Update/Delete 시그니처에 serviceId 추가 - [x] `SPMS.Application/Services/TagService.cs` — GenerateUniqueTagCodeAsync, TagCode 기반 CRUD - [x] `SPMS.Application/Services/DeviceService.cs` — ITagRepository DI, tag_code ↔ tag_id 변환 - [x] `SPMS.API/Controllers/TagController.cs` — Update/Delete에 GetServiceId() 전달 - [x] `SPMS.API/Middlewares/ServiceCodeMiddleware.cs` — /v1/in/tag/list만 OPTIONAL - [x] EF Core Migration `AddTagCode` — 컬럼 추가 + 기존 태그에 랜덤 코드 할당 ## 📢 리뷰어 참고 사항 (To Reviewers) - Device.Tags DB 컬럼은 변경 없음 (여전히 tag_id JSON 저장) - 마이그레이션 적용 시 기존 태그에 MySQL RAND()로 4자리 코드 자동 할당 - 서비스당 최대 10개 태그이므로 4자리(62^4 = 14M) 충돌 확률 극히 낮음 ## ✅ 체크리스트 (Self Checklist) - [x] 빌드(Build)가 성공적으로 수행되었는가? - [x] 모든 단위 테스트(Unit Test)를 통과하였는가? - [x] 불필요한 로그나 주석을 제거하였는가? - [x] 컨벤션(Clean Architecture, Naming)을 준수하였는가? - [x] 기밀 정보(비밀번호, 키 등)가 하드코딩 되어있지 않은가? ## 📸 스크린샷 / 테스트 로그 (Screenshots/Logs) 빌드 성공: 경고 0, 오류 0
seonkyu.kim added 1 commit 2026-03-02 07:13:34 +00:00
seonkyu.kim added the
Priority
High
Status
In Progress
Type
Improvement
labels 2026-03-02 07:13:41 +00:00
seonkyu.kim self-assigned this 2026-03-02 07:13:42 +00:00
seonkyu.kim added this to the Phase 3: 운영 기능 milestone 2026-03-02 07:13:44 +00:00
seonkyu.kim requested review from Owners 2026-03-02 07:13:52 +00:00
seonkyu.kim merged commit 6c3a384a99 into develop 2026-03-02 07:15:26 +00:00
seonkyu.kim deleted branch improvement/#269-tag-code-identifier 2026-03-02 07:15:41 +00:00
seonkyu.kim added
Status
Done
and removed
Status
In Progress
labels 2026-03-02 07:17:22 +00:00
Sign in to join this conversation.
No description provided.