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.HealthPopularArticleChronicMapper;
import com.bonus.canteen.core.health.domain.HealthPopularArticleChronic;
import com.bonus.canteen.core.health.service.IHealthPopularArticleChronicService;

/**
 * 营养科普慢性病关联Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class HealthPopularArticleChronicServiceImpl implements IHealthPopularArticleChronicService {
    @Autowired
    private HealthPopularArticleChronicMapper healthPopularArticleChronicMapper;

    /**
     * 查询营养科普慢性病关联
     * 
     * @param id 营养科普慢性病关联主键
     * @return 营养科普慢性病关联
     */
    @Override
    public HealthPopularArticleChronic selectHealthPopularArticleChronicById(Long id) {
        return healthPopularArticleChronicMapper.selectHealthPopularArticleChronicById(id);
    }

    /**
     * 查询营养科普慢性病关联列表
     * 
     * @param healthPopularArticleChronic 营养科普慢性病关联
     * @return 营养科普慢性病关联
     */
    @Override
    public List<HealthPopularArticleChronic> selectHealthPopularArticleChronicList(HealthPopularArticleChronic healthPopularArticleChronic) {
        return healthPopularArticleChronicMapper.selectHealthPopularArticleChronicList(healthPopularArticleChronic);
    }

    /**
     * 新增营养科普慢性病关联
     * 
     * @param healthPopularArticleChronic 营养科普慢性病关联
     * @return 结果
     */
    @Override
    public int insertHealthPopularArticleChronic(HealthPopularArticleChronic healthPopularArticleChronic) {
        healthPopularArticleChronic.setCreateTime(DateUtils.getNowDate());
        try {
            return healthPopularArticleChronicMapper.insertHealthPopularArticleChronic(healthPopularArticleChronic);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改营养科普慢性病关联
     * 
     * @param healthPopularArticleChronic 营养科普慢性病关联
     * @return 结果
     */
    @Override
    public int updateHealthPopularArticleChronic(HealthPopularArticleChronic healthPopularArticleChronic) {
        healthPopularArticleChronic.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthPopularArticleChronicMapper.updateHealthPopularArticleChronic(healthPopularArticleChronic);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

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

    /**
     * 删除营养科普慢性病关联信息
     * 
     * @param id 营养科普慢性病关联主键
     * @return 结果
     */
    @Override
    public int deleteHealthPopularArticleChronicById(Long id) {
        return healthPopularArticleChronicMapper.deleteHealthPopularArticleChronicById(id);
    }
}
