package com.younike.system.service.impl;

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

import com.younike.system.domain.vo.ServerUserSearchParam;
import com.younike.system.domain.ServerTime;
import com.younike.system.domain.vo.ServerUserListVo;
import com.younike.system.domain.vo.ServerUserVo;
import com.younike.system.param.ServerUserQueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.younike.system.mapper.ServerUserMapper;
import com.younike.system.domain.ServerUser;
import com.younike.system.service.IServerUserService;

/**
 * 服务人员Service业务层处理
 *
 * @author elev
 * @date 2022-01-06
 */
@Service
public class ServerUserServiceImpl implements IServerUserService {
    @Autowired
    private ServerUserMapper serverUserMapper;

    @Override
    public List<ServerUserListVo> pageList(ServerUserQueryParam param) {
        return serverUserMapper.adminUserList(param);
    }

    /**
     * 查询服务人员
     *
     * @param serverId 服务人员主键
     * @return 服务人员
     */
    @Override
    public ServerUser selectServerUserByServerId(Long serverId) {
        return serverUserMapper.selectServerUserByServerId(serverId);
    }

    /**
     * 查询服务人员列表
     *
     * @param serverUser 服务人员
     * @return 服务人员
     */
    @Override
    public List<ServerUser> selectServerUserList(ServerUser serverUser) {
        return serverUserMapper.selectServerUserList(serverUser);
    }

    @Override
    public List<ServerUser> getServerUserList(ServerUserSearchParam searchParam) {
        return serverUserMapper.getServerUserList(searchParam);
    }

    /**
     * 新增服务人员
     *
     * @param serverUser 服务人员
     * @return 结果
     */
    @Override
    public int insertServerUser(ServerUser serverUser) {
        serverUser.setCreateTime(LocalDateTime.now());
        return serverUserMapper.insertServerUser(serverUser);
    }

    /**
     * 修改服务人员
     *
     * @param serverUser 服务人员
     * @return 结果
     */
    @Override
    public int updateServerUser(ServerUser serverUser) {
        serverUser.setUpdateTime(LocalDateTime.now());
        return serverUserMapper.updateServerUser(serverUser);
    }

    /**
     * 批量删除服务人员
     *
     * @param serverIds 需要删除的服务人员主键
     * @return 结果
     */
    @Override
    public int deleteServerUserByServerIds(Long[] serverIds) {
        return serverUserMapper.deleteServerUserByServerIds(serverIds);
    }

    /**
     * 删除服务人员信息
     *
     * @param serverId 服务人员主键
     * @return 结果
     */
    @Override
    public int deleteServerUserByServerId(Long serverId)
    {
        return serverUserMapper.deleteServerUserByServerId(serverId);
    }

    @Override
    public ServerUser findByPhone(String phone) {
        return serverUserMapper.findByPhone(phone);
    }
    @Override
    public ServerUser findByOpenid(String openid) {
        return serverUserMapper.findByOpenid(openid);
    }

    @Override
    public ServerUserVo selectUserInfo(ServerUser serverUser) {
        return serverUserMapper.selectUserInfo(serverUser);
    }

    /**
     * 获取服务人员工作时间
     * @param serverId
     * @return
     */
    @Override
    public ServerTime getServerTime(Long serverId) {
        return null;
    }

    /**
     * 批量更新
     *
     * @param users 服务人员
     */
    @Override
    public void updateServerUsers(List<ServerUser> users) {
        serverUserMapper.updateServerUsers(users);
    }
}
