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.DmsBaseShutTypeMapper;
import com.hw.dms.domain.DmsBaseShutType;
import com.hw.dms.service.IDmsBaseShutTypeService;

/**
 * 停机类型信息Service业务层处理
 *
 * @author Open Platform
 * @date 2024-01-12
 */
@Service
public class DmsBaseShutTypeServiceImpl implements IDmsBaseShutTypeService
{
    @Autowired
    private DmsBaseShutTypeMapper dmsBaseShutTypeMapper;

    /**
     * 查询停机类型信息
     *
     * @param shutTypeId 停机类型信息主键
     * @return 停机类型信息
     */
    @Override
    public DmsBaseShutType selectDmsBaseShutTypeByShutTypeId(Long shutTypeId)
    {
        return dmsBaseShutTypeMapper.selectDmsBaseShutTypeByShutTypeId(shutTypeId);
    }

    /**
     * 查询停机类型信息列表
     *
     * @param dmsBaseShutType 停机类型信息
     * @return 停机类型信息
     */
    @Override
    public List<DmsBaseShutType> selectDmsBaseShutTypeList(DmsBaseShutType dmsBaseShutType)
    {
        return dmsBaseShutTypeMapper.selectDmsBaseShutTypeList(dmsBaseShutType);
    }

    /**
     * 新增停机类型信息
     *
     * @param dmsBaseShutType 停机类型信息
     * @return 结果
     */
    @Override
    public int insertDmsBaseShutType(DmsBaseShutType dmsBaseShutType)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseShutType.setIsFlag("1");
        dmsBaseShutType.setCreateBy(user.getUsername());
        dmsBaseShutType.setCreateTime(DateUtils.getNowDate());
        return dmsBaseShutTypeMapper.insertDmsBaseShutType(dmsBaseShutType);
    }

    /**
     * 修改停机类型信息
     *
     * @param dmsBaseShutType 停机类型信息
     * @return 结果
     */
    @Override
    public int updateDmsBaseShutType(DmsBaseShutType dmsBaseShutType)
    {
        LoginUser user  = new LoginUser();
        dmsBaseShutType.setUpdateBy(user.getUsername());
        dmsBaseShutType.setUpdateTime(DateUtils.getNowDate());
        return dmsBaseShutTypeMapper.updateDmsBaseShutType(dmsBaseShutType);
    }

    /**
     * 批量删除停机类型信息
     *
     * @param shutTypeIds 需要删除的停机类型信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseShutTypeByShutTypeIds(Long[] shutTypeIds)
    {
        return dmsBaseShutTypeMapper.deleteDmsBaseShutTypeByShutTypeIds(shutTypeIds);
    }

    /**
     * 删除停机类型信息信息
     *
     * @param shutTypeId 停机类型信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseShutTypeByShutTypeId(Long shutTypeId)
    {
        return dmsBaseShutTypeMapper.deleteDmsBaseShutTypeByShutTypeId(shutTypeId);
    }
}
