diff --git a/.agent/project.md b/.agent/project.md index 519f1ad..71fe693 100644 --- a/.agent/project.md +++ b/.agent/project.md @@ -33,7 +33,9 @@ - A normal item has no `t_part_item_sub` rows, and both base and data rows must use `part_item_sub_cd = NULL`. Never use `0` as a substitute for this `NULL` value. - An item with sub-items has one or more `t_part_item_sub` rows. Every non-null `part_item_sub_cd` in its base and data rows must reference a sub-item belonging to the same `(wave_cd, part_cd, part_item_cd)`. - Every survey code used by `t_part_item_base` or `t_part_item_data` must belong to the same Wave. Survey items must likewise belong to an existing `(wave_cd, survey_cd)`. +- Treat `t_survey.survey_color` as a required `VARCHAR(8)` value. Include it as the `survey_color` column in the Excel template/import contract and persist it with each survey. - Use `t_part_item_base` as the preferred source for determining which survey audiences apply to an item. Display the single matching `survey_alias` when only one audience applies; display `공통` when all defined audiences apply. +- Store an optional display string in `t_part_item_base.base_text` (`VARCHAR(128)`). Do not reconstruct it from `base_count`, and do not retain the removed `base_pre_text` or `base_post_text` fields in entities, Excel contracts, or query assembly. - Use the corresponding `*_order` column for API and screen ordering: `wave_info_order`, `survey_order`, `survey_item_order`, `file_order`, `part_order`, `part_item_order`, and `part_item_data_order`. Use `part_item_sub_cd` as the default sub-item order because the schema has no separate sub-item order column. - Use the same `t_part_item_data` rows for both chart and statistical-table views. `is_chart_visible` is a required Boolean column with database default `1`; statistical tables use every row, while charts omit categories and matching values whose flag is false. Do not introduce a separate table-data source that could diverge from chart values. - Avoid N+1 query patterns when assembling a Wave dashboard. Fetch the required Part, Item, Sub, Base, and Data ranges in batches and assemble the response hierarchy in the backend. @@ -45,6 +47,8 @@ - Revalidate Wave access on both Wave-detail and Part-detail requests. Throw a KriCommon `BusinessException` with forbidden status when a restricted user requests a closed Wave; frontend visibility is not an authorization boundary. - Assemble normal and sub-item results through one `resultGroups` response shape. A normal item has one group with `subItem = null`; an item with sub-items has one group per Sub in `part_item_sub_cd` order. - Return categories as objects containing `order`, `label`, and `chartVisible`, alongside complete survey value series. The frontend uses all category/value indexes for statistical tables and filters matching indexes only for chart rendering. Reject Excel imports when category labels, display orders, or chart-visibility flags differ between survey series in the same Item/Sub result group. +- Expose each survey's stored color as `color` in both Wave-detail survey objects and Part-detail series objects so the frontend uses one server-managed color mapping. +- Return the stored nullable `t_part_item_base.base_text` value unchanged as Part-detail `series[].baseText`; `baseCount` remains a separate numeric field. - When importing `part_item_data_value`, round to scale 10 with `RoundingMode.HALF_UP` before validating and storing it as `DECIMAL(14,10)`. Reject only values that still exceed precision 14 after rounding. - When `part_item_comment` is blank in Excel, store an empty string rather than `NULL` because the database column is required. Preserve the existing `NULL` semantics of other optional Excel fields. - Manage chart types as code enums. The initial supported type is `BAR`; Excel accepts its label `bar` case-insensitively, the database stores code `BAR`, and frontend responses return code `BAR`. Reject unsupported labels during Excel validation. diff --git a/AGENTS.md b/AGENTS.md index 85821a0..fedd166 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -295,7 +295,9 @@ When implementation is complete, report in Korean: - A normal item has no `t_part_item_sub` rows, and both base and data rows must use `part_item_sub_cd = NULL`. Never use `0` as a substitute for this `NULL` value. - An item with sub-items has one or more `t_part_item_sub` rows. Every non-null `part_item_sub_cd` in its base and data rows must reference a sub-item belonging to the same `(wave_cd, part_cd, part_item_cd)`. - Every survey code used by `t_part_item_base` or `t_part_item_data` must belong to the same Wave. Survey items must likewise belong to an existing `(wave_cd, survey_cd)`. +- Treat `t_survey.survey_color` as a required `VARCHAR(8)` value. Include it as the `survey_color` column in the Excel template/import contract and persist it with each survey. - Use `t_part_item_base` as the preferred source for determining which survey audiences apply to an item. Display the single matching `survey_alias` when only one audience applies; display `공통` when all defined audiences apply. +- Store an optional display string in `t_part_item_base.base_text` (`VARCHAR(128)`). Do not reconstruct it from `base_count`, and do not retain the removed `base_pre_text` or `base_post_text` fields in entities, Excel contracts, or query assembly. - Use the corresponding `*_order` column for API and screen ordering: `wave_info_order`, `survey_order`, `survey_item_order`, `file_order`, `part_order`, `part_item_order`, and `part_item_data_order`. Use `part_item_sub_cd` as the default sub-item order because the schema has no separate sub-item order column. - Use the same `t_part_item_data` rows for both chart and statistical-table views. `is_chart_visible` is a required Boolean column with database default `1`; statistical tables use every row, while charts omit categories and matching values whose flag is false. Do not introduce a separate table-data source that could diverge from chart values. - Avoid N+1 query patterns when assembling a Wave dashboard. Fetch the required Part, Item, Sub, Base, and Data ranges in batches and assemble the response hierarchy in the backend. @@ -307,6 +309,8 @@ When implementation is complete, report in Korean: - Revalidate Wave access on both Wave-detail and Part-detail requests. Throw a KriCommon `BusinessException` with forbidden status when a restricted user requests a closed Wave; frontend visibility is not an authorization boundary. - Assemble normal and sub-item results through one `resultGroups` response shape. A normal item has one group with `subItem = null`; an item with sub-items has one group per Sub in `part_item_sub_cd` order. - Return categories as objects containing `order`, `label`, and `chartVisible`, alongside complete survey value series. The frontend uses all category/value indexes for statistical tables and filters matching indexes only for chart rendering. Reject Excel imports when category labels, display orders, or chart-visibility flags differ between survey series in the same Item/Sub result group. +- Expose each survey's stored color as `color` in both Wave-detail survey objects and Part-detail series objects so the frontend uses one server-managed color mapping. +- Return the stored nullable `t_part_item_base.base_text` value unchanged as Part-detail `series[].baseText`; `baseCount` remains a separate numeric field. - When importing `part_item_data_value`, round to scale 10 with `RoundingMode.HALF_UP` before validating and storing it as `DECIMAL(14,10)`. Reject only values that still exceed precision 14 after rounding. - When `part_item_comment` is blank in Excel, store an empty string rather than `NULL` because the database column is required. Preserve the existing `NULL` semantics of other optional Excel fields. - Manage chart types as code enums. The initial supported type is `BAR`; Excel accepts its label `bar` case-insensitively, the database stores code `BAR`, and frontend responses return code `BAR`. Reject unsupported labels during Excel validation. diff --git a/src/main/java/com/kri/epolicy/dash/back/dto/excel/ExcelTemplateRows.java b/src/main/java/com/kri/epolicy/dash/back/dto/excel/ExcelTemplateRows.java index f7d2c33..2020a3a 100644 --- a/src/main/java/com/kri/epolicy/dash/back/dto/excel/ExcelTemplateRows.java +++ b/src/main/java/com/kri/epolicy/dash/back/dto/excel/ExcelTemplateRows.java @@ -42,6 +42,7 @@ public final class ExcelTemplateRows { @ExcelColumn(header = "survey_order", order = 2) private String surveyOrder; @ExcelColumn(header = "survey_title", order = 3) private String surveyTitle; @ExcelColumn(header = "survey_alias", order = 4) private String surveyAlias; + @ExcelColumn(header = "survey_color", order = 5) private String surveyColor; } @Getter @@ -89,8 +90,7 @@ public final class ExcelTemplateRows { @ExcelColumn(header = "survey_cd", order = 3) private String surveyCd; @ExcelColumn(header = "part_item_sub_cd", order = 4) private String partItemSubCd; @ExcelColumn(header = "base_count", order = 5) private String baseCount; - @ExcelColumn(header = "base_pre_text", order = 6) private String basePreText; - @ExcelColumn(header = "base_post_text", order = 7) private String basePostText; + @ExcelColumn(header = "base_text", order = 6) private String baseText; } @Getter diff --git a/src/main/java/com/kri/epolicy/dash/back/dto/request/ExcelData.java b/src/main/java/com/kri/epolicy/dash/back/dto/request/ExcelData.java index 32cc70f..e10e36e 100644 --- a/src/main/java/com/kri/epolicy/dash/back/dto/request/ExcelData.java +++ b/src/main/java/com/kri/epolicy/dash/back/dto/request/ExcelData.java @@ -38,7 +38,8 @@ public record ExcelData( Short surveyCd, Short surveyOrder, String surveyTitle, - String surveyAlias + String surveyAlias, + String surveyColor ) { } @@ -86,8 +87,7 @@ public record ExcelData( Short surveyCd, Short partItemSubCd, Integer baseCount, - String basePreText, - String basePostText + String baseText ) { } diff --git a/src/main/java/com/kri/epolicy/dash/back/dto/response/PartDetailResponse.java b/src/main/java/com/kri/epolicy/dash/back/dto/response/PartDetailResponse.java index ae95f42..2abb096 100644 --- a/src/main/java/com/kri/epolicy/dash/back/dto/response/PartDetailResponse.java +++ b/src/main/java/com/kri/epolicy/dash/back/dto/response/PartDetailResponse.java @@ -44,6 +44,7 @@ public record PartDetailResponse( public record Series( Short surveyCd, String label, + String color, Integer baseCount, String baseText, List values diff --git a/src/main/java/com/kri/epolicy/dash/back/dto/response/WaveDetailResponse.java b/src/main/java/com/kri/epolicy/dash/back/dto/response/WaveDetailResponse.java index 54ceab8..adc127c 100644 --- a/src/main/java/com/kri/epolicy/dash/back/dto/response/WaveDetailResponse.java +++ b/src/main/java/com/kri/epolicy/dash/back/dto/response/WaveDetailResponse.java @@ -17,6 +17,7 @@ public record WaveDetailResponse( Short surveyCd, String title, String alias, + String color, List items ) { } diff --git a/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TPartItemBaseEntity.java b/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TPartItemBaseEntity.java index 826229a..dc71428 100644 --- a/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TPartItemBaseEntity.java +++ b/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TPartItemBaseEntity.java @@ -46,12 +46,8 @@ public class TPartItemBaseEntity { private Integer baseCount; @Size(max = 128) - @Column(name = "base_pre_text", length = 128) - private String basePreText; - - @Size(max = 128) - @Column(name = "base_post_text", length = 128) - private String basePostText; + @Column(name = "base_text", length = 128) + private String baseText; -} +} \ No newline at end of file diff --git a/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TSurveyEntity.java b/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TSurveyEntity.java index 0bbc80f..edc4b13 100644 --- a/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TSurveyEntity.java +++ b/src/main/java/com/kri/epolicy/dash/back/persistence/entity/TSurveyEntity.java @@ -33,5 +33,10 @@ public class TSurveyEntity { @Column(name = "survey_alias", nullable = false, length = 32) private String surveyAlias; + @Size(max = 8) + @NotNull + @Column(name = "survey_color", nullable = false, length = 8) + private String surveyColor; + } \ No newline at end of file diff --git a/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportService.java b/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportService.java index 0a82f3f..8fc0efe 100644 --- a/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportService.java +++ b/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportService.java @@ -106,6 +106,7 @@ public class ExcelImportService { entity.setSurveyOrder(row.surveyOrder()); entity.setSurveyTitle(row.surveyTitle()); entity.setSurveyAlias(row.surveyAlias()); + entity.setSurveyColor(row.surveyColor()); return entity; }).toList()); @@ -157,8 +158,7 @@ public class ExcelImportService { entity.setSurveyCd(row.surveyCd()); entity.setPartItemSubCd(row.partItemSubCd()); entity.setBaseCount(row.baseCount()); - entity.setBasePreText(row.basePreText()); - entity.setBasePostText(row.basePostText()); + entity.setBaseText(row.baseText()); return entity; }).toList()); diff --git a/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportValidator.java b/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportValidator.java index d42b14d..1b29739 100644 --- a/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportValidator.java +++ b/src/main/java/com/kri/epolicy/dash/back/service/ExcelImportValidator.java @@ -60,7 +60,8 @@ public class ExcelImportValidator { row.getWaveInfoContent()), this::toWaveInfoRow), readRows(workbook, ExcelTemplateRows.SURVEY_SHEET, ExcelTemplateRows.Survey.class, row -> allBlank(row.getWaveCd(), row.getSurveyCd(), row.getSurveyOrder(), - row.getSurveyTitle(), row.getSurveyAlias()), this::toSurveyRow), + row.getSurveyTitle(), row.getSurveyAlias(), row.getSurveyColor()), + this::toSurveyRow), readRows(workbook, ExcelTemplateRows.SURVEY_ITEM_SHEET, ExcelTemplateRows.SurveyItem.class, row -> allBlank(row.getWaveCd(), row.getSurveyCd(), row.getSurveyItemOrder(), @@ -80,7 +81,7 @@ public class ExcelImportValidator { ExcelTemplateRows.PartItemBase.class, row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(), row.getSurveyCd(), row.getPartItemSubCd(), row.getBaseCount(), - row.getBasePreText(), row.getBasePostText()), this::toPartItemBaseRow), + row.getBaseText()), this::toPartItemBaseRow), readRows(workbook, ExcelTemplateRows.PART_ITEM_DATA_SHEET, ExcelTemplateRows.PartItemData.class, row -> allBlank(row.getWaveCd(), row.getPartCd(), row.getPartItemCd(), @@ -188,7 +189,8 @@ public class ExcelImportValidator { requiredShort(row.getSurveyCd(), "survey_cd", context), requiredShort(row.getSurveyOrder(), "survey_order", context), requiredString(row.getSurveyTitle(), "survey_title", 128, context), - requiredString(row.getSurveyAlias(), "survey_alias", 32, context) + requiredString(row.getSurveyAlias(), "survey_alias", 32, context), + requiredString(row.getSurveyColor(), "survey_color", 8, context) ); } @@ -251,8 +253,7 @@ public class ExcelImportValidator { requiredShort(row.getSurveyCd(), "survey_cd", context), optionalShort(row.getPartItemSubCd(), "part_item_sub_cd", context), requiredInteger(row.getBaseCount(), "base_count", context), - optionalString(row.getBasePreText(), "base_pre_text", 128, context), - optionalString(row.getBasePostText(), "base_post_text", 128, context) + optionalString(row.getBaseText(), "base_text", 128, context) ); } diff --git a/src/main/java/com/kri/epolicy/dash/back/service/WaveQueryService.java b/src/main/java/com/kri/epolicy/dash/back/service/WaveQueryService.java index 1bbdb9c..95835ae 100644 --- a/src/main/java/com/kri/epolicy/dash/back/service/WaveQueryService.java +++ b/src/main/java/com/kri/epolicy/dash/back/service/WaveQueryService.java @@ -32,13 +32,11 @@ import com.kri.epolicy.dash.back.persistence.repository.SurveyItemRepository; import com.kri.epolicy.dash.back.persistence.repository.SurveyRepository; import com.kri.epolicy.dash.back.persistence.repository.WaveInfoRepository; import com.kri.epolicy.dash.back.persistence.repository.WaveRepository; -import java.text.NumberFormat; import java.util.ArrayList; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -95,6 +93,7 @@ public class WaveQueryService { survey.getId().getSurveyCd(), survey.getSurveyTitle(), survey.getSurveyAlias(), + survey.getSurveyColor(), surveyItems.getOrDefault(survey.getId().getSurveyCd(), List.of()).stream() .map(item -> new WaveDetailResponse.SurveyItem( item.getSurveyItemTitle(), item.getSurveyItemContent())) @@ -222,8 +221,9 @@ public class WaveQueryService { return new Series( surveyCd, survey.getSurveyAlias(), + survey.getSurveyColor(), base == null ? null : base.getBaseCount(), - base == null ? null : formatBase(base), + base == null ? null : base.getBaseText(), dataBySurvey.get(surveyCd).stream() .sorted(Comparator.comparing(TPartItemDataEntity::getPartItemDataOrder)) .map(TPartItemDataEntity::getPartItemDataValue) @@ -251,13 +251,6 @@ public class WaveQueryService { return new Audience("SURVEY", label); } - private String formatBase(TPartItemBaseEntity base) { - String prefix = base.getBasePreText() == null ? "" : base.getBasePreText(); - String suffix = base.getBasePostText() == null ? "" : base.getBasePostText(); - String count = NumberFormat.getIntegerInstance(Locale.KOREA).format(base.getBaseCount()); - return prefix + count + suffix; - } - private WaveDetailResponse.FileDownload toFileDownload(Short waveCd, TFileEntity file) { String encodedFilename = UriUtils.encodePathSegment(file.getFileName(), java.nio.charset.StandardCharsets.UTF_8); String resourcePath = fileStorageProperties.getResourcePattern().replace("/**", "");