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.HealthPersonInfoChronicMapper;
import com.bonus.canteen.core.health.domain.HealthPersonInfoChronic;
import com.bonus.canteen.core.health.service.IHealthPersonInfoChronicService;

/**
 * 人员健康慢性病关联Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class HealthPersonInfoChronicServiceImpl implements IHealthPersonInfoChronicService {
    @Autowired
    private HealthPersonInfoChronicMapper healthPersonInfoChronicMapper;

    /**
     * 查询人员健康慢性病关联
     * 
     * @param id 人员健康慢性病关联主键
     * @return 人员健康慢性病关联
     */
    @Override
    public HealthPersonInfoChronic selectHealthPersonInfoChronicById(Long id) {
        return healthPersonInfoChronicMapper.selectHealthPersonInfoChronicById(id);
    }

    /**
     * 查询人员健康慢性病关联列表
     * 
     * @param healthPersonInfoChronic 人员健康慢性病关联
     * @return 人员健康慢性病关联
     */
    @Override
    public List<HealthPersonInfoChronic> selectHealthPersonInfoChronicList(HealthPersonInfoChronic healthPersonInfoChronic) {
        return healthPersonInfoChronicMapper.selectHealthPersonInfoChronicList(healthPersonInfoChronic);
    }

    /**
     * 新增人员健康慢性病关联
     * 
     * @param healthPersonInfoChronic 人员健康慢性病关联
     * @return 结果
     */
    @Override
    public int insertHealthPersonInfoChronic(HealthPersonInfoChronic healthPersonInfoChronic) {
        healthPersonInfoChronic.setCreateTime(DateUtils.getNowDate());
        try {
            return healthPersonInfoChronicMapper.insertHealthPersonInfoChronic(healthPersonInfoChronic);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改人员健康慢性病关联
     * 
     * @param healthPersonInfoChronic 人员健康慢性病关联
     * @return 结果
     */
    @Override
    public int updateHealthPersonInfoChronic(HealthPersonInfoChronic healthPersonInfoChronic) {
        healthPersonInfoChronic.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthPersonInfoChronicMapper.updateHealthPersonInfoChronic(healthPersonInfoChronic);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除人员健康慢性病关联
     * 
     * @param ids 需要删除的人员健康慢性病关联主键
     * @return 结果
     */
    @Override
    public int deleteHealthPersonInfoChronicByIds(Long[] ids) {
        return healthPersonInfoChronicMapper.deleteHealthPersonInfoChronicByIds(ids);
    }

    /**
     * 删除人员健康慢性病关联信息
     * 
     * @param id 人员健康慢性病关联主键
     * @return 结果
     */
    @Override
    public int deleteHealthPersonInfoChronicById(Long id) {
        return healthPersonInfoChronicMapper.deleteHealthPersonInfoChronicById(id);
    }
}
