package org.qinan.safetyeval.app.support;

import org.qinan.safetyeval.domain.constant.QualFilingMaterialUploadStatusEnum;
import org.qinan.safetyeval.domain.entity.QualFilingMaterialEntity;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 备案材料标准模板（对齐原型 10 项）
 */
@Component
public class QualFilingMaterialTemplateProvider {

    public List<QualFilingMaterialEntity> buildTemplate(Long filingId) {
        List<QualFilingMaterialEntity> list = new ArrayList<>();
        list.add(item(filingId, 1, "申请材料目录（原件）", "pdf", "纸质版扫描件", null));
        list.add(item(filingId, 2, "申请书（原件）", "pdf", "纸质版扫描件", "法定代表人亲笔签名并加盖单位公章"));
        list.add(item(filingId, 3, "法人证明（复印件）", "pdf", "纸质版扫描件", "营业执照或事业单位法人证书等"));
        list.add(item(filingId, 4, "三年内无重大违法失信记录查询证明（原件）", "pdf", "纸质版扫描件", "法定代表人亲笔签名并加盖单位公章"));
        list.add(item(filingId, 5, "法定代表人承诺书（原件）", "pdf", "纸质版扫描件", "法定代表人亲笔签名"));
        list.add(item(filingId, 6, "固定资产法定证明材料或书面承诺", "pdf", "纸质版扫描件", null));
        list.add(item(filingId, 7, "工作场所及档案室面积证明资料（复印件）", "pdf", "纸质版扫描件", "房产证、租赁协议等"));
        list.add(item(filingId, 8, "安全评价师专业能力证明（彩色复印件）", "pdf", "纸质版扫描件", "学历证书、职称证及其他相关证明材料"));
        list.add(item(filingId, 9, "相关负责人证明材料（复印件）", "pdf", "纸质版扫描件", "任命文件、简历、职称证等"));
        list.add(item(filingId, 10, "机构内部管理制度（非受控版）", "pdf", "纸质版扫描件", null));
        return list;
    }

    private QualFilingMaterialEntity item(Long filingId, int sortOrder, String content, String format,
                                          String attachmentDesc, String remark) {
        QualFilingMaterialEntity entity = new QualFilingMaterialEntity();
        entity.setFilingId(filingId);
        entity.setSortOrder(sortOrder);
        entity.setMaterialContent(content);
        entity.setMaterialFormat(format);
        entity.setAttachmentDesc(attachmentDesc);
        entity.setMaterialRemark(remark);
        entity.setRequiredFlag(1);
        entity.setUploadStatusCode(QualFilingMaterialUploadStatusEnum.PENDING.getCode());
        entity.setUploadStatusName(QualFilingMaterialUploadStatusEnum.PENDING.getName());
        return entity;
    }
}
