package com.bonus.canteen.core.health.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.health.mapper.HealthMedicalReportDetailMapper;
import com.bonus.canteen.core.health.domain.HealthMedicalReportDetail;
import com.bonus.canteen.core.health.service.IHealthMedicalReportDetailService;

/**
 * 体检报告项目明细Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class HealthMedicalReportDetailServiceImpl implements IHealthMedicalReportDetailService {
    @Autowired
    private HealthMedicalReportDetailMapper healthMedicalReportDetailMapper;

    /**
     * 查询体检报告项目明细
     * 
     * @param id 体检报告项目明细主键
     * @return 体检报告项目明细
     */
    @Override
    public HealthMedicalReportDetail selectHealthMedicalReportDetailById(Long id) {
        return healthMedicalReportDetailMapper.selectHealthMedicalReportDetailById(id);
    }

    /**
     * 查询体检报告项目明细列表
     * 
     * @param healthMedicalReportDetail 体检报告项目明细
     * @return 体检报告项目明细
     */
    @Override
    public List<HealthMedicalReportDetail> selectHealthMedicalReportDetailList(HealthMedicalReportDetail healthMedicalReportDetail) {
        return healthMedicalReportDetailMapper.selectHealthMedicalReportDetailList(healthMedicalReportDetail);
    }

    /**
     * 新增体检报告项目明细
     * 
     * @param healthMedicalReportDetail 体检报告项目明细
     * @return 结果
     */
    @Override
    public int insertHealthMedicalReportDetail(HealthMedicalReportDetail healthMedicalReportDetail) {
        healthMedicalReportDetail.setCreateTime(DateUtils.getNowDate());
        try {
            return healthMedicalReportDetailMapper.insertHealthMedicalReportDetail(healthMedicalReportDetail);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改体检报告项目明细
     * 
     * @param healthMedicalReportDetail 体检报告项目明细
     * @return 结果
     */
    @Override
    public int updateHealthMedicalReportDetail(HealthMedicalReportDetail healthMedicalReportDetail) {
        healthMedicalReportDetail.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthMedicalReportDetailMapper.updateHealthMedicalReportDetail(healthMedicalReportDetail);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除体检报告项目明细
     * 
     * @param ids 需要删除的体检报告项目明细主键
     * @return 结果
     */
    @Override
    public int deleteHealthMedicalReportDetailByIds(Long[] ids) {
        return healthMedicalReportDetailMapper.deleteHealthMedicalReportDetailByIds(ids);
    }

    /**
     * 删除体检报告项目明细信息
     * 
     * @param id 体检报告项目明细主键
     * @return 结果
     */
    @Override
    public int deleteHealthMedicalReportDetailById(Long id) {
        return healthMedicalReportDetailMapper.deleteHealthMedicalReportDetailById(id);
    }
}
