package com.bonus.canteen.core.health.service.impl;

import java.util.List;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.houqin.utils.LeBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.health.mapper.HealthChronicMapper;
import com.bonus.canteen.core.health.domain.HealthChronic;
import com.bonus.canteen.core.health.service.IHealthChronicService;

/**
 * 慢性病Service业务层处理
 *
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class HealthChronicServiceImpl implements IHealthChronicService {
    @Autowired
    private HealthChronicMapper healthChronicMapper;

    /**
     * 查询慢性病
     *
     * @param chronicId 慢性病主键
     * @return 慢性病
     */
    @Override
    public HealthChronic selectHealthChronicByChronicId(Long chronicId) {
        return healthChronicMapper.selectHealthChronicByChronicId(chronicId);
    }

    /**
     * 查询慢性病列表
     *
     * @param healthChronic 慢性病
     * @return 慢性病
     */
    @Override
    public List<HealthChronic> selectHealthChronicList(HealthChronic healthChronic) {
        return healthChronicMapper.selectHealthChronicList(healthChronic);
    }

    /**
     * 新增慢性病
     *
     * @param healthChronic 慢性病
     * @return 结果
     */
    @Override
    public int insertHealthChronic(HealthChronic healthChronic) {
        healthChronic.setCreateTime(DateUtils.getNowDate());
        try {
            return healthChronicMapper.insertHealthChronic(healthChronic);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改慢性病
     *
     * @param healthChronic 慢性病
     * @return 结果
     */
    @Override
    public int updateHealthChronic(HealthChronic healthChronic) {
        healthChronic.setUpdateTime(DateUtils.getNowDate());
        try {
            return healthChronicMapper.updateHealthChronic(healthChronic);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除慢性病
     *
     * @param chronicIds 需要删除的慢性病主键
     * @return 结果
     */
    @Override
    public int deleteHealthChronicByChronicIds(Long[] chronicIds) {
        return healthChronicMapper.deleteHealthChronicByChronicIds(chronicIds);
    }

    /**
     * 删除慢性病信息
     *
     * @param chronicId 慢性病主键
     * @return 结果
     */
    @Override
    public int deleteHealthChronicByChronicId(Long chronicId) {
        return healthChronicMapper.deleteHealthChronicByChronicId(chronicId);
    }

    @Override
    public List<HealthChronic> dictHealthChronic(HealthChronic content) {

        return healthChronicMapper.selectHealthChronicList(content);
    }
}
