package com.diagbot.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diagbot.dto.UserInfoDTO;
import com.diagbot.dto.UserInfoExportDTO;
import com.diagbot.dto.UserOrgDTO;
import com.diagbot.entity.User;
import com.diagbot.mapper.UserMapper;
import com.diagbot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gaodm
 * @since 2018-08-02
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    UserMapper userMapper;

    /**
     * 根据用户查找信息
     * @param username 用户名
     * @return 用户信息
     */
    public User findByName(String username){
        return baseMapper.findByName(username);
    }

    /**
     * 根据用户id获取用户信息(示例)
     * @param page 翻页信息
     * @param user 用户输入信息
     * @return 翻页用户信息
     */
    @Override
    public IPage<User> selectUserListPage(Page<User> page, User user) {
        return baseMapper.selectUserListPage(page, user);
    }
    @Override
    public IPage<UserInfoDTO>  selectUserInfoListPage(Page<UserInfoDTO> page,UserInfoDTO userInfo){
    	return baseMapper.selectUserInfoListPage(page, userInfo);
    	
    }

	@Override
	public boolean  updateUserInfoAll(Map<String, Object> userMap) {
		return baseMapper.updateUserInfoAll(userMap);
		
	}
	@Override
	public boolean updateDeleted(Map<String,Object> map){
		return baseMapper.updateDeleted(map);
		
	}

    @Override
    public IPage<User> indexPage(Page<User> page, User user) {
        return baseMapper.indexPage(page, user);
    }

    @Override
    public List<User> getByIds(List<Long> ids) {
        return userMapper.getByIds(ids);
    }


    /**
     * 获取用户和机构信息
     * @param userIds 用户ids
     * @return 用户和机构信息
     */
    @Override
    public List<UserOrgDTO> getUserOrgByIds(List<Long> userIds) {
        return userMapper.getUserOrgDTOByIds(userIds);
    }

    @Override
    public boolean auditUserInfoAll(Map<String,Object> auditMap) {
	    // TODO Auto-generated method stub
	    return baseMapper.auditUserInfoAll(auditMap);
    }

	@Override
	public List<UserInfoExportDTO> dependentuserInfoByTime(Map<String, Object> map) {

		return baseMapper.dependentuserInfoByTime(map);
	}

    @Override
    public List<User> getUserByOrgName(String orgName) {
        return baseMapper.getUserByOrgName(orgName);
    }

}
