package com.hw.dms.service.impl;

import java.util.List;
import com.hw.common.core.utils.DateUtils;
import com.hw.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.dms.mapper.DmsBaseDeviceSuplierMapper;
import com.hw.dms.domain.DmsBaseDeviceSuplier;
import com.hw.dms.service.IDmsBaseDeviceSuplierService;

/**
 * 设备供应商信息Service业务层处理
 *
 * @author xins
 * @date 2023-12-28
 */
@Service
public class DmsBaseDeviceSuplierServiceImpl implements IDmsBaseDeviceSuplierService
{
    @Autowired
    private DmsBaseDeviceSuplierMapper dmsBaseDeviceSuplierMapper;

    /**
     * 查询设备供应商信息
     *
     * @param supplierId 设备供应商信息主键
     * @return 设备供应商信息
     */
    @Override
    public DmsBaseDeviceSuplier selectDmsBaseDeviceSuplierBySupplierId(Long supplierId)
    {
        return dmsBaseDeviceSuplierMapper.selectDmsBaseDeviceSuplierBySupplierId(supplierId);
    }

    /**
     * 查询设备供应商信息列表
     *
     * @param dmsBaseDeviceSuplier 设备供应商信息
     * @return 设备供应商信息
     */
    @Override
    public List<DmsBaseDeviceSuplier> selectDmsBaseDeviceSuplierList(DmsBaseDeviceSuplier dmsBaseDeviceSuplier)
    {
        return dmsBaseDeviceSuplierMapper.selectDmsBaseDeviceSuplierList(dmsBaseDeviceSuplier);
    }

    /**
     * 新增设备供应商信息
     *
     * @param dmsBaseDeviceSuplier 设备供应商信息
     * @return 结果
     */
    @Override
    public int insertDmsBaseDeviceSuplier(DmsBaseDeviceSuplier dmsBaseDeviceSuplier)
    {
        LoginUser loginUser = new LoginUser();
        dmsBaseDeviceSuplier.setCreateBy(loginUser.getUsername());
        //添加标识
        dmsBaseDeviceSuplier.setIsFlag(1l);
        dmsBaseDeviceSuplier.setCreateTime(DateUtils.getNowDate());
        return dmsBaseDeviceSuplierMapper.insertDmsBaseDeviceSuplier(dmsBaseDeviceSuplier);
    }

    /**
     * 修改设备供应商信息
     *
     * @param dmsBaseDeviceSuplier 设备供应商信息
     * @return 结果
     */
    @Override
    public int updateDmsBaseDeviceSuplier(DmsBaseDeviceSuplier dmsBaseDeviceSuplier)
    {
        LoginUser loginUser = new LoginUser();
        dmsBaseDeviceSuplier.setUpdateBy(loginUser.getUsername());
        dmsBaseDeviceSuplier.setUpdateTime(DateUtils.getNowDate());
        return dmsBaseDeviceSuplierMapper.updateDmsBaseDeviceSuplier(dmsBaseDeviceSuplier);
    }

    /**
     * 批量删除设备供应商信息
     *
     * @param supplierIds 需要删除的设备供应商信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseDeviceSuplierBySupplierIds(Long[] supplierIds)
    {
        return dmsBaseDeviceSuplierMapper.deleteDmsBaseDeviceSuplierBySupplierIds(supplierIds);
    }

    /**
     * 删除设备供应商信息信息
     *
     * @param supplierId 设备供应商信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseDeviceSuplierBySupplierId(Long supplierId)
    {
        return dmsBaseDeviceSuplierMapper.deleteDmsBaseDeviceSuplierBySupplierId(supplierId);
    }

    @Override
    public List<DmsBaseDeviceSuplier> selectDmsBaseDeviceSuplierDeviceId(Long deviceId) {

        return dmsBaseDeviceSuplierMapper.selectDmsBaseDeviceSuplierDeviceId(deviceId);
    }
}
