package org.example.mybatisplus.model.auto;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.example.mybatisplus.module.BasicInfo;
import org.example.mybatisplus.module.vo.BasicInfoCheck;
import org.example.mybatisplus.module.vo.BasicInfoScore;

import lombok.Data;

@Data
public class CmsEnterpriseRiskInfoCheckBO {
    // key: checkItemLabel
    private Map<String, CmsEnterpriseRiskInfoCheckItem> mpCmsEnterpriseRiskInfoCheckItem =
        Collections.emptyMap();
    private CmsEnterpriseRiskInfoCheck cmsEnterpriseRiskInfoCheck =
        new CmsEnterpriseRiskInfoCheck();
    private Map<String, CmsEntRiskInfoCktItemCategory> mpCmsEntRiskInfoCktItemCategory =
        Collections.emptyMap();

    public void fillBasicInfoVO(BasicInfo basicInfo) {
        List<BasicInfoCheck> checks = new ArrayList<>();
        for(String label: new String[] {"donation_revenue_scale", "net_worth_rating", "operation_years", "moca_rating"}) {
            BasicInfoCheck check = new BasicInfoCheck();
            check.setName(mpCmsEnterpriseRiskInfoCheckItem.get(label).getItemName());
            check.setDesc(mpCmsEnterpriseRiskInfoCheckItem.get(label).getDescription());
            check.setFact(mpCmsEnterpriseRiskInfoCheckItem.get(label).getActualValue());
            check.setResult(mpCmsEnterpriseRiskInfoCheckItem.get(label).getBizResultStr());
            check.setScore(mpCmsEnterpriseRiskInfoCheckItem.get(label).getScore());
            checks.add(check);
        }
        basicInfo.setBasicInfoChecks(checks);
        
        basicInfo.setBasicInfoScore(new BasicInfoScore(
            mpCmsEntRiskInfoCktItemCategory.get("BASIC").getScore(),
            cmsEnterpriseRiskInfoCheck.getRemarks(),
            cmsEnterpriseRiskInfoCheck.getAdvice()
        ));
    }
}
