package com.ruoyi.satisfaction.api; import com.ruoyi.common.utils.poi.ExcelUtil; import java.util.Collections; import java.util.List; /** * 「问题详情占比」导出包(满意度模块对外暴露的导出载体)。 *

* 为什么需要它:随访导出({@code ServiceSubtaskController#patItemExport})需要把满意度占比行 * 交给 {@code ExcelUtil.exportExcelTwoSheetWithChart(...)},而这个方法要求同时给出 * 「行列表 + 行类型 {@code Class} + 图表构建器」。如果让调用方自己拿这三样, * 它就必须 import 满意度模块内部的 {@code domain} 与 {@code support} 包, * 违反「其它模块只能用本模块暴露的 api」的约束。 *

* 因此这里把三样东西打包成一个 api 层的值对象: *

* 调用方只需 import 本类与 {@link SatisfactionFacade} 即可完成整个导出。 */ public class SatisfactionExportBundle { /** * 模块关闭时使用的空导出包(无行、无图表构建器) */ private static final SatisfactionExportBundle EMPTY = new SatisfactionExportBundle(Collections.emptyList(), null, null); private final List rows; private final Class rowClass; private final ExcelUtil.ChartSheetBuilder chartBuilder; public SatisfactionExportBundle(List rows, Class rowClass, ExcelUtil.ChartSheetBuilder chartBuilder) { this.rows = rows == null ? Collections.emptyList() : rows; this.rowClass = rowClass; this.chartBuilder = chartBuilder; } /** * 模块关闭时的空包(行列表为空、行类型与图表构建器为 null)。 *

配合 {@code ExcelUtil} 的"行列表为空则跳过该 Sheet"行为,导出可以照常完成。 */ public static SatisfactionExportBundle empty() { return EMPTY; } /** * 占比行(调用方只作透传,不建议自行解析其字段语义) */ public List getRows() { return rows; } /** * 占比行的类型(透传给 {@code ExcelUtil} 用;模块关闭时为 null) */ public Class getRowClass() { return rowClass; } /** * 柱状图 Sheet 构建器(透传给 {@code ExcelUtil} 用;无数据或模块关闭时为 null) */ public ExcelUtil.ChartSheetBuilder getChartBuilder() { return chartBuilder; } /** * 是否没有可导出的行 */ public boolean isEmpty() { return rows.isEmpty(); } }