package com.ruoyi.ibs.visit.service;

import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.ibs.visit.domain.dto.VisitQualityReportDTO;
import com.ruoyi.ibs.visit.domain.entity.VisitQualityReport;
import com.ruoyi.ibs.visit.mapper.VisitQualityReportMapper;
import com.ruoyi.system.domain.OssFileUploadDTO;
import com.ruoyi.system.enums.OssFileEnum;
import com.ruoyi.system.service.OssFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author 吴凯程
 * @Date 2025/11/21
 **/
@Service
public class VisitQualityReportService {

    @Resource
    private VisitQualityReportMapper visitQualityReportMapper;

    @Resource
    private OssFileService ossFileService;

    public String uploadVisitReport(VisitQualityReportDTO visitQualityReportDTO) {
        OssFileUploadDTO ossFileUploadDTO = new OssFileUploadDTO();
        ossFileUploadDTO.setFile(visitQualityReportDTO.getFile());
        ossFileUploadDTO.setOssFileEnum(OssFileEnum.VISIT_REPORT_875);
        String fileId = ossFileService.uploadFileToOss(ossFileUploadDTO);

        VisitQualityReport visitQualityReport = new VisitQualityReport();
        BeanUtils.copyBeanProp(visitQualityReportDTO, visitQualityReport);
        visitQualityReport.setFileId(fileId);
        visitQualityReportMapper.insert(visitQualityReport);
        return "上传成功";
    }

}
