fix: 채널ID 갱신을 kind 분기 대신 정적 타입 메서드 2개로 분리
updateChannelId(id, kind, channelId)는 kind가 "mj"가 아니면 무조건로 빠져 channel_id_law에 잘못 기록됐다. 오타·null·새 kind가 들어와도 예외 없이 조용히 엉뚱한 컬럼을 덮어써 검증이 불가능했다. 분기를 없애고 updateChannelIdMj/updateChannelIdLaw로 나눠 컬럼을 컴파일 타임에 고정한다. 폴백 경로 자체가 사라져 다음 단계인 Mattermost 채널 프로비저닝에서 한쪽씩 기록해도 안전하다.
@cecbba01d4fdc20b2776cbb8e2e2df3adc2f00eb
--- src/main/java/kr/itn/itnhub/org/OrganizationMapper.java
+++ src/main/java/kr/itn/itnhub/org/OrganizationMapper.java
... | ... | @@ -17,7 +17,9 @@ |
| 17 | 17 |
|
| 18 | 18 |
int updateContact(Organization org); |
| 19 | 19 |
|
| 20 |
- int updateChannelId(@Param("id") Long id,
|
|
| 21 |
- @Param("kind") String kind,
|
|
| 22 |
- @Param("channelId") String channelId);
|
|
| 20 |
+ int updateChannelIdMj(@Param("id") Long id,
|
|
| 21 |
+ @Param("channelId") String channelId);
|
|
| 22 |
+ |
|
| 23 |
+ int updateChannelIdLaw(@Param("id") Long id,
|
|
| 24 |
+ @Param("channelId") String channelId);
|
|
| 23 | 25 |
} |
--- src/main/resources/mapper/OrganizationMapper.xml
+++ src/main/resources/mapper/OrganizationMapper.xml
... | ... | @@ -54,13 +54,17 @@ |
| 54 | 54 |
where id = #{id}
|
| 55 | 55 |
</update> |
| 56 | 56 |
|
| 57 |
- <update id="updateChannelId"> |
|
| 57 |
+ <update id="updateChannelIdMj"> |
|
| 58 | 58 |
update organization set |
| 59 |
- <choose> |
|
| 60 |
- <when test="kind == 'mj'">channel_id_mj = #{channelId},</when>
|
|
| 61 |
- <otherwise>channel_id_law = #{channelId},</otherwise>
|
|
| 62 |
- </choose> |
|
| 63 |
- updated_at = now() |
|
| 59 |
+ channel_id_mj = #{channelId},
|
|
| 60 |
+ updated_at = now() |
|
| 61 |
+ where id = #{id}
|
|
| 62 |
+ </update> |
|
| 63 |
+ |
|
| 64 |
+ <update id="updateChannelIdLaw"> |
|
| 65 |
+ update organization set |
|
| 66 |
+ channel_id_law = #{channelId},
|
|
| 67 |
+ updated_at = now() |
|
| 64 | 68 |
where id = #{id}
|
| 65 | 69 |
</update> |
| 66 | 70 |
|
--- src/test/java/kr/itn/itnhub/org/OrganizationMapperTest.java
+++ src/test/java/kr/itn/itnhub/org/OrganizationMapperTest.java
... | ... | @@ -60,8 +60,8 @@ |
| 60 | 60 |
void 시드_재실행은_기존_채널ID를_지우지_않는다() {
|
| 61 | 61 |
mapper.upsertBySeed(seedRow("001", "국제방송교류재단", "데이터정보화팀"));
|
| 62 | 62 |
Long id = mapper.findAll().get(0).getId(); |
| 63 |
- mapper.updateChannelId(id, "mj", "chan-mj"); |
|
| 64 |
- mapper.updateChannelId(id, "law", "chan-law"); |
|
| 63 |
+ mapper.updateChannelIdMj(id, "chan-mj"); |
|
| 64 |
+ mapper.updateChannelIdLaw(id, "chan-law"); |
|
| 65 | 65 |
|
| 66 | 66 |
mapper.upsertBySeed(seedRow("001", "국제방송교류재단", "데이터정보화팀"));
|
| 67 | 67 |
|
... | ... | @@ -105,7 +105,7 @@ |
| 105 | 105 |
mapper.upsertBySeed(seedRow("002", "세종학당재단", "콘텐츠개발팀"));
|
| 106 | 106 |
Long id = mapper.findAll().get(0).getId(); |
| 107 | 107 |
|
| 108 |
- mapper.updateChannelId(id, "mj", "only-mj"); |
|
| 108 |
+ mapper.updateChannelIdMj(id, "only-mj"); |
|
| 109 | 109 |
|
| 110 | 110 |
Organization after = mapper.findById(id); |
| 111 | 111 |
assertThat(after.getChannelIdMj()).isEqualTo("only-mj");
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?