package com.bonus.canteen.core.nutrition.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.nutrition.mapper.HealthArticleChronicMapper;
import com.bonus.canteen.core.nutrition.domain.HealthArticleChronic;
import com.bonus.canteen.core.nutrition.service.IHealthArticleChronicService;

/**
 * 健康科普慢性病关联Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-13
 */
@Service
public class HealthArticleChronicServiceImpl implements IHealthArticleChronicService {
    @Autowired
    private HealthArticleChronicMapper healthArticleChronicMapper;

    /**
     * 查询健康科普慢性病关联
     * 
     * @param id 健康科普慢性病关联主键
     * @return 健康科普慢性病关联
     */
    @Override
    public HealthArticleChronic selectHealthArticleChronicById(Long id) {
        return healthArticleChronicMapper.selectHealthArticleChronicById(id);
    }

    /**
     * 查询健康科普慢性病关联列表
     * 
     * @param healthArticleChronic 健康科普慢性病关联
     * @return 健康科普慢性病关联
     */
    @Override
    public List<HealthArticleChronic> selectHealthArticleChronicList(HealthArticleChronic healthArticleChronic) {
        return healthArticleChronicMapper.selectHealthArticleChronicList(healthArticleChronic);
    }

    /**
     * 新增健康科普慢性病关联
     * 
     * @param healthArticleChronic 健康科普慢性病关联
     * @return 结果
     */
    @Override
    public int insertHealthArticleChronic(HealthArticleChronic healthArticleChronic) {
        healthArticleChronic.setCreateTime(DateUtils.getNowDate());
        try {
            return healthArticleChronicMapper.insertHealthArticleChronic(healthArticleChronic);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

    /**
     * 修改健康科普慢性病关联
     * 
     * @param healthArticleChronic 健康科普慢性病关联
     * @return 结果
     */
    @Override
    public int updateHealthArticleChronic(HealthArticleChronic healthArticleChronic) {
        healthArticleChronic.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthArticleChronicMapper.updateHealthArticleChronic(healthArticleChronic);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

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

    /**
     * 删除健康科普慢性病关联信息
     * 
     * @param id 健康科普慢性病关联主键
     * @return 结果
     */
    @Override
    public int deleteHealthArticleChronicById(Long id) {
        return healthArticleChronicMapper.deleteHealthArticleChronicById(id);
    }
}
