package com.younike.system.service.impl;

import java.util.List;
import java.time.LocalDateTime;

import com.younike.system.domain.vo.ServerTimeSectionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.younike.system.mapper.ServerTimeSectionMapper;
import com.younike.system.domain.ServerTimeSection;
import com.younike.system.service.IServerTimeSectionService;

/**
 * 服务人员服务时间段Service业务层处理
 * 
 * @author elev
 * @date 2022-01-10
 */
@Service
public class ServerTimeSectionServiceImpl implements IServerTimeSectionService {
    @Autowired
    private ServerTimeSectionMapper serverTimeSectionMapper;

    /**
     * 查询服务人员服务时间段
     * 
     * @param sectionId 服务人员服务时间段主键
     * @return 服务人员服务时间段
     */
    @Override
    public ServerTimeSection selectServerTimeSectionBySectionId(Long sectionId) {
        return serverTimeSectionMapper.selectServerTimeSectionBySectionId(sectionId);
    }

    /**
     * 查询服务人员服务时间段列表
     * 
     * @param serverTimeSection 服务人员服务时间段
     * @return 服务人员服务时间段
     */
    @Override
    public List<ServerTimeSection> selectServerTimeSectionList(ServerTimeSection serverTimeSection) {
        return serverTimeSectionMapper.selectServerTimeSectionList(serverTimeSection);
    }

    /**
     * 新增服务人员服务时间段
     * 
     * @param serverTimeSection 服务人员服务时间段
     * @return 结果
     */
    @Override
    public int insertServerTimeSection(ServerTimeSection serverTimeSection) {
        serverTimeSection.setCreateTime(LocalDateTime.now());
        return serverTimeSectionMapper.insertServerTimeSection(serverTimeSection);
    }

    /**
     * 修改服务人员服务时间段
     * 
     * @param serverTimeSection 服务人员服务时间段
     * @return 结果
     */
    @Override
    public int updateServerTimeSection(ServerTimeSection serverTimeSection) {
        serverTimeSection.setUpdateTime(LocalDateTime.now());
        return serverTimeSectionMapper.updateServerTimeSection(serverTimeSection);
    }

    /**
     * 批量删除服务人员服务时间段
     * 
     * @param sectionIds 需要删除的服务人员服务时间段主键
     * @return 结果
     */
    @Override
    public int deleteServerTimeSectionBySectionIds(Long[] sectionIds) {
        return serverTimeSectionMapper.deleteServerTimeSectionBySectionIds(sectionIds);
    }

    /**
     * 删除服务人员服务时间段信息
     * 
     * @param sectionId 服务人员服务时间段主键
     * @return 结果
     */
    @Override
    public int deleteServerTimeSectionBySectionId(Long sectionId)
    {
        return serverTimeSectionMapper.deleteServerTimeSectionBySectionId(sectionId);
    }

    @Override
    public int updateServerTimeSectionVo(ServerTimeSectionVo serverTimeSection) {
        serverTimeSection.setUpdateTime(LocalDateTime.now());
        serverTimeSection.setUpdateBy(serverTimeSection.getServerId());
        return serverTimeSectionMapper.updateServerTimeSectionVo(serverTimeSection);
    }
    @Override
    public int insertServerTimeSectionVo(ServerTimeSectionVo serverTimeSection) {
        serverTimeSection.setDelFlag("0");
        serverTimeSection.setCreateBy(serverTimeSection.getServerId());
        serverTimeSection.setCreateTime(LocalDateTime.now());
        serverTimeSection.setUpdateTime(LocalDateTime.now());
        serverTimeSection.setUpdateBy(serverTimeSection.getServerId());
        return serverTimeSectionMapper.insertServerTimeSectionVo(serverTimeSection);
    }
}
