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.AuthenticationDTO;
import com.diagbot.dto.CustomerDTO;
import com.diagbot.dto.OrganizationDTO;
import com.diagbot.dto.UserAllDTO;
import com.diagbot.dto.UserInfoDTO;
import com.diagbot.dto.UserOrgDTO;
import com.diagbot.dto.UserOrgizationProductDTO;
import com.diagbot.entity.User;
import com.diagbot.mapper.UserMapper;
import com.diagbot.service.UserService;
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 {

    /**
     * 根据用户查找信息
     *
     * @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 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 baseMapper.getByIds(ids);
    }


    /**
     * 获取用户和机构信息
     *
     * @param userIds 用户ids
     * @return 用户和机构信息
     */
    @Override
    public List<UserOrgDTO> getUserOrgByIds(List<Long> userIds) {
        return baseMapper.getUserOrgDTOByIds(userIds);
    }
    
    //审核用户信息和机构信息
    @Override
    public boolean auditUserInfoAll(Map<String, Object> auditMap) {
        
        return baseMapper.auditUserInfoAll(auditMap);
    }
    //导出用户和机构信息
    @Override
    public List<UserInfoDTO> dependentuserInfoByTime(Map<String, Object> map) {

        return baseMapper.dependentuserInfoByTime(map);
    }

    @Override
    public List<User> getUserByOrgName(String orgName) {
        return baseMapper.getUserByOrgName(orgName);
    }
    //分页查询注册用户信息接口
    @Override
    public IPage<UserAllDTO> queryUserInformation(Page page, CustomerDTO userInfo){
    	 return baseMapper.queryUserInformation(page, userInfo);
    }
    //分页查询机构信息接口
    @Override
    public IPage<OrganizationDTO> queryMechanismInformation(Page page, CustomerDTO userInfo){
    	return baseMapper.queryMechanismInformation(page, userInfo);
    }

    //分页查询已认证用户信息和机构信息及开通产品接口
	@Override
	public IPage<UserOrgizationProductDTO> queryVerifiedUserOrganizationProduct(Page page, CustomerDTO userInfo) {
		
		return baseMapper.queryVerifiedUserOrganizationProduct(page, userInfo);
	}

	//分页查询认证中的用户信息接口
	@Override
	public IPage<AuthenticationDTO> queryAuthentication(Page page, CustomerDTO userInfo) {
		
		return baseMapper.queryAuthentication(page, userInfo);
	}

	//超管修改用户信息接口
	@Override
	public boolean updateUserInfo(Map<String, Object> amendUserInfo) {
		
		return baseMapper.updateUserInfo(amendUserInfo);
	}

	//机构信息修改接口
	@Override
	public boolean updateOrganizations(Map<String, Object> amendOrg) {
		
		return baseMapper.updateOrganizations(amendOrg);
	}

	@Override
	public List<UserInfoDTO> exportOrganizations(Map<String, Object> map) {
		
		return baseMapper.exportOrganizations(map);
	}
	


}
