package com.ruoyi.os.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.os.mapper.HealthcareOsComplaintsMapper;
import com.ruoyi.os.domain.HealthcareOsComplaints;
import com.ruoyi.os.service.IHealthcareOsComplaintsService;

/**
 * 主诉Service业务层处理
 *
 * @author 何顺
 * @date 2024-09-24
 */
@Service
public class HealthcareOsComplaintsServiceImpl implements IHealthcareOsComplaintsService
{
    @Autowired
    private HealthcareOsComplaintsMapper healthcareOsComplaintsMapper;

    /**
     * 查询主诉
     *
     * @param id 主诉主键
     * @return 主诉
     */
    @Override
    public HealthcareOsComplaints selectHealthcareOsComplaintsById(Long id)
    {
        return healthcareOsComplaintsMapper.selectHealthcareOsComplaintsById(id);
    }

    /**
     * 查询主诉列表
     *
     * @param healthcareOsComplaints 主诉
     * @return 主诉
     */
    @Override
    public List<HealthcareOsComplaints> selectHealthcareOsComplaintsList(HealthcareOsComplaints healthcareOsComplaints)
    {
        return healthcareOsComplaintsMapper.selectHealthcareOsComplaintsList(healthcareOsComplaints);
    }

    /**
     * 新增主诉
     *
     * @param healthcareOsComplaints 主诉
     * @return 结果
     */
    @Override
    public int insertHealthcareOsComplaints(HealthcareOsComplaints healthcareOsComplaints)
    {
        healthcareOsComplaints.setCreateTime(DateUtils.getNowDate());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        healthcareOsComplaints.setCreateBy(loginUser.getUsername());
        return healthcareOsComplaintsMapper.insertHealthcareOsComplaints(healthcareOsComplaints);
    }

    /**
     * 修改主诉
     *
     * @param healthcareOsComplaints 主诉
     * @return 结果
     */
    @Override
    public int updateHealthcareOsComplaints(HealthcareOsComplaints healthcareOsComplaints)
    {
        healthcareOsComplaints.setUpdateTime(DateUtils.getNowDate());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        healthcareOsComplaints.setUpdateBy(loginUser.getUsername());
        return healthcareOsComplaintsMapper.updateHealthcareOsComplaints(healthcareOsComplaints);
    }

    /**
     * 批量删除主诉
     *
     * @param ids 需要删除的主诉主键
     * @return 结果
     */
    @Override
    public int deleteHealthcareOsComplaintsByIds(Long[] ids)
    {
        return healthcareOsComplaintsMapper.deleteHealthcareOsComplaintsByIds(ids);
    }

    /**
     * 删除主诉信息
     *
     * @param id 主诉主键
     * @return 结果
     */
    @Override
    public int deleteHealthcareOsComplaintsById(Long id)
    {
        return healthcareOsComplaintsMapper.deleteHealthcareOsComplaintsById(id);
    }
}
