package com.hz.pm.api.user.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hz.pm.api.user.model.entity.UserInfo;
import com.ningdatech.basic.util.CollUtils;

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

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author Lierbao
 * @since 2023-02-01
 */
public interface IUserInfoService extends IService<UserInfo> {

    UserInfo getUserInfoByPhoneNo(String phoneNo);

    UserInfo getUserInfoByEmployeeCode(String employeeCode);

    UserInfo getUserInfoByAccountId(Long accountId);

    List<UserInfo> getUserInfoByEmployeeCodes(Collection<String> employeeCodes);

    default Map<String, Long> listUserIdByMhUserIds(Collection<String> mhUserIds) {
        LambdaQueryWrapper<UserInfo> query = Wrappers.lambdaQuery(UserInfo.class)
                .select(UserInfo::getMhUserId, UserInfo::getId)
                .in(UserInfo::getMhUserId, mhUserIds);
        return CollUtils.listToMap(list(query), UserInfo::getMhUserId, UserInfo::getId);
    }

}
