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.HealthMedicalReportTemplateMapper;
import com.bonus.canteen.core.health.domain.HealthMedicalReportTemplate;
import com.bonus.canteen.core.health.service.IHealthMedicalReportTemplateService;

/**
 * 体检报告模板Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class HealthMedicalReportTemplateServiceImpl implements IHealthMedicalReportTemplateService {
    @Autowired
    private HealthMedicalReportTemplateMapper healthMedicalReportTemplateMapper;

    /**
     * 查询体检报告模板
     * 
     * @param id 体检报告模板主键
     * @return 体检报告模板
     */
    @Override
    public HealthMedicalReportTemplate selectHealthMedicalReportTemplateById(Long id) {
        return healthMedicalReportTemplateMapper.selectHealthMedicalReportTemplateById(id);
    }

    /**
     * 查询体检报告模板列表
     * 
     * @param healthMedicalReportTemplate 体检报告模板
     * @return 体检报告模板
     */
    @Override
    public List<HealthMedicalReportTemplate> selectHealthMedicalReportTemplateList(HealthMedicalReportTemplate healthMedicalReportTemplate) {
        return healthMedicalReportTemplateMapper.selectHealthMedicalReportTemplateList(healthMedicalReportTemplate);
    }

    /**
     * 新增体检报告模板
     * 
     * @param healthMedicalReportTemplate 体检报告模板
     * @return 结果
     */
    @Override
    public int insertHealthMedicalReportTemplate(HealthMedicalReportTemplate healthMedicalReportTemplate) {
        healthMedicalReportTemplate.setCreateTime(DateUtils.getNowDate());
        try {
            return healthMedicalReportTemplateMapper.insertHealthMedicalReportTemplate(healthMedicalReportTemplate);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改体检报告模板
     * 
     * @param healthMedicalReportTemplate 体检报告模板
     * @return 结果
     */
    @Override
    public int updateHealthMedicalReportTemplate(HealthMedicalReportTemplate healthMedicalReportTemplate) {
        healthMedicalReportTemplate.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthMedicalReportTemplateMapper.updateHealthMedicalReportTemplate(healthMedicalReportTemplate);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除体检报告模板
     * 
     * @param ids 需要删除的体检报告模板主键
     * @return 结果
     */
    @Override
    public int deleteHealthMedicalReportTemplateByIds(Long[] ids) {
        return healthMedicalReportTemplateMapper.deleteHealthMedicalReportTemplateByIds(ids);
    }

    /**
     * 删除体检报告模板信息
     * 
     * @param id 体检报告模板主键
     * @return 结果
     */
    @Override
    public int deleteHealthMedicalReportTemplateById(Long id) {
        return healthMedicalReportTemplateMapper.deleteHealthMedicalReportTemplateById(id);
    }
}
