package com.ruoyi.shipping.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shipping.mapper.TVesselMapper;
import com.ruoyi.shipping.domain.TVessel;
import com.ruoyi.shipping.service.ITVesselService;

/**
 * 船名Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-04-02
 */
@Service
public class TVesselServiceImpl implements ITVesselService 
{
    @Autowired
    private TVesselMapper tVesselMapper;

    /**
     * 查询船名
     * 
     * @param fId 船名ID
     * @return 船名
     */
    @Override
    public TVessel selectTVesselById(Long fId)
    {
        return tVesselMapper.selectTVesselById(fId);
    }

    /**
     * 查询船名列表
     * 
     * @param tVessel 船名
     * @return 船名
     */
    @Override
    public List<TVessel> selectTVesselList(TVessel tVessel)
    {
        return tVesselMapper.selectTVesselList(tVessel);
    }

    /**
     * 新增船名
     * 
     * @param tVessel 船名
     * @return 结果
     */
    @Override
    public int insertTVessel(TVessel tVessel)
    {
        tVessel.setCreateTime(DateUtils.getNowDate());
        tVessel.setCreateBy(SecurityUtils.getUsername());
        return tVesselMapper.insertTVessel(tVessel);
    }

    /**
     * 修改船名
     * 
     * @param tVessel 船名
     * @return 结果
     */
    @Override
    public int updateTVessel(TVessel tVessel)
    {
        tVessel.setUpdateTime(DateUtils.getNowDate());
        tVessel.setUpdateBy(SecurityUtils.getUsername());
        return tVesselMapper.updateTVessel(tVessel);
    }

    /**
     * 批量删除船名
     * 
     * @param fIds 需要删除的船名ID
     * @return 结果
     */
    @Override
    public int deleteTVesselByIds(Long[] fIds)
    {
        return tVesselMapper.deleteTVesselByIds(fIds);
    }

    /**
     * 删除船名信息
     * 
     * @param fId 船名ID
     * @return 结果
     */
    @Override
    public int deleteTVesselById(Long fId)
    {
        return tVesselMapper.deleteTVesselById(fId);
    }

    @Override
    public String selectTVesselfNo(TVessel tVessel) {
        TVessel vessel = tVesselMapper.selectTVesselfNo(tVessel);
        if (StringUtils.isNotNull(vessel) && !vessel.getfId().equals(vessel.getfId())) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public String selectTVesselfName(TVessel tVessel) {
        TVessel vessel = tVesselMapper.selectTVesselfName(tVessel);
        if (StringUtils.isNotNull(vessel) && !vessel.getfId().equals(vessel.getfId())) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public String selectTVesselfEname(TVessel tVessel) {
        TVessel vessel = tVesselMapper.selectTVesselfEname(tVessel);
        if (StringUtils.isNotNull(vessel) && !vessel.getfId().equals(vessel.getfId())) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public String selectTVesselfImo(TVessel tVessel) {
        TVessel vessel = tVesselMapper.selectTVesselfImo(tVessel);
        if (StringUtils.isNotNull(vessel) && !vessel.getfId().equals(vessel.getfId())) {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public List<Map<String, Object>> selectTVesselfNumber(TVessel tVessel) {
        return tVesselMapper.selectTVesselfNumber(tVessel);
    }
}
