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.DmsRecordShutDownMapper;
import com.hw.dms.domain.DmsRecordShutDown;
import com.hw.dms.service.IDmsRecordShutDownService;

/**
 * 停机记录Service业务层处理
 *
 * @author Open Platform
 * @date 2024-01-15
 */
@Service
public class DmsRecordShutDownServiceImpl implements IDmsRecordShutDownService
{
    @Autowired
    private DmsRecordShutDownMapper dmsRecordShutDownMapper;

    /**
     * 查询停机记录
     *
     * @param recordShutDownId 停机记录主键
     * @return 停机记录
     */
    @Override
    public DmsRecordShutDown selectDmsRecordShutDownByRecordShutDownId(Long recordShutDownId)
    {
        return dmsRecordShutDownMapper.selectDmsRecordShutDownByRecordShutDownId(recordShutDownId);
    }

    /**
     * 查询停机记录列表
     *
     * @param dmsRecordShutDown 停机记录
     * @return 停机记录
     */
    @Override
    public List<DmsRecordShutDown> selectDmsRecordShutDownList(DmsRecordShutDown dmsRecordShutDown)
    {
        return dmsRecordShutDownMapper.selectDmsRecordShutDownList(dmsRecordShutDown);
    }

    /**
     * 新增停机记录
     *
     * @param dmsRecordShutDown 停机记录
     * @return 结果
     */
    @Override
    public int insertDmsRecordShutDown(DmsRecordShutDown dmsRecordShutDown)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsRecordShutDown.setIsFlag(1l);
        dmsRecordShutDown.setCreateBy(user.getUsername());
        dmsRecordShutDown.setCreateTime(DateUtils.getNowDate());
        return dmsRecordShutDownMapper.insertDmsRecordShutDown(dmsRecordShutDown);
    }

    /**
     * 修改停机记录
     *
     * @param dmsRecordShutDown 停机记录
     * @return 结果
     */
    @Override
    public int updateDmsRecordShutDown(DmsRecordShutDown dmsRecordShutDown)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsRecordShutDown.setUpdateBy(user.getUsername());
        dmsRecordShutDown.setUpdateTime(DateUtils.getNowDate());
        return dmsRecordShutDownMapper.updateDmsRecordShutDown(dmsRecordShutDown);
    }

    /**
     * 批量删除停机记录
     *
     * @param recordShutDownIds 需要删除的停机记录主键
     * @return 结果
     */
    @Override
    public int deleteDmsRecordShutDownByRecordShutDownIds(Long[] recordShutDownIds)
    {
        return dmsRecordShutDownMapper.deleteDmsRecordShutDownByRecordShutDownIds(recordShutDownIds);
    }

    /**
     * 删除停机记录信息
     *
     * @param recordShutDownId 停机记录主键
     * @return 结果
     */
    @Override
    public int deleteDmsRecordShutDownByRecordShutDownId(Long recordShutDownId)
    {
        return dmsRecordShutDownMapper.deleteDmsRecordShutDownByRecordShutDownId(recordShutDownId);
    }
}
