package com.srs.diagnostic.service.impl;
import java.util.List;

import com.srs.common.core.domain.model.LoginUser;
import com.srs.common.utils.SecurityUtils;
import com.srs.diagnostic.service.IDiaFillOutReportService;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.srs.diagnostic.mapper.DiaFillOutReportMapper;
import com.srs.diagnostic.domain.DiaFillOutReport;
/**
 * 诊断报告Service业务层处理
 *
 * @author srs
 * @date 2025-05-08
 */
@Service
public class DiaFillOutReportServiceImpl extends ServiceImpl<DiaFillOutReportMapper,DiaFillOutReport> implements IDiaFillOutReportService {

    @Autowired
    private DiaFillOutReportMapper diaFillOutReportMapper;
    /**
     * 查询诊断报告列表
     *
     * @param diaFillOutReport 诊断报告
     * @return 诊断报告
     */
    @Override
    public List<DiaFillOutReport> selectDiaFillOutReportList(DiaFillOutReport diaFillOutReport) {
        diaFillOutReport.setCollegeId(SecurityUtils.getDeptId());
        diaFillOutReport.setUserId(SecurityUtils.getUserId());

        return diaFillOutReportMapper.selectDiaFillOutReportList(diaFillOutReport);

    }

    /**
     * 查询学生填写详情
     *
     * @param
     * @return 诊断报告
     */
    @Override
    public List<DiaFillOutReport> selectDiaFillOutReportListUser(String stuNo) {
        return diaFillOutReportMapper.selectDiaFillOutReportListUser(stuNo);

    }

    /**
     * 批量新增诊断报告
     *
     * @param diaFillOutReport 批量新增诊断报告
     * @return 批量新增诊断报告
     */
    @Override
    public int insertDiaFillOutReport(DiaFillOutReport diaFillOutReport) {
        diaFillOutReport.setUserId(SecurityUtils.getUserId());
        return diaFillOutReportMapper.insertDiaFillOutReport(diaFillOutReport);
    }


    @Override
    public int updateDiaFillOutReportList(List<DiaFillOutReport> list) {
        //获取登录人遍历
        LoginUser user = SecurityUtils.getLoginUser();
        for (DiaFillOutReport diaFillOutReport : list) {
            diaFillOutReport.setUserId(user.getUserId());
        }

        return diaFillOutReportMapper.updateDiaFillOutReportList(list);
    }
    @Override
    public int insertDiaFillOutReportList(List<DiaFillOutReport> list) {

        //获取登录人遍历
        LoginUser user = SecurityUtils.getLoginUser();
        for (DiaFillOutReport diaFillOutReport : list) {
            diaFillOutReport.setUserId(user.getUserId());
        }
        return diaFillOutReportMapper.insertDiaFillOutReportList(list);
    }
}
