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.DmsBaseMaintStationMapper;
import com.hw.dms.domain.DmsBaseMaintStation;
import com.hw.dms.service.IDmsBaseMaintStationService;

/**
 * 保养部位信息Service业务层处理
 *
 * @author xins
 * @date 2024-01-05
 */
@Service
public class DmsBaseMaintStationServiceImpl implements IDmsBaseMaintStationService
{
    @Autowired
    private DmsBaseMaintStationMapper dmsBaseMaintStationMapper;

    /**
     * 查询保养部位信息
     *
     * @param maintStationId 保养部位信息主键
     * @return 保养部位信息
     */
    @Override
    public DmsBaseMaintStation selectDmsBaseMaintStationByMaintStationId(Long maintStationId)
    {
        return dmsBaseMaintStationMapper.selectDmsBaseMaintStationByMaintStationId(maintStationId);
    }

    /**
     * 查询保养部位信息列表
     *
     * @param dmsBaseMaintStation 保养部位信息
     * @return 保养部位信息
     */
    @Override
    public List<DmsBaseMaintStation> selectDmsBaseMaintStationList(DmsBaseMaintStation dmsBaseMaintStation)
    {
        return dmsBaseMaintStationMapper.selectDmsBaseMaintStationList(dmsBaseMaintStation);
    }

    /**
     * 新增保养部位信息
     *
     * @param dmsBaseMaintStation 保养部位信息
     * @return 结果
     */
    @Override
    public int insertDmsBaseMaintStation(DmsBaseMaintStation dmsBaseMaintStation)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseMaintStation.setIsFlag(1l);
        dmsBaseMaintStation.setCreateBy(user.getUsername());
        dmsBaseMaintStation.setCreateTime(DateUtils.getNowDate());
        return dmsBaseMaintStationMapper.insertDmsBaseMaintStation(dmsBaseMaintStation);
    }

    /**
     * 修改保养部位信息
     *
     * @param dmsBaseMaintStation 保养部位信息
     * @return 结果
     */
    @Override
    public int updateDmsBaseMaintStation(DmsBaseMaintStation dmsBaseMaintStation)
    {
        LoginUser user = SecurityUtils.getLoginUser();
        dmsBaseMaintStation.setUpdateBy(user.getUsername());
        dmsBaseMaintStation.setUpdateTime(DateUtils.getNowDate());
        return dmsBaseMaintStationMapper.updateDmsBaseMaintStation(dmsBaseMaintStation);
    }

    /**
     * 批量删除保养部位信息
     *
     * @param maintStationIds 需要删除的保养部位信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseMaintStationByMaintStationIds(Long[] maintStationIds)
    {
        return dmsBaseMaintStationMapper.deleteDmsBaseMaintStationByMaintStationIds(maintStationIds);
    }

    /**
     * 删除保养部位信息信息
     *
     * @param maintStationId 保养部位信息主键
     * @return 结果
     */
    @Override
    public int deleteDmsBaseMaintStationByMaintStationId(Long maintStationId)
    {
        return dmsBaseMaintStationMapper.deleteDmsBaseMaintStationByMaintStationId(maintStationId);
    }
}
