
package com.jeelowcode.core.framework.enhance.example.report.xtsy;

import com.jeelowcode.tool.framework.common.util.json.JsonUtils;
import com.jeelowcode.core.framework.config.aspect.enhancereport.model.EnhanceReportContext;
import com.jeelowcode.core.framework.config.aspect.enhancereport.plugin.ReportAfterAdvicePlugin;
import com.jeelowcode.core.framework.utils.Func;
import com.jeelowcode.core.framework.utils.FuncWeb;
import com.jeelowcode.framework.utils.utils.JeeLowCodeUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 报表-系统首页-单表
 */
@Component("exampleXtsyLineReportEnhance")
public class ExampleXtsyLineReportEnhance implements ReportAfterAdvicePlugin {

    @Override
    public void execute(EnhanceReportContext enhanceContext) {
        List<Map<String, Object>> records = enhanceContext.getResult().getRecords();
        if (Func.isEmpty(records)) {
            return;
        }
        String jsonStr = JeeLowCodeUtils.getMap2Str(records.get(0), "value");
        List<Map<String, Object>> list = (List<Map<String, Object>>) (List<?>) JsonUtils.parseArray(jsonStr, Map.class);
        FuncWeb.setReportResult(enhanceContext, list);
    }
}
