package com.hw.dms.service.impl;

import java.util.List;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.dms.mapper.DmsBaseShutReasonMapper;
import com.hw.dms.domain.DmsBaseShutReason;
import com.hw.dms.service.IDmsBaseShutReasonService;

/**
 * 停机原因信息Service业务层处理
 *
 * @author Open Platform
 * @date 2024-01-12
 */
@Service
public class DmsBaseShutReasonServiceImpl implements IDmsBaseShutReasonService
{
    @Autowired
    private DmsBaseShutReasonMapper dmsBaseShutReasonMapper;

    /**
     * 查询停机原因信息
     *
     * @param shutReasonId 停机原因信息主键
     * @return 停机原因信息
     */
    @Override
    public DmsBaseShutReason selectDmsBaseShutReasonByShutReasonId(Long shutReasonId)
    {
        return dmsBaseShutReasonMapper.selectDmsBaseShutReasonByShutReasonId(shutReasonId);
    }

    /**
     * 查询停机原因信息列表
     *
     * @param dmsBaseShutReason 停机原因信息
     * @return 停机原因信息
     */
    @Override
    public List<DmsBaseShutReason> selectDmsBaseShutReasonList(DmsBaseShutReason dmsBaseShutReason)
    {
        return dmsBaseShutReasonMapper.selectDmsBaseShutReasonList(dmsBaseShutReason);
    }

    /**
     * 新增停机原因信息
     *
     * @param dmsBaseShutReason 停机原因信息
     * @return 结果
     */
    @Override
    public int insertDmsBaseShutReason(DmsBaseShutReason dmsBaseShutReason)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseShutReason.setIsFlag("1");
        dmsBaseShutReason.setCreateBy(user.getUsername());
        dmsBaseShutReason.setCreateTime(DateUtils.getNowDate());
        return dmsBaseShutReasonMapper.insertDmsBaseShutReason(dmsBaseShutReason);
    }

    /**
     * 修改停机原因信息
     *
     * @param dmsBaseShutReason 停机原因信息
     * @return 结果
     */
    @Override
    public int updateDmsBaseShutReason(DmsBaseShutReason dmsBaseShutReason)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseShutReason.setUpdateBy(user.getUsername());
        dmsBaseShutReason.setUpdateTime(DateUtils.getNowDate());
        return dmsBaseShutReasonMapper.updateDmsBaseShutReason(dmsBaseShutReason);
    }

    /**
     * 批量删除停机原因信息
     *
     * @param shutReasonIds 需要删除的停机原因信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseShutReasonByShutReasonIds(Long[] shutReasonIds)
    {
        return dmsBaseShutReasonMapper.deleteDmsBaseShutReasonByShutReasonIds(shutReasonIds);
    }

    /**
     * 删除停机原因信息信息
     *
     * @param shutReasonId 停机原因信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseShutReasonByShutReasonId(Long shutReasonId)
    {
        return dmsBaseShutReasonMapper.deleteDmsBaseShutReasonByShutReasonId(shutReasonId);
    }
}
