package com.ruoyi.baseinfo.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.baseinfo.mapper.BaseShiftInfoMapper;
import com.ruoyi.baseinfo.domain.BaseShiftInfo;
import com.ruoyi.baseinfo.service.IBaseShiftInfoService;
import com.ruoyi.common.core.text.Convert;

/**
 * 班次基础信息Service业务层处理
 * 
 * @author CaesarBao
 * @date 2020-10-20
 */
@Service
public class BaseShiftInfoServiceImpl implements IBaseShiftInfoService 
{
    @Autowired
    private BaseShiftInfoMapper baseShiftInfoMapper;

    /**
     * 查询班次基础信息
     * 
     * @param objid 班次基础信息ID
     * @return 班次基础信息
     */
    @Override
    public BaseShiftInfo selectBaseShiftInfoById(Long objid)
    {
        return baseShiftInfoMapper.selectBaseShiftInfoById(objid);
    }

    /**
     * 查询班次基础信息列表
     * 
     * @param baseShiftInfo 班次基础信息
     * @return 班次基础信息
     */
    @Override
    public List<BaseShiftInfo> selectBaseShiftInfoList(BaseShiftInfo baseShiftInfo)
    {
        return baseShiftInfoMapper.selectBaseShiftInfoList(baseShiftInfo);
    }

    /**
     * 新增班次基础信息
     * 
     * @param baseShiftInfo 班次基础信息
     * @return 结果
     */
    @Override
    public int insertBaseShiftInfo(BaseShiftInfo baseShiftInfo)
    {
        baseShiftInfo.setCreateTime(DateUtils.getNowDate());
        return baseShiftInfoMapper.insertBaseShiftInfo(baseShiftInfo);
    }

    /**
     * 修改班次基础信息
     * 
     * @param baseShiftInfo 班次基础信息
     * @return 结果
     */
    @Override
    public int updateBaseShiftInfo(BaseShiftInfo baseShiftInfo)
    {
        baseShiftInfo.setUpdateTime(DateUtils.getNowDate());
        return baseShiftInfoMapper.updateBaseShiftInfo(baseShiftInfo);
    }

    /**
     * 删除班次基础信息对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBaseShiftInfoByIds(String ids)
    {
        return baseShiftInfoMapper.deleteBaseShiftInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除班次基础信息信息
     * 
     * @param objid 班次基础信息ID
     * @return 结果
     */
    @Override
    public int deleteBaseShiftInfoById(Long objid)
    {
        return baseShiftInfoMapper.deleteBaseShiftInfoById(objid);
    }

    @Override
    public List<BaseShiftInfo> selectEditBaseShiftInfoList(String shiftid)
    {
        BaseShiftInfo baseShiftInfos = new BaseShiftInfo();
        List<BaseShiftInfo> baseShiftInfoList = baseShiftInfoMapper.selectBaseShiftInfoList(baseShiftInfos);
        for (BaseShiftInfo baseShiftInfo:baseShiftInfoList
             ) {
            if(baseShiftInfo.getShiftid().equals(shiftid)){
                baseShiftInfo.setFlag(true);
                break;
            }
        }
        return baseShiftInfoList;
    }
}
