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.HealthPersonInfoMapper;
import com.bonus.canteen.core.health.domain.HealthPersonInfo;
import com.bonus.canteen.core.health.service.IHealthPersonInfoService;

/**
 * 人员健康情况Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class HealthPersonInfoServiceImpl implements IHealthPersonInfoService {
    @Autowired
    private HealthPersonInfoMapper healthPersonInfoMapper;

    /**
     * 查询人员健康情况
     * 
     * @param id 人员健康情况主键
     * @return 人员健康情况
     */
    @Override
    public HealthPersonInfo selectHealthPersonInfoById(Long id) {
        return healthPersonInfoMapper.selectHealthPersonInfoById(id);
    }

    /**
     * 查询人员健康情况列表
     * 
     * @param healthPersonInfo 人员健康情况
     * @return 人员健康情况
     */
    @Override
    public List<HealthPersonInfo> selectHealthPersonInfoList(HealthPersonInfo healthPersonInfo) {
        return healthPersonInfoMapper.selectHealthPersonInfoList(healthPersonInfo);
    }

    /**
     * 新增人员健康情况
     * 
     * @param healthPersonInfo 人员健康情况
     * @return 结果
     */
    @Override
    public int insertHealthPersonInfo(HealthPersonInfo healthPersonInfo) {
        healthPersonInfo.setCreateTime(DateUtils.getNowDate());
        try {
            return healthPersonInfoMapper.insertHealthPersonInfo(healthPersonInfo);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改人员健康情况
     * 
     * @param healthPersonInfo 人员健康情况
     * @return 结果
     */
    @Override
    public int updateHealthPersonInfo(HealthPersonInfo healthPersonInfo) {
        healthPersonInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthPersonInfoMapper.updateHealthPersonInfo(healthPersonInfo);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除人员健康情况
     * 
     * @param ids 需要删除的人员健康情况主键
     * @return 结果
     */
    @Override
    public int deleteHealthPersonInfoByIds(Long[] ids) {
        return healthPersonInfoMapper.deleteHealthPersonInfoByIds(ids);
    }

    /**
     * 删除人员健康情况信息
     * 
     * @param id 人员健康情况主键
     * @return 结果
     */
    @Override
    public int deleteHealthPersonInfoById(Long id) {
        return healthPersonInfoMapper.deleteHealthPersonInfoById(id);
    }
}
